From 1bae8ae070826e3d731becc760fe855c5aa8a226 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Sat, 21 Nov 2009 18:37:59 +0000 Subject: [PATCH] hng64: Added preliminary hook-up for multi-byte chain mode for sprites, used by Buriki One and the two Samurai Shodown games [David Haywood, Angelo Salese] hng64: Fixed back plane color, thus giving characteristic blue background for POST screen [Angelo Salese] hng64: Improved Dual Port emulation, fixing the POST errors about it [Angelo Salese] --- src/mame/drivers/hng64.c | 52 ++++++++++++++++++------- src/mame/video/hng64.c | 84 +++++++++++++++++++++------------------- 2 files changed, 82 insertions(+), 54 deletions(-) diff --git a/src/mame/drivers/hng64.c b/src/mame/drivers/hng64.c index fb844e17827..0c555a9b3f6 100644 --- a/src/mame/drivers/hng64.c +++ b/src/mame/drivers/hng64.c @@ -454,6 +454,7 @@ or Fatal Fury for example). static int hng64_mcu_type = 0; static UINT32 fake_mcu_time; +static UINT16 hng_mcu_en; #define FIGHT_MCU 1 #define SHOOT_MCU 2 #define RACING_MCU 3 @@ -634,15 +635,15 @@ static READ32_HANDLER( hng64_sysregs_r ) mame_system_time systime; mame_get_base_datetime(space->machine, &systime); - //if(((offset*4) & 0xff00) == 0x2100) - // printf("HNG64 port read (PC=%08x) 0x%08x\n", cpu_get_pc(space->cpu),offset*4); +// if((offset*4) != 0x1084) +// printf("HNG64 port read (PC=%08x) 0x%08x\n", cpu_get_pc(space->cpu),offset*4); switch(offset*4) { case 0x001c: return mame_rand(space->machine); // hng64 hangs on start-up if zero. //case 0x106c: //case 0x107c: - case 0x1084: return 0x00000002; //??? + case 0x1084: return 0x00000002; //MCU->MIPS latch port //case 0x108c: case 0x1104: return hng64_interrupt_level_request; case 0x1254: return 0x00000000; //dma status, 0x800 @@ -709,15 +710,19 @@ static WRITE32_HANDLER( hng64_sysregs_w ) COMBINE_DATA (&hng64_sysregs[offset]); switch(offset*4) { - case 0x111c: /* irq ack */ break; + case 0x1084: //MIPS->MCU latch port + hng_mcu_en = (data & 0xff); //command-based, i.e. doesn't control halt line and such? + printf("HNG64 writing to SYSTEM Registers 0x%08x == 0x%08x. (PC=%08x)\n", offset*4, hng64_sysregs[offset], cpu_get_pc(space->cpu)); + break; + case 0x111c: /*irq ack */ break; case 0x1204: hng_dma_start = hng64_sysregs[offset]; break; case 0x1214: hng_dma_dst = hng64_sysregs[offset]; break; case 0x1224: hng_dma_len = hng64_sysregs[offset]; hng64_do_dma(space); break; - default: - logerror("HNG64 writing to SYSTEM Registers 0x%08x == 0x%08x. (PC=%08x)\n", offset*4, hng64_sysregs[offset], cpu_get_pc(space->cpu)); + //default: + //printf("HNG64 writing to SYSTEM Registers 0x%08x == 0x%08x. (PC=%08x)\n", offset*4, hng64_sysregs[offset], cpu_get_pc(space->cpu)); } } @@ -745,7 +750,9 @@ static READ32_HANDLER( fight_io_r ) case 0x000: return 0x00000400; case 0x004: return input_port_read(space->machine, "SYSTEM"); case 0x008: return input_port_read(space->machine, "P1_P2"); - case 0x600: return no_machine_error_code; + case 0x600: + printf("%04x\n",hng_mcu_en); + return no_machine_error_code; } return hng64_dualport[offset]; @@ -787,10 +794,13 @@ static READ32_HANDLER( shoot_io_r ) { case 0x000: { - if(cpu_get_pc(space->cpu) == 0x8000e040 || cpu_get_pc(space->cpu) == 0x80012fc0) //i/o init 1 + if(fake_mcu_time < 0x100)//i/o init + { + fake_mcu_time++; return 0x400; - - return 0; + } + else + return 0x000; } case 0x010: return input_port_read(space->machine, "D_IN"); case 0x018: @@ -833,7 +843,20 @@ static READ32_HANDLER( racing_io_r ) static READ32_HANDLER( hng64_dualport_r ) { - printf("dualport R %08x %08x (PC=%08x)\n", offset*4, hng64_dualport[offset], cpu_get_pc(space->cpu)); +// printf("dualport R %08x %08x (PC=%08x)\n", offset*4, hng64_dualport[offset], cpu_get_pc(space->cpu)); + + /* + command table: + 0x0b = ? mode input polling (sams64, bbust2, sams64_2 & roadedge) (*) + 0x0c = cut down connections, treats the dualport to be normal RAM + 0x11 = ? mode input polling (fatfurwa, xrally, buriki) (*) + 0x20 = asks for MCU machine code + + (*) 0x11 is followed by 0x0b if the latter is used, JVS-esque indirect/direct mode? + */ + + if(hng_mcu_en == 0x0c) + return hng64_dualport[offset]; switch(hng64_mcu_type) { @@ -843,12 +866,12 @@ static READ32_HANDLER( hng64_dualport_r ) case SAMSHO_MCU: return samsho_io_r(space, offset,0xffffffff); } - return mame_rand(space->machine)&0xffffffff; + return hng64_dualport[offset]; } static WRITE32_HANDLER( hng64_dualport_w ) { - printf("dualport WRITE %08x %08x (PC=%08x)\n", offset*4, hng64_dualport[offset], cpu_get_pc(space->cpu)); +// printf("dualport WRITE %08x %08x (PC=%08x)\n", offset*4, hng64_dualport[offset], cpu_get_pc(space->cpu)); COMBINE_DATA (&hng64_dualport[offset]); } @@ -1733,13 +1756,12 @@ static MACHINE_RESET(hyperneo) cputag_set_input_line(machine, "comm", INPUT_LINE_RESET, PULSE_LINE); // reset the CPU and let 'er rip // cputag_set_input_line(machine, "comm", INPUT_LINE_HALT, ASSERT_LINE); // hold on there pardner... - - // "Display List" init - ugly activeBuffer = 0 ; /* For simulate MCU stepping */ fake_mcu_time = 0; + hng_mcu_en = 0; } static PALETTE_INIT( hng64 ) diff --git a/src/mame/video/hng64.c b/src/mame/video/hng64.c index 3299d0b3a45..8a409927f92 100644 --- a/src/mame/video/hng64.c +++ b/src/mame/video/hng64.c @@ -51,24 +51,14 @@ static struct polygon *polys ; * * UINT32 | Bytes | Use * -------+-76543210-+---------------- - * 0 | xxxx---- | y position - * 0 | ----xxxx | x position - * 1 | xxxx---- | y zoom - * 1 | ----xxxx | x zoom - * 2 | ------x- | x chain - * 2 | -------x | y chain - * 2 | xxxx---- | end of sprite list - though it surely contains more info ! - * 2 | ----oo-- | not used ?? - * 3 | --xx---- | palette entry - * 3 | --x----- | (bit 0x8) - maybe a graphics bank selector - * 3 | oo--oooo | not used ? - * 4 | --xxxxxx | tile number - * 4 | --x----- | (bit 0x2) - x flip - * 4 | --x----- | (bit 0x1) - y flip - * 4 | oo------ | not used ?? - * 5 | oooooooo | not used ?? - * 6 | oooooooo | not used ?? - * 7 | oooooooo | not used ?? + * 0 | yyyy yyyy yyyy yyyy xxxx xxxx xxxx xxxx | x/y position + * 1 | YYYY YYYY YYYY YYYY XXXX XXXX XXXX XXXX | x/y zoom + * 2 | ???? ???? ???? ???? ---- ---I cccc CCCC | unknown, 'Inline' chain flag, x/y chain + * 3 | ---- ---- bppp pppp ---- ---- ---- ---- | bpp select, palette entry + * 4 | ---- --fF ???? tttt tttt tttt tttt tttt | flip bits, unknown, tile number + * 5 | ---- ---- ---- ---- ---- ---- ---- ---- | not used ?? + * 6 | ---- ---- ---- ---- ---- ---- ---- ---- | not used ?? + * 7 | ---- ---- ---- ---- ---- ---- ---- ---- | not used ?? */ /* xxxx---- | I think this part of UINT32 2 is interesting as more than just a list end marker (AJG) @@ -80,37 +70,25 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta UINT32 *source = hng64_spriteram; UINT32 *finish = hng64_spriteram + 0xb000/4; - /* find end of list? */ - while( source>16; - if (endlist == 0x07ff) break; - source+=8; - } - // for (int iii = 0; iii < 0x0f; iii++) // mame_printf_debug("%.8x ", hng64_videoregs[iii]) ; // mame_printf_debug("\n") ; - finish = hng64_spriteram; - - /* draw backwards .. */ - while( source>finish ) + while( source>16; xpos = (source[0]&0x0000ffff)>>0; - tileno=(source[4]&0x00ffffff); + tileno=(source[4]&0x0007ffff); chainx=(source[2]&0x000000f0)>>4; chainy=(source[2]&0x0000000f); + chaini=(source[2]&0x00000100); zoomy = (source[1]&0xffff0000)>>16; zoomx = (source[1]&0x0000ffff)>>0; @@ -199,10 +177,38 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { for(xdrw=0;xdrw<=chainx;xdrw++) { - drawgfxzoom_transpen(bitmap,cliprect,gfx,tileno,pal,xflip,yflip,xpos+(xinc*xdrw),ypos+(yinc*ydrw),zoomx,zoomy/*0x10000*/,0); - tileno++; + if (!chaini) + { + pdrawgfxzoom_transpen(bitmap,cliprect,gfx,tileno,pal,xflip,yflip,xpos+(xinc*xdrw),ypos+(yinc*ydrw),zoomx,zoomy/*0x10000*/,machine->priority_bitmap, 0,0); + tileno++; + } + else // inline chain mode, used by ss64 + { + tileno=(source[4]&0x0007ffff); + pal =(source[3]&0x00ff0000)>>16; + //xflip=(source[4]&0x02000000)>>25; + //yflip=(source[4]&0x01000000)>>24; + + if (source[3]&0x00800000) + { + gfx= machine->gfx[4]; + } + else + { + gfx= machine->gfx[5]; + tileno>>=1; + } + + pdrawgfxzoom_transpen(bitmap,cliprect,gfx,tileno,pal,xflip,yflip,xpos+(xinc*xdrw),ypos+(yinc*ydrw),zoomx,zoomy/*0x10000*/,machine->priority_bitmap, 0,0); + source +=8; + + } + } } + + + if (!chaini) source +=8; } } @@ -1124,7 +1130,8 @@ static void hng64_drawtilemap( bitmap_t *bitmap, const rectangle *cliprect, int VIDEO_UPDATE( hng64 ) { - bitmap_fill(bitmap, 0, get_black_pen(screen->machine)); + bitmap_fill(bitmap, 0, screen->machine->pens[0]); //<- user selectable pen too? + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0x00); // the tilemap auto animation and moveable tilebases means that they end up // dirty most frames anyway, even with manual tracking @@ -1146,7 +1153,6 @@ VIDEO_UPDATE( hng64 ) transition_control(bitmap, cliprect) ; - /* popmessage("%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x", hng64_videoregs[0x00], hng64_videoregs[0x01], @@ -1163,7 +1169,7 @@ VIDEO_UPDATE( hng64 ) hng64_videoregs[0x0c], hng64_videoregs[0x0d], hng64_videoregs[0x0e]); - */ + // tilemap0 per layer flags // 0840 - startup tests, 8x8x4 layer