summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/xavix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/xavix.cpp')
-rw-r--r--src/mame/video/xavix.cpp192
1 files changed, 62 insertions, 130 deletions
diff --git a/src/mame/video/xavix.cpp b/src/mame/video/xavix.cpp
index 58a12e516a3..89571158df1 100644
--- a/src/mame/video/xavix.cpp
+++ b/src/mame/video/xavix.cpp
@@ -109,97 +109,61 @@ WRITE8_MEMBER(xavix_state::spriteram_w)
}
}
+double xavix_state::hue2rgb(double p, double q, double t)
+{
+ if (t < 0) t += 1;
+ if (t > 1) t -= 1;
+ if (t < 1 / 6.0f) return p + (q - p) * 6 * t;
+ if (t < 1 / 2.0f) return q;
+ if (t < 2 / 3.0f) return p + (q - p) * (2 / 3.0f - t) * 6;
+ return p;
+}
+
void xavix_state::update_pen(int pen, uint8_t shval, uint8_t lval)
{
uint16_t dat;
dat = shval;
dat |= lval << 8;
- int y_raw = (dat & 0x1f00) >> 8;
- int c_raw = (dat & 0x00e0) >> 5;
+ int l_raw = (dat & 0x1f00) >> 8;
+ int s_raw = (dat & 0x00e0) >> 5;
int h_raw = (dat & 0x001f) >> 0;
- // The dividers may be dynamic
- double y = y_raw / 20.0;
- double c = c_raw / 5.0;
-
- // These weights may be dynamic too. They're standard NTSC values, would they change on PAL?
- const double wr = 0.299;
- const double wg = 0.587;
- const double wb = 0.114;
-
- // Table of hues
- // Values 24+ are transparent
-
- const double hues[32][3] = {
- { 1.00, 0.00, 0.00 },
- { 1.00, 0.25, 0.00 },
- { 1.00, 0.50, 0.00 },
- { 1.00, 0.75, 0.00 },
- { 1.00, 1.00, 0.00 },
- { 0.75, 1.00, 0.00 },
- { 0.50, 1.00, 0.00 },
- { 0.25, 1.00, 0.00 },
- { 0.00, 1.00, 0.00 },
- { 0.00, 1.00, 0.25 },
- { 0.00, 1.00, 0.50 },
- { 0.00, 1.00, 0.75 },
- { 0.00, 1.00, 1.00 },
- { 0.00, 0.75, 1.00 },
- { 0.00, 0.50, 1.00 },
- { 0.00, 0.25, 1.00 },
- { 0.00, 0.00, 1.00 },
- { 0.25, 0.00, 1.00 },
- { 0.50, 0.00, 1.00 },
- { 0.75, 0.00, 1.00 },
- { 1.00, 0.00, 1.00 },
- { 1.00, 0.00, 0.75 },
- { 1.00, 0.00, 0.50 },
- { 1.00, 0.00, 0.25 },
-
- { 0 , 0 , 0 },
- { 0 , 0 , 0 },
- { 0 , 0 , 0 },
- { 0 , 0 , 0 },
- { 0 , 0 , 0 },
- { 0 , 0 , 0 },
- { 0 , 0 , 0 },
- { 0 , 0 , 0 },
- };
-
- double r0 = hues[h_raw][0];
- double g0 = hues[h_raw][1];
- double b0 = hues[h_raw][2];
-
- double z = wr * r0 + wg * g0 + wb * b0;
-
- if(y < z)
- c *= y/z;
- else if(z < 1)
- c *= (1-y) / (1-z);
-
- double r1 = (r0 - z) * c + y;
- double g1 = (g0 - z) * c + y;
- double b1 = (b0 - z) * c + y;
-
- if(r1 < 0)
- r1 = 0;
- else if(r1 > 1)
- r1 = 1.0;
-
- if(g1 < 0)
- g1 = 0;
- else if(g1 > 1)
- g1 = 1.0;
-
- if(b1 < 0)
- b1 = 0;
- else if(b1 > 1)
- b1 = 1.0;
-
- int r_real = r1 * 255.0f;
- int g_real = g1 * 255.0f;
- int b_real = b1 * 255.0f;
+ //if (h_raw > 24)
+ // LOG("hraw >24 (%02x)\n", h_raw);
+
+ //if (l_raw > 24)
+ // LOG("lraw >24 (%02x)\n", l_raw);
+
+ //if (s_raw > 7)
+ // LOG("s_raw >5 (%02x)\n", s_raw);
+
+ double l = (double)l_raw / 24.0f; // ekara and drgqst go up to 23 during fades, expect that to be brightest
+ l = l * (std::atan(1)*2); // does not appear to be a linear curve
+ l = std::sin(l);
+
+ double s = (double)s_raw / 7.0f;
+ s = s * (std::atan(1)*2); // does not appear to be a linear curve
+ s = std::sin(s);
+
+ double h = (double)h_raw / 24.0f; // hue values 24-31 render as transparent
+
+ double r, g, b;
+
+ if (s == 0) {
+ r = g = b = l; // greyscale
+ }
+ else {
+ double q = l < 0.5f ? l * (1 + s) : l + s - l * s;
+ double p = 2 * l - q;
+ r = hue2rgb(p, q, h + 1 / 3.0f);
+ g = hue2rgb(p, q, h);
+ b = hue2rgb(p, q, h - 1 / 3.0f);
+ }
+
+ int r_real = r * 255.0f;
+ int g_real = g * 255.0f;
+ int b_real = b * 255.0f;
m_palette->set_pen_color(pen, r_real, g_real, b_real);
}
@@ -408,8 +372,8 @@ void xavix_state::draw_tilemap_line(screen_device &screen, bitmap_ind16 &bitmap,
int scrollx = tileregs[0x4];
int basereg;
- int flipx = (tileregs[0x03]&0x40)>>6;
- int flipy = (tileregs[0x03]&0x80)>>7;
+ int flipx = 0;
+ int flipy = 0;
int gfxbase;
// tile 0 is always skipped, doesn't even point to valid data packets in alt mode
@@ -821,49 +785,26 @@ uint32_t xavix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap,
// temp, needs priority, transparency etc. also it's far bigger than the screen, I guess it must get scaled?!
if (m_bmp_base)
{
- // looks like it can zoom the bitmap using these?
- uint16_t top = ((m_bmp_base[0x01] << 8) | m_bmp_base[0x00]);
- uint16_t bot = ((m_bmp_base[0x03] << 8) | m_bmp_base[0x02]);
- uint16_t lft = ((m_bmp_base[0x05] << 8) | m_bmp_base[0x04]);
- uint16_t rgt = ((m_bmp_base[0x07] << 8) | m_bmp_base[0x06]);
-
- // and can specify base address relative start / end positions with these for data reading to be cut off?
- uint16_t topadr = ((m_bmp_base[0x09] << 8) | m_bmp_base[0x08]);
- uint16_t botadr = ((m_bmp_base[0x0b] << 8) | m_bmp_base[0x0a]);
- uint16_t lftadr = ((m_bmp_base[0x0d] << 8) | m_bmp_base[0x0c]);
- uint16_t rgtadr = ((m_bmp_base[0x0f] << 8) | m_bmp_base[0x0e]);
-
- uint16_t start = ((m_bmp_base[0x11] << 8) | m_bmp_base[0x10]);
- uint8_t end = m_bmp_base[0x12]; // ?? related to width?
- uint8_t size = m_bmp_base[0x13]; // some kind of additional scaling?
- uint8_t mode = m_bmp_base[0x14]; // eanble,bpp, zval etc.
-
- uint32_t unused = ((m_bmp_base[0x15] << 16) | (m_bmp_base[0x16] << 8) | (m_bmp_base[0x17] << 0));
-
- if (mode & 0x01)
+ if (m_bmp_base[0x14] & 0x01)
{
- popmessage("bitmap t:%04x b:%04x l:%04x r:%04x -- -- ba:%04x la:%04x ra:%04x -- -- end:%02x - size:%02x unused:%08x",
- top, bot, lft, rgt,
- /*topadr*/ botadr, lftadr, rgtadr,
- /*start*/ end, size, unused);
-
- int base = start * 0x800;
- int base2 = topadr * 0x8;
+ popmessage("bitmap %02x %02x %02x %02x %02x %02x %02x %02x -- -- %02x %02x %02x %02x %02x %02x -- -- %02x %02x %02x %02x %02x %02x",
+ m_bmp_base[0x00], m_bmp_base[0x01], m_bmp_base[0x02], m_bmp_base[0x03], m_bmp_base[0x04], m_bmp_base[0x05], m_bmp_base[0x06], m_bmp_base[0x07],
+ /*m_bmp_base[0x08], m_bmp_base[0x09],*/ m_bmp_base[0x0a], m_bmp_base[0x0b], m_bmp_base[0x0c], m_bmp_base[0x0d], m_bmp_base[0x0e], m_bmp_base[0x0f],
+ /*m_bmp_base[0x10], m_bmp_base[0x11],*/ m_bmp_base[0x12], m_bmp_base[0x13], m_bmp_base[0x14], m_bmp_base[0x15], m_bmp_base[0x16], m_bmp_base[0x17]);
- int bpp = ((mode & 0x0e) >> 1) + 1;
- int zval = ((mode & 0xf0) >> 4);
-
- int width = (rgtadr * 8) / bpp;
+ int base = ((m_bmp_base[0x11] << 8) | m_bmp_base[0x10]) * 0x800;
+ int base2 = ((m_bmp_base[0x09] << 8) | m_bmp_base[0x08]) * 0x8;
//int count = 0;
set_data_address(base + base2, 0);
- for (int y = top; y < 256; y++)
+ for (int y = 0; y < 256; y++)
{
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < 512; x++)
{
uint16_t* yposptr = &bitmap.pix16(y);
- uint16_t* zyposptr = &m_zbuffer.pix16(y);
+
+ int bpp = 6;
uint8_t dat = 0;
for (int i = 0; i < bpp; i++)
@@ -871,17 +812,8 @@ uint32_t xavix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap,
dat |= (get_next_bit() << i);
}
- if (((x <= cliprect.max_x) && (x >= cliprect.min_x)) && ((y <= cliprect.max_y) && (y >= cliprect.min_y)))
- {
- if ((m_bmp_palram_sh[dat] & 0x1f) < 24) // same transparency logic as everything else? (baseball title)
- {
- if (zval >= zyposptr[x])
- {
- yposptr[x] = dat + 0x100;
- zyposptr[x] = zval;
- }
- }
- }
+ if (x < cliprect.max_x)
+ yposptr[x] = dat + 0x100;
}
}