summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Angelo Salese <angelosa@users.noreply.github.com>2013-08-28 22:56:07 +0000
committer Angelo Salese <angelosa@users.noreply.github.com>2013-08-28 22:56:07 +0000
commit85ed8d906129982143045c183af0b3bd4ef088b9 (patch)
tree04eb02708c9f73dc065be1b4367a7a0c0e9fa9c8 /src
parentd2bb45c2785a7db8f027205933ce1dfa4af48b8c (diff)
PowerVR2: Added preliminary YUV converter [Angelo Salese]
Diffstat (limited to 'src')
-rw-r--r--src/mame/machine/dc.c9
-rw-r--r--src/mame/video/powervr2.c59
-rw-r--r--src/mame/video/powervr2.h6
-rw-r--r--src/mess/drivers/dccons.c4
4 files changed, 62 insertions, 16 deletions
diff --git a/src/mame/machine/dc.c b/src/mame/machine/dc.c
index 914778d332e..c56ac9ba92f 100644
--- a/src/mame/machine/dc.c
+++ b/src/mame/machine/dc.c
@@ -187,12 +187,6 @@ TIMER_CALLBACK_MEMBER(dc_state::ch2_dma_irq)
dc_update_interrupt_status();
}
-TIMER_CALLBACK_MEMBER(dc_state::yuv_fifo_irq)
-{
- dc_sysctrl_regs[SB_ISTNRM] |= IST_EOXFER_YUV;
- dc_update_interrupt_status();
-}
-
void dc_state::wave_dma_execute(address_space &space)
{
UINT32 src,dst,size;
@@ -437,9 +431,6 @@ WRITE64_MEMBER(dc_state::dc_sysctrl_w )
/* TODO: timing is a guess */
machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(ddtdata.length/4), timer_expired_delegate(FUNC(dc_state::ch2_dma_irq),this));
- /* simulate YUV FIFO processing here (HACK! should go inside the YUV FIFO itself) */
- if((address & 0x1800000) == 0x0800000)
- machine().scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(dc_state::yuv_fifo_irq),this));
}
break;
diff --git a/src/mame/video/powervr2.c b/src/mame/video/powervr2.c
index 8cae458dcbb..26996b06ca2 100644
--- a/src/mame/video/powervr2.c
+++ b/src/mame/video/powervr2.c
@@ -632,7 +632,7 @@ void powervr2_device::tex_get_info(texinfo *t)
t->vqbase = t->address;
t->blend = use_alpha ? blend_functions[t->blend_mode] : bl10;
- // fprintf(stderr, "tex %d %d %d %d\n", t->pf, t->mode, pal_ram_ctrl, t->mipmapped);
+ //fprintf(stderr, "tex %d %d %d %d\n", t->pf, t->mode, pal_ram_ctrl, t->mipmapped);
switch(t->pf) {
case 0: // 1555
@@ -1407,8 +1407,10 @@ WRITE32_MEMBER( powervr2_device::ta_yuv_tex_base_w )
COMBINE_DATA(&ta_yuv_tex_base);
logerror("%s: ta_yuv_tex_base = %08x\n", tag(), ta_yuv_tex_base);
- // hack, this interrupt is generated after transfering a set amount of data
- //irq_cb(EOXFER_YUV_IRQ);
+ ta_yuv_index = 0;
+ ta_yuv_x = 0;
+ ta_yuv_y = 0;
+
}
READ32_MEMBER( powervr2_device::ta_yuv_tex_ctrl_r )
@@ -1419,9 +1421,12 @@ READ32_MEMBER( powervr2_device::ta_yuv_tex_ctrl_r )
WRITE32_MEMBER( powervr2_device::ta_yuv_tex_ctrl_w )
{
COMBINE_DATA(&ta_yuv_tex_ctrl);
+ ta_yuv_x_size = ((ta_yuv_tex_ctrl & 0x3f)+1)*16;
+ ta_yuv_y_size = (((ta_yuv_tex_ctrl>>8) & 0x3f)+1)*16;
logerror("%s: ta_yuv_tex_ctrl = %08x\n", tag(), ta_yuv_tex_ctrl);
}
+/* TODO */
READ32_MEMBER( powervr2_device::ta_yuv_tex_cnt_r )
{
return ta_yuv_tex_cnt;
@@ -1943,8 +1948,54 @@ WRITE64_MEMBER( powervr2_device::ta_fifo_poly_w )
}
-WRITE64_MEMBER( powervr2_device::ta_fifo_yuv_w )
+WRITE8_MEMBER( powervr2_device::ta_fifo_yuv_w )
{
+ //printf("%08x %08x\n",ta_yuv_index++,ta_yuv_tex_ctrl);
+
+ //popmessage("YUV fifo write %08x %08x",ta_yuv_index,ta_yuv_tex_ctrl);
+
+ yuv_fifo[ta_yuv_index] = data;
+ ta_yuv_index++;
+
+ if(ta_yuv_index == 0x180)
+ {
+ ta_yuv_index = 0;
+ for(int y=0;y<16;y++)
+ {
+ for(int x=0;x<16;x+=2)
+ {
+ int dst_addr;
+ int u,v,y0,y1;
+
+ dst_addr = ta_yuv_tex_base;
+ dst_addr+= (ta_yuv_x+x)*2;
+ dst_addr+= ((ta_yuv_y+y)*320*2);
+
+ u = yuv_fifo[0x00+(x>>1)+((y>>1)*8)];
+ v = yuv_fifo[0x40+(x>>1)+((y>>1)*8)];
+ y0 = yuv_fifo[0x80+((x&8) ? 0x40 : 0x00)+((y&8) ? 0x80 : 0x00)+(x&6)+((y&7)*8)];
+ y1 = yuv_fifo[0x80+((x&8) ? 0x40 : 0x00)+((y&8) ? 0x80 : 0x00)+(x&6)+((y&7)*8)+1];
+
+ *(UINT16 *)((reinterpret_cast<UINT8 *>(dc_texture_ram)) + WORD_XOR_LE(dst_addr)) = u;
+ *(UINT16 *)((reinterpret_cast<UINT8 *>(dc_texture_ram)) + WORD_XOR_LE(dst_addr+1)) = y0;
+ *(UINT16 *)((reinterpret_cast<UINT8 *>(dc_texture_ram)) + WORD_XOR_LE(dst_addr+2)) = v;
+ *(UINT16 *)((reinterpret_cast<UINT8 *>(dc_texture_ram)) + WORD_XOR_LE(dst_addr+3)) = y1;
+ }
+ }
+
+ ta_yuv_x+=16;
+ if(ta_yuv_x == ta_yuv_x_size)
+ {
+ ta_yuv_x = 0;
+ ta_yuv_y+=16;
+ if(ta_yuv_y == ta_yuv_y_size)
+ {
+ ta_yuv_y = 0;
+ /* TODO: timing */
+ irq_cb(EOXFER_YUV_IRQ);
+ }
+ }
+ }
}
// SB_LMMODE0
diff --git a/src/mame/video/powervr2.h b/src/mame/video/powervr2.h
index 6b91a649b6c..629dc9c6f06 100644
--- a/src/mame/video/powervr2.h
+++ b/src/mame/video/powervr2.h
@@ -249,7 +249,7 @@ public:
DECLARE_READ32_MEMBER( elan_regs_r );
DECLARE_WRITE32_MEMBER( elan_regs_w );
DECLARE_WRITE64_MEMBER( ta_fifo_poly_w );
- DECLARE_WRITE64_MEMBER( ta_fifo_yuv_w );
+ DECLARE_WRITE8_MEMBER( ta_fifo_yuv_w );
DECLARE_WRITE64_MEMBER( ta_texture_directpath0_w );
DECLARE_WRITE64_MEMBER( ta_texture_directpath1_w );
@@ -293,6 +293,10 @@ private:
UINT32 ta_ol_base, ta_ol_limit, ta_isp_base, ta_isp_limit;
UINT32 ta_next_opb, ta_itp_current, ta_alloc_ctrl, ta_next_opb_init;
UINT32 ta_yuv_tex_base, ta_yuv_tex_ctrl, ta_yuv_tex_cnt;
+ UINT32 ta_yuv_index;
+ int ta_yuv_x,ta_yuv_y;
+ int ta_yuv_x_size,ta_yuv_y_size;
+ UINT8 yuv_fifo[384];
// Other registers
UINT32 fog_table[0x80];
diff --git a/src/mess/drivers/dccons.c b/src/mess/drivers/dccons.c
index 9189592d858..d5de50b6aa6 100644
--- a/src/mess/drivers/dccons.c
+++ b/src/mess/drivers/dccons.c
@@ -387,11 +387,11 @@ static ADDRESS_MAP_START( dc_map, AS_PROGRAM, 64, dc_cons_state )
/* Area 4 */
AM_RANGE(0x10000000, 0x107fffff) AM_DEVWRITE("powervr2", powervr2_device, ta_fifo_poly_w)
- AM_RANGE(0x10800000, 0x10ffffff) AM_DEVWRITE("powervr2", powervr2_device, ta_fifo_yuv_w)
+ AM_RANGE(0x10800000, 0x10ffffff) AM_DEVWRITE8("powervr2", powervr2_device, ta_fifo_yuv_w, U64(0xffffffffffffffff))
AM_RANGE(0x11000000, 0x117fffff) AM_DEVWRITE("powervr2", powervr2_device, ta_texture_directpath0_w) AM_MIRROR(0x00800000) // access to texture / framebuffer memory (either 32-bit or 64-bit area depending on SB_LMMODE0 register - cannot be written directly, only through dma / store queue
AM_RANGE(0x12000000, 0x127fffff) AM_DEVWRITE("powervr2", powervr2_device, ta_fifo_poly_w)
- AM_RANGE(0x12800000, 0x12ffffff) AM_DEVWRITE("powervr2", powervr2_device, ta_fifo_yuv_w)
+ AM_RANGE(0x12800000, 0x12ffffff) AM_DEVWRITE8("powervr2", powervr2_device, ta_fifo_yuv_w, U64(0xffffffffffffffff))
AM_RANGE(0x13000000, 0x137fffff) AM_DEVWRITE("powervr2", powervr2_device, ta_texture_directpath1_w) AM_MIRROR(0x00800000) // access to texture / framebuffer memory (either 32-bit or 64-bit area depending on SB_LMMODE1 register - cannot be written directly, only through dma / store queue
AM_RANGE(0x8c000000, 0x8cffffff) AM_RAM AM_SHARE("dc_ram") // another RAM mirror