further code reorg, this seems to upset some of the fb logging, find out why.

This commit is contained in:
David Haywood 2013-02-22 14:38:01 +00:00
parent 563a6a6f95
commit fd8ac8ba2f

View File

@ -445,7 +445,12 @@ public:
DECLARE_WRITE32_MEMBER(sysh1_sound_dma_w);
DECLARE_READ32_MEMBER(sysh1_ioga_r);
DECLARE_WRITE32_MEMBER(sysh1_ioga_w);
DECLARE_WRITE32_MEMBER(sysh1_txt_blit_w);
DECLARE_WRITE32_MEMBER(sysh1_unk_blit_w);
DECLARE_WRITE32_MEMBER(sysh1_blit_mode_w);
DECLARE_WRITE32_MEMBER(sysh1_blit_data_w);
DECLARE_WRITE32_MEMBER(sysh1_fb_mode_w);
DECLARE_WRITE32_MEMBER(sysh1_fb_data_w);
DECLARE_WRITE32_MEMBER(sysh1_pal_w);
DECLARE_WRITE32_MEMBER(sysh1_dma_w);
DECLARE_WRITE32_MEMBER(sysh1_char_w);
@ -467,6 +472,7 @@ public:
UINT32 screen_update_coolridr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which);
UINT32 screen_update_coolridr1(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
UINT32 screen_update_coolridr2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
void blit_current_sprite(address_space &space);
INTERRUPT_GEN_MEMBER(system_h1);
TIMER_DEVICE_CALLBACK_MEMBER(system_h1_main);
TIMER_DEVICE_CALLBACK_MEMBER(system_h1_sub);
@ -607,171 +613,11 @@ WRITE32_MEMBER(coolridr_state::sysh1_ioga_w)
}
#endif
/*
if(type == 4)
*/
/* This is a RLE-based sprite blitter (US Patent #6,141,122), very unusual from Sega... */
WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
void coolridr_state::blit_current_sprite(address_space &space)
{
COMBINE_DATA(&m_sysh1_txt_blit[offset]);
const pen_t *clut = &machine().pens[0];
switch(offset)
{
/*
This does the fb display/clear phases of blitter data processed in the previous frame.
And yes, game effectively runs at 30 Hz (because data processing happens on even frames, actual display transfer happens on odd frames).
screen 1
8c200000 06
00000001 07
0000017f 07 Y range (upper start, lower end)
000701f7 07 X range (upper start, lower end)
00000007 07 enable?
screen 2
8c800000 06
00000001 07
0000017f 07
020703f7 07
00000207 07 enable plus clear?
*/
case 0x06:
m_blitterClearMode = m_sysh1_txt_blit[offset];
if(m_blitterClearMode != 0x8c200000 && m_blitterClearMode != 0x8c800000)
printf("Blitter Clear used with param %08x\n",m_blitterClearMode);
m_blitterClearCount = 0;
break;
case 0x07:
if(m_blitterClearCount == 0)
{
if(m_sysh1_txt_blit[offset] != 1)
printf("Blitter Clear Count == 0 used with param %08x\n",m_sysh1_txt_blit[offset]);
}
else if(m_blitterClearCount == 1)
{
if(m_sysh1_txt_blit[offset] != 0x17f)
printf("Blitter Clear Count == 1 used with param %08x\n",m_sysh1_txt_blit[offset]);
}
else if(m_blitterClearCount == 2)
{
if(m_sysh1_txt_blit[offset] != 0x000701f7 && m_sysh1_txt_blit[offset] != 0x020703f7)
printf("Blitter Clear Count == 2 used with param %08x\n",m_sysh1_txt_blit[offset]);
}
else if(m_blitterClearCount == 3)
{
if(m_sysh1_txt_blit[offset] != 0x00000007 && m_sysh1_txt_blit[offset] != 0x00000207)
printf("Blitter Clear Count == 3 used with param %08x\n",m_sysh1_txt_blit[offset]);
{
const rectangle& visarea = machine().primary_screen->visible_area();
if(m_blitterClearMode == 0x8c200000)
{
copybitmap(m_screen1_bitmap, m_temp_bitmap_sprites, 0, 0, 0, 0, visarea);
m_temp_bitmap_sprites.fill(0, visarea);
}
if(m_blitterClearMode == 0x8c800000)
{
copybitmap(m_screen2_bitmap, m_temp_bitmap_sprites2, 0, 0, 0, 0, visarea);
m_temp_bitmap_sprites2.fill(0, visarea);
}
}
}
else
{
printf("Blitter Clear Count == %02x used with param %08x\n",m_blitterClearCount,m_sysh1_txt_blit[offset]);
}
m_blitterClearCount++;
break;
// The mode register
case 0x04:
{
m_blitterMode = (data & 0x00ff0000) >> 16;
if (m_blitterMode == 0xf4)
{
// Some sort of addressing state.
// In the case of text, simply writes 4 characters per 32-bit word.
// These values may be loaded into RAM somewhere as they are written.
// The number of characters is determined by the upper-most 8 bits.
m_textBytesToWrite = (data & 0xff000000) >> 24;
m_textOffset = (data & 0x0000ffff);
m_blitterSerialCount = 0;
// this is ONLY used when there is text on the screen
//printf("set mode %08x\n", data);
}
else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
|| m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
{
// The blitter function(s).
// After this is set a fixed count of 11 32-bit words are sent to the data register.
// The lower word always seems to be 0x0001 and the upper byte always 0xac.
m_blitterSerialCount = 0;
// form 0xacMM-xxx ac = fixed value for this mode? MM = modes above. -xxx = some kind of offset? but it doesn't increment for each blit like the textOffset / paletteOffset stuff, investigate
}
else if (m_blitterMode == 0x10)
{
// Could be a full clear of VRAM?
for(UINT32 vramAddr = 0x3f40000; vramAddr < 0x3f4ffff; vramAddr+=4)
space.write_dword(vramAddr, 0x00000000);
m_blitterSerialCount = 0;
}
else if (m_blitterMode == 0xe0)
{
// uploads palettes...
// does NOT upload the palette for the WDUD screen when set to US mode this way..
m_blitterSerialCount = 0;
m_textOffset = (data & 0x0000ffff)>>2; // it's a byte offset
// printf("set e0 %08x\n", data);
}
else
{
printf("set unknown blit mode %02x\n", m_blitterMode);
}
break;
}
// The data register
case 0x05:
{
if (m_blitterMode == 0xf4)
{
// Uploads a series of bytes that index into the encoded sprite table
const size_t memOffset = 0x03f40000 + m_textOffset + m_blitterSerialCount;
space.write_dword(memOffset, data);
m_blitterSerialCount += 0x04;
// DEBUG: Uncomment to see the ASCII strings as they are being blitted
//if (m_blitterSerialCount >= m_textBytesToWrite)
//{
// for (int i = 0; i < m_textBytesToWrite+1; i++)
// printf("%c", read_byte(0x03f40000 + m_textOffset + i));
// printf("\n");
//}
}
else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
|| m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
{
// Serialized 32-bit words in order of appearance:
// 0: 00000000 - unknown, 0x00000000 or 0x00000001, 0 seems to be regular sprite, 1 seems to change meaning of below, possible clip area?
// 1: 00010000 - unknown, color mode? (7bpp select?) set on player bike object
@ -792,23 +638,9 @@ WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
// 9: xxxx---- - "Display Vertical Position"
// 9: ----yyyy - "Display Horizontal Position"
// 10: 00000000 - unknown : always seems to be zero - NO, for some things (not text) it's also a reference to 3f40000 region like #11
// 11: ........ - complex - likely an address into bytes uploaded by mode 0xf4 (likely, it's only used when text is present otherwise it's always 0, some indirect tile mode I guess)
// (See ifdef'ed out code below for a closer examination)
// 11: ........ - indirect tile mode ram address (used for text)
// Serialized counts
if (m_blitterSerialCount < 12)
{
m_spriteblit[m_blitterSerialCount] = data;
m_blitterSerialCount++;
}
else
{
printf("more than 11 dwords (%d) in blit?\n", m_blitterSerialCount);
}
// use the 11th blit write also as the trigger
if (m_blitterSerialCount == 12)
{
// first parse the bits
/************* m_spriteblit[0] *************/
@ -935,18 +767,6 @@ WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
UINT32 textlookup = m_spriteblit[11];
/* DRAW */
if (blit0 & 1)
{
// NOT A SPRITE
// these are something else, not sprites? It still writes 11 dwords I think they have a different meaning
// it might be a clipping area set? looks potentially like co-ordinates at least
//printf("non sprite: ");
//PRINT_BLIT_STUFF
}
else
{
UINT16 used_hCellCount = hCellCount;
UINT16 used_vCellCount = vCellCount;
UINT16 used_flipx = blit_flipx;
@ -968,8 +788,6 @@ WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
// we also use this to trigger the actual draw operation
//if (blit10!=0)
if (indirect_zoom_enable)
{
// with this bit enabled blit10 is a look up to the zoom(?) value eg. 03f42600
@ -1334,14 +1152,92 @@ WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
}
}
}
}
}
}
WRITE32_MEMBER(coolridr_state::sysh1_blit_mode_w)
{
m_blitterMode = (data & 0x00ff0000) >> 16;
if (m_blitterMode == 0xf4)
{
// Some sort of addressing state.
// In the case of text, simply writes 4 characters per 32-bit word.
// These values may be loaded into RAM somewhere as they are written.
// The number of characters is determined by the upper-most 8 bits.
m_textBytesToWrite = (data & 0xff000000) >> 24;
m_textOffset = (data & 0x0000ffff);
m_blitterSerialCount = 0;
// this is ONLY used when there is text on the screen
//printf("set mode %08x\n", data);
}
}
else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
|| m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
{
// The blitter function(s).
// After this is set a fixed count of 11 32-bit words are sent to the data register.
// The lower word always seems to be 0x0001 and the upper byte always 0xac.
m_blitterSerialCount = 0;
//printf("\n");
// form 0xacMM-xxx ac = fixed value for this mode? MM = modes above. -xxx = some kind of offset? but it doesn't increment for each blit like the textOffset / paletteOffset stuff, investigate
}
else if (m_blitterMode == 0x10)
{
// Could be a full clear of VRAM?
for(UINT32 vramAddr = 0x3f40000; vramAddr < 0x3f4ffff; vramAddr+=4)
space.write_dword(vramAddr, 0x00000000);
m_blitterSerialCount = 0;
}
else if (m_blitterMode == 0xe0)
{
// uploads palettes...
// does NOT upload the palette for the WDUD screen when set to US mode this way..
m_blitterSerialCount = 0;
m_textOffset = (data & 0x0000ffff);
// printf("set e0 %08x\n", data);
}
else
{
printf("set unknown blit mode %02x\n", m_blitterMode);
}
}
WRITE32_MEMBER(coolridr_state::sysh1_blit_data_w)
{
if (m_blitterMode == 0xf4)
{
// Uploads a series of bytes that index into the encoded sprite table
const size_t memOffset = 0x03f40000 + m_textOffset + m_blitterSerialCount;
space.write_dword(memOffset, data);
m_blitterSerialCount += 0x04;
}
else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
|| m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
{
// Serialized counts
if (m_blitterSerialCount < 12)
{
m_spriteblit[m_blitterSerialCount] = data;
m_blitterSerialCount++;
}
else
{
printf("more than 11 dwords (%d) in blit?\n", m_blitterSerialCount);
}
// use the 11th blit write also as the trigger
if (m_blitterSerialCount == 12)
{
blit_current_sprite(space);
}
}
@ -1357,16 +1253,108 @@ WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
// is this the only way for the tile colours to be actually used, or does this just go to memory somewhere too?
//printf("blit mode %02x %02x %08x\n", m_blitterMode, m_blitterSerialCount, data);
sysh1_pal_w(space,m_textOffset,data,0xffffffff);
m_textOffset++;
// maybe should write to a different address, see dma hack in other code
const size_t memOffset = 0x3c00000 + m_textOffset + m_blitterSerialCount;
space.write_dword(memOffset, data);
m_blitterSerialCount += 0x04;
}
else
{
logerror("unk blit mode %02x\n", m_blitterMode);
}
break;
}
WRITE32_MEMBER(coolridr_state::sysh1_fb_mode_w)
{
/*
This does the fb display/clear phases of blitter data processed in the previous frame.
And yes, game effectively runs at 30 Hz (because data processing happens on even frames, actual display transfer happens on odd frames).
screen 1
8c200000 06
00000001 07
0000017f 07 Y range (upper start, lower end)
000701f7 07 X range (upper start, lower end)
00000007 07 enable?
screen 2
8c800000 06
00000001 07
0000017f 07
020703f7 07
00000207 07 enable plus clear?
*/
COMBINE_DATA(&m_blitterClearMode);
/*
if(m_blitterClearMode != 0x8c200000 && m_blitterClearMode != 0x8c800000)
printf("Blitter Clear used with param %08x\n",m_blitterClearMode);
*/
m_blitterClearCount = 0;
}
WRITE32_MEMBER(coolridr_state::sysh1_fb_data_w)
{
if(m_blitterClearCount == 0)
{
if(data != 1)
printf("Blitter Clear Count == 0 used with param %08x\n",data);
}
else if(m_blitterClearCount == 1)
{
if(data != 0x17f)
printf("Blitter Clear Count == 1 used with param %08x\n",data);
}
else if(m_blitterClearCount == 2)
{
/*
if(data != 0x000701f7 && m_sysh1_txt_blit[offset] != 0x020703f7)
printf("Blitter Clear Count == 2 used with param %08x\n",data);
*/
}
else if(m_blitterClearCount == 3)
{
if(data != 0x00000007 && data != 0x00000207)
printf("Blitter Clear Count == 3 used with param %08x\n",data);
{
const rectangle& visarea = machine().primary_screen->visible_area();
if(m_blitterClearMode == 0x8c200000)
{
copybitmap(m_screen1_bitmap, m_temp_bitmap_sprites, 0, 0, 0, 0, visarea);
m_temp_bitmap_sprites.fill(0, visarea);
}
if(m_blitterClearMode == 0x8c800000)
{
copybitmap(m_screen2_bitmap, m_temp_bitmap_sprites2, 0, 0, 0, 0, visarea);
m_temp_bitmap_sprites2.fill(0, visarea);
}
}
}
else
{
printf("Blitter Clear Count == %02x used with param %08x\n",m_blitterClearCount,m_sysh1_txt_blit[offset]);
}
m_blitterClearCount++;
}
WRITE32_MEMBER(coolridr_state::sysh1_unk_blit_w)
{
COMBINE_DATA(&m_sysh1_txt_blit[offset]);
switch(offset)
{
default:
{
printf("sysh1_unk_blit_w unhandled offset %04x %08x %08x\n", offset, data, mem_mask);
}
}
}
@ -1475,6 +1463,7 @@ WRITE32_MEMBER(coolridr_state::sysh1_dma_w)
{
COMBINE_DATA(&m_framebuffer_vram[offset]);
// is this real, or just work ram for the actual blitter?
if(offset*4 == 0x000)
{
if((m_framebuffer_vram[offset] & 0xff00000) == 0xfe00000)
@ -1509,7 +1498,17 @@ static ADDRESS_MAP_START( system_h1_map, AS_PROGRAM, 32, coolridr_state )
AM_RANGE(0x03f00000, 0x03f0ffff) AM_RAM AM_SHARE("share3") /*Communication area RAM*/
AM_RANGE(0x03f40000, 0x03f4ffff) AM_RAM AM_SHARE("txt_vram")//text tilemap + "lineram"
AM_RANGE(0x04000000, 0x0400003f) AM_RAM_WRITE(sysh1_txt_blit_w) AM_SHARE("sysh1_txt_blit")
AM_RANGE(0x04000000, 0x0400000f) AM_RAM_WRITE(sysh1_unk_blit_w) AM_SHARE("sysh1_txt_blit")
AM_RANGE(0x04000010, 0x04000013) AM_WRITE(sysh1_blit_mode_w)
AM_RANGE(0x04000014, 0x04000017) AM_WRITE(sysh1_blit_data_w)
AM_RANGE(0x04000018, 0x0400001b) AM_WRITE(sysh1_fb_mode_w)
AM_RANGE(0x0400001c, 0x0400001f) AM_WRITE(sysh1_fb_data_w)
AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_SHARE("sysh1_workrah")
AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share1")