> From: Robert [mailto:pac0446@bigpond.net.au]

> Sent: Sunday, 30 August 2009 20:58
> To: Aaron Giles
> Subject: mame update submission
> 
> 
> Hi Aaron,
> 
> I meant to submit this before u3 came out but just been too busy with
> real
> life.
> 
> So, I'll send it now before it gets overwritten again.. it doesn't
> appear to
> cause any problem in cojag but maybe you should do a quick check just
> to
> make sure..
> 
> The changes (which are only for MESS): [Robbbert]
> - Added RGB 24-bit pixels (for Iron Soldier)
> - Added depth 0 and 1 to scaled bitmaps (for Val Disere Skiing)
> - Preliminary work on PIT support
> 
> The files go into src/mame/video
> 
> Thanks,
> - Robert
This commit is contained in:
Aaron Giles 2009-09-06 21:42:59 +00:00
parent 4ef3afec0a
commit 3745cd514f
2 changed files with 217 additions and 49 deletions

View File

@ -80,10 +80,10 @@ INLINE void bitmap_4_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos,
{
if (firstpix & 7)
{
UINT32 pixsrc = src[firstpix / 8];
UINT32 pixsrc = src[firstpix >> 3];
while (firstpix & 7)
{
int pix = (pixsrc >> (4 * (~firstpix & 7))) & 0x0f;
int pix = (pixsrc >> ((~firstpix & 7) << 2)) & 0x0f;
if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
{
if (!(flags & 2))
@ -96,8 +96,8 @@ INLINE void bitmap_4_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos,
}
}
firstpix /= 8;
iwidth /= 8;
firstpix >>= 3;
iwidth >>= 3;
iwidth -= firstpix;
while (iwidth-- > 0)
@ -178,7 +178,7 @@ INLINE void bitmap_4_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos,
xpos += dxpos;
}
else
xpos += 8 * dxpos;
xpos += dxpos << 3;
}
}
@ -246,10 +246,10 @@ INLINE void bitmap_8_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos,
{
if (firstpix & 3)
{
UINT32 pixsrc = src[firstpix / 4];
UINT32 pixsrc = src[firstpix >> 2];
while (firstpix & 3)
{
UINT8 pix = pixsrc >> (8 * (~firstpix & 3));
UINT8 pix = pixsrc >> ((~firstpix & 3) << 3);
if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
{
if (!(flags & 2))
@ -262,8 +262,8 @@ INLINE void bitmap_8_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos,
}
}
firstpix /= 4;
iwidth /= 4;
firstpix >>= 2;
iwidth >>= 2;
iwidth -= firstpix;
while (iwidth-- > 0)
@ -308,7 +308,7 @@ INLINE void bitmap_8_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos,
xpos += dxpos;
}
else
xpos += 4 * dxpos;
xpos += dxpos << 2;
}
}
@ -376,7 +376,7 @@ INLINE void bitmap_16_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos
{
if (firstpix & 1)
{
UINT16 pix = src[firstpix / 2];
UINT16 pix = src[firstpix >> 1];
if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
{
if (!(flags & 2))
@ -387,8 +387,8 @@ INLINE void bitmap_16_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos
xpos += dxpos;
}
firstpix /= 2;
iwidth /= 2;
firstpix >>= 1;
iwidth >>= 1;
iwidth -= firstpix;
while (iwidth-- > 0)
@ -415,7 +415,7 @@ INLINE void bitmap_16_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos
xpos += dxpos;
}
else
xpos += 2 * dxpos;
xpos += dxpos << 1;
}
}
@ -473,10 +473,88 @@ static void (*const bitmap16[8])(INT32, INT32, UINT32 *, INT32) =
/*************************************
*
* 32bpp bitmap renderers - needs to be verified
*
*************************************/
INLINE void bitmap_32_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
{
iwidth -= firstpix;
while (iwidth-- > 0)
{
UINT32 pix = src[firstpix++];
if (xpos < 760)
{
scanline[xpos++] = (pix&0xffff0000)>>16;
scanline[xpos++] = pix&0xffff;
}
}
}
static void bitmap_32_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 0, 1);
}
static void bitmap_32_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 1, -1);
}
static void bitmap_32_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 2, 1);
}
static void bitmap_32_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 3, -1);
}
static void bitmap_32_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 4, 1);
}
static void bitmap_32_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 5, -1);
}
static void bitmap_32_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 6, 1);
}
static void bitmap_32_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
{
bitmap_32_draw(firstpix, iwidth, src, xpos, 7, -1);
}
static void (*const bitmap32[8])(INT32, INT32, UINT32 *, INT32) =
{
bitmap_32_0,
bitmap_32_1,
bitmap_32_2,
bitmap_32_3,
bitmap_32_4,
bitmap_32_5,
bitmap_32_6,
bitmap_32_7
};
INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth)
{
int ppl = 32 / depth;
UINT32 data = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)];
UINT32 data = src[((i & ppl) / ppl) + ((i / (ppl<<1)) * (pitch<<1))];
UINT8 pix = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
return pix;
}
@ -534,8 +612,8 @@ static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc,
UINT32 dwidth = (lower2 >> 18) & 0x3ff;
UINT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
UINT8 _index = (upper2 >> 5) & 0xfe;
UINT8 flags = (upper2 >> 13) & 0x0f;
UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
UINT8 flags = (upper2 >> 13) & 0x07;
UINT8 firstpix = ((upper2 >> 17) & 0x3f) >> depthlog;
int i, dxpos = (flags & 1) ? -1 : 1;
/* preadjust for firstpix */
@ -547,8 +625,7 @@ static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc,
/* 1bpp case */
case 0:
{
UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
clut += _index & 0xfe;
UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
/* non-blending */
if (!(flags & 2))
@ -581,8 +658,7 @@ static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc,
/* 2bpp case */
case 1:
{
UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
clut += _index & 0xfc;
UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
/* non-blending */
if (!(flags & 2))
@ -618,8 +694,8 @@ static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc,
if (pitch != 1)
logerror("Unhandled pitch = %d\n", pitch);
clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf0);
(*bitmap4[flags & 7])(firstpix, iwidth, src, xpos);
clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
(*bitmap4[flags])(firstpix, iwidth, src, xpos);
break;
/* 8bpp case */
@ -629,7 +705,7 @@ static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc,
logerror("Unhandled pitch = %d\n", pitch);
clutbase = (UINT16 *)jaguar_gpu_clut;
(*bitmap8[flags & 7])(firstpix, iwidth, src, xpos);
(*bitmap8[flags])(firstpix, iwidth, src, xpos);
break;
/* 16bpp case */
@ -638,7 +714,16 @@ static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc,
if (pitch != 1)
logerror("Unhandled pitch = %d\n", pitch);
(*bitmap16[flags & 7])(firstpix, iwidth, src, xpos);
(*bitmap16[flags])(firstpix, iwidth, src, xpos);
break;
/* 32bpp case */
case 5:
/* only handle pitch=1 for now */
if (pitch != 1)
logerror("Unhandled pitch = %d\n", pitch);
(*bitmap32[flags])(firstpix, iwidth, src, xpos);
break;
default:
@ -715,8 +800,8 @@ static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata,
UINT32 dwidth = (lower2 >> 18) & 0x3ff;
INT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
UINT8 _index = (upper2 >> 5) & 0xfe;
UINT8 flags = (upper2 >> 13) & 0x0f;
UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
UINT8 flags = (upper2 >> 13) & 0x07;
UINT8 firstpix = ((upper2 >> 17) & 0x3f) >> depthlog;
INT32 hscale = lower3 & 0xff;
INT32 vscale = (lower3 >> 8) & 0xff;
@ -724,7 +809,7 @@ static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata,
int dxpos = (flags & 1) ? -1 : 1;
int xpix = firstpix, yinc;
/* only handle pitch=0 for now */
/* only handle pitch=1 (sequential data) for now */
if (pitch != 1)
logerror("Unhandled pitch = %d\n", pitch);
if (flags & 2)
@ -742,15 +827,58 @@ static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata,
/* switch off the depth */
switch (depthlog)
{
case 2:
case 0:
{
UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
clut += _index & 0xf0;
UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
/* render in phrases */
while (xpix < iwidth)
{
UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f;
UINT16 pix = (src[xpix >> 5] >> (~xpix & 31)) & 0x01;
while (xleft > 0)
{
if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
scanline[xpos] = clut[BYTE_XOR_BE(pix)];
xpos += dxpos;
xleft -= 0x20;
}
while (xleft <= 0)
xleft += hscale, xpix++;
}
break;
}
case 1:
{
UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
/* render in phrases */
while (xpix < iwidth)
{
UINT16 pix = (src[xpix >> 4] >> ((~xpix & 15) << 1)) & 0x03;
while (xleft > 0)
{
if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
scanline[xpos] = clut[BYTE_XOR_BE(pix)];
xpos += dxpos;
xleft -= 0x20;
}
while (xleft <= 0)
xleft += hscale, xpix++;
}
break;
}
case 2:
{
UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
/* render in phrases */
while (xpix < iwidth)
{
UINT16 pix = (src[xpix >> 3] >> ((~xpix & 7) << 2)) & 0x0f;
while (xleft > 0)
{
@ -772,7 +900,7 @@ static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata,
/* render in phrases */
while (xpix < iwidth)
{
UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff;
UINT16 pix = (src[xpix >> 2] >> ((~xpix & 3) << 3)) & 0xff;
while (xleft > 0)
{
@ -790,7 +918,7 @@ static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata,
case 4:
while (xpix < iwidth)
{
UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16);
UINT16 pix = src[xpix >> 1] >> ((~xpix & 1) << 4);
while (xleft > 0)
{
@ -831,7 +959,7 @@ static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata,
/*************************************
*
* Brach object processor
* Branch object processor
*
*************************************/
@ -937,10 +1065,10 @@ static void process_object_list(running_machine *machine, int vc, UINT16 *_scanl
/* GPU interrupt */
case 2:
gpu_regs[OB_HH]=objdata[1];
gpu_regs[OB_HL]=objdata[2];
gpu_regs[OB_LH]=objdata[3];
gpu_regs[OB_LL]=objdata[4];
gpu_regs[OB_HH]=(objdata[1]&0xffff0000)>>16;
gpu_regs[OB_HL]=objdata[1]&0xffff;
gpu_regs[OB_LH]=(objdata[0]&0xffff0000)>>16;
gpu_regs[OB_LL]=objdata[0]&0xffff;
cpu_irq_state |= 2;
update_cpu_irq(machine);
done=1;

View File

@ -424,6 +424,8 @@ static void jaguar_set_palette(UINT16 vmode)
{
/* YCC full */
case 0x000:
/* RGB24 */
case 0x002:
for (i = 0; i < 65536; i++)
{
UINT8 r = (red_lookup[i >> 8] * (i & 0xff)) >> 8;
@ -465,6 +467,7 @@ static void jaguar_set_palette(UINT16 vmode)
/* others */
default:
logerror("Can't handle mode %X\n", vmode);
fprintf(stderr, "Can't handle mode %X\n", vmode);
break;
}
}
@ -595,7 +598,7 @@ READ32_HANDLER( jaguar_blitter_r )
switch (offset)
{
case B_CMD: /* B_CMD */
return 0x00000001;
return 1;
default:
logerror("%08X:Blitter read register @ F022%02X\n", cpu_get_previouspc(space->cpu), offset * 4);
@ -643,17 +646,40 @@ READ16_HANDLER( jaguar_tom_regs_r )
return gpu_regs[offset];
}
#if 0
static TIMER_CALLBACK( jaguar_pit )
{
attotime sample_period;
cpu_irq_state |= 4;
update_cpu_irq(machine);
if (gpu_regs[PIT0])
{
sample_period = ATTOTIME_IN_NSEC(cpu_get_clock(cputag_get_cpu(machine,"gpu")) / (1+gpu_regs[PIT0]) / (1+gpu_regs[PIT1]));
// timer_set(machine, sample_period, NULL, 0, jaguar_pit);
}
}
#endif
WRITE16_HANDLER( jaguar_tom_regs_w )
{
UINT32 reg_store = gpu_regs[offset];
// attotime sample_period;
if (offset < GPU_REGS)
{
COMBINE_DATA(&gpu_regs[offset]);
switch (offset)
{
#if 0
case PIT1:
if (gpu_regs[PIT0])
{
sample_period = ATTOTIME_IN_NSEC(cpu_get_clock(cputag_get_cpu(space->machine,"gpu")) / (1+gpu_regs[PIT0]) / (1+gpu_regs[PIT1]));
timer_set(space->machine, sample_period, NULL, 0, jaguar_pit);
}
break;
#endif
case INT1:
cpu_irq_state &= ~(gpu_regs[INT1] >> 8);
update_cpu_irq(space->machine);
@ -687,7 +713,7 @@ WRITE16_HANDLER( jaguar_tom_regs_w )
int hbend = effective_hvalue(ENABLE_BORDERS ? gpu_regs[HBE] : MIN(gpu_regs[HDB1], gpu_regs[HDB2]));
int hbstart = effective_hvalue(gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
int vperiod = (gpu_regs[VP] & 0x7ff) + 1;
int vbend = gpu_regs[VBE] & 0x7ff;
int vbend = MAX(gpu_regs[VBE],gpu_regs[VDB]) & 0x7ff;
int vbstart = gpu_regs[VBB] & 0x7ff;
/* adjust for the half-lines */
@ -774,9 +800,9 @@ static TIMER_CALLBACK( cojag_scanline_update )
/* only run if video is enabled and we are past the "display begin" */
if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff))
{
UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc / 2, 0);
UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc >> 1, 0);
int maxx = visarea->max_x;
int hde = effective_hvalue(gpu_regs[HDE]) / 2;
int hde = effective_hvalue(gpu_regs[HDE]) >> 1;
UINT16 x,scanline[760];
UINT8 y,pixel_width = ((gpu_regs[VMODE]>>10)&3)+1;
@ -792,10 +818,24 @@ static TIMER_CALLBACK( cojag_scanline_update )
process_object_list(machine, vc, scanline);
/* copy the data to the target, clipping */
if ((gpu_regs[VMODE] & 0x106) == 0x002) /* RGB24 */
{
for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x+=2)
for (y = 0; y < pixel_width; y++)
{
UINT8 r = pen_table[(scanline[x]&0xff)|256];
UINT8 g = pen_table[(scanline[x]>>8)|512];
UINT8 b = pen_table[scanline[x+1]&0xff];
dest[hdb++] = MAKE_RGB(r, g, b);
}
}
else
{
for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++)
for (y = 0; y < pixel_width; y++)
dest[hdb++] = pen_table[scanline[x]];
}
}
/* adjust the timer in a loop, to handle missed cases */
do