From 598cebb186bdc1a90d791e33617cadc08ed1e475 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Fri, 22 Apr 2011 23:24:57 +0000 Subject: [PATCH] Hooked up NB1414M4 priority bit, fixing video text priority in all the games in the Armed F driver [Angelo Salese] --- src/mame/drivers/armedf.c | 44 +++++++++-------------- src/mame/machine/armedf.c | 18 +++++++--- src/mame/video/armedf.c | 75 ++++++--------------------------------- 3 files changed, 41 insertions(+), 96 deletions(-) diff --git a/src/mame/drivers/armedf.c b/src/mame/drivers/armedf.c index 1a136d987d3..b66cd4153c5 100644 --- a/src/mame/drivers/armedf.c +++ b/src/mame/drivers/armedf.c @@ -21,12 +21,8 @@ actually bootlegs. 68000 + Z80 TODO: -- simulate the mcu/blitter (particularly needed in terrafu and legion) - -- or figure out which chip it is, decap it, and emulate it. +- identify and decap the NB1414M4 chip, it could be either a MCU or a fancy blitter chip; - time over doesn't kill the player in Kozure Ookami; -- intro in Terra Force isn't right, the square panels should be cleared after every - animation is played, almost likely to not be protection related; -- priorities, especially with the text layer (Terra Force); - sprites use a RAM clut for colors, used for color cycling effects. Examples are: - "2" logo in Crazy Climber 2 title screen; - ship rays on Armed F title screen; @@ -197,18 +193,8 @@ static WRITE16_HANDLER( terraf_io_w ) armedf_state *state = space->machine().driver_data(); if(data & 0x4000 && ((state->m_vreg & 0x4000) == 0)) //0 -> 1 transition - { - /* latch fg scroll values */ - state->m_fg_scrollx = (state->m_text_videoram[0x0d] & 0xff) | ((state->m_text_videoram[0x0e] & 0x3) << 8); - state->m_fg_scrolly = (state->m_text_videoram[0x0b] & 0xff) | ((state->m_text_videoram[0x0c] & 0x3) << 8); - - /* process the command */ nb_1414m4_exec(space,(state->m_text_videoram[0] << 8) | (state->m_text_videoram[1] & 0xff)); - /* mark tiles dirty */ - tilemap_mark_all_tiles_dirty(state->m_tx_tilemap); - } - COMBINE_DATA(&state->m_vreg); coin_counter_w(space->machine(), 0, (data & 1) >> 0); @@ -236,8 +222,10 @@ static WRITE16_HANDLER( bootleg_io_w ) { armedf_state *state = space->machine().driver_data(); - //if(data & 0x4000 && ((state->m_vreg & 0x4000) == 0)) //0 -> 1 transition - // cputag_set_input_line(space->machine(), "extra", 0, HOLD_LINE); + if(data & 0x4000 && ((state->m_vreg & 0x4000) == 0)) //0 -> 1 transition + { + // NOP + } COMBINE_DATA(&state->m_vreg); @@ -1631,14 +1619,14 @@ static DRIVER_INIT( cclimbr2 ) *************************************/ /* YEAR, NAME, PARENT, MACHINE, INPUT, INIT, MONITOR, COMPANY, FULLNAME, FLAGS */ -GAME( 1987, legion, 0, legion, legion, legion, ROT270, "Nichibutsu", "Legion - Spinner-87 (World ver 2.03)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_COLORS ) -GAME( 1987, legiono, legion, legiono, legion, legiono, ROT270, "Nichibutsu", "Chouji Meikyuu Legion (Japan bootleg ver 1.05)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_COLORS ) /* bootleg? */ -GAME( 1987, terraf, 0, terraf, terraf, terraf, ROT0, "bootleg", "Terra Force (bootleg)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_COLORS ) //world bootleg? -GAME( 1987, terrafb, terraf, terrafb, terraf, terrafb, ROT0, "bootleg", "Terra Force (Japan bootleg with additional Z80)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_COLORS) -GAME( 1987, terrafu, terraf, terraf, terraf, terrafu, ROT0, "Nichibutsu USA", "Terra Force (US set 1)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_COLORS ) -GAME( 1987, terrafa, terraf, terraf, terraf, terrafu, ROT0, "Nichibutsu USA", "Terra Force (US set 2)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_COLORS ) //world? -GAME( 1987, kozure, 0, kozure, kozure, kozure, ROT0, "Nichibutsu", "Kozure Ookami (Japan)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1988, cclimbr2, 0, cclimbr2, cclimbr2, cclimbr2, ROT0, "Nichibutsu", "Crazy Climber 2 (Japan)", GAME_SUPPORTS_SAVE| GAME_IMPERFECT_COLORS ) -GAME( 1988, cclimbr2a,cclimbr2, cclimbr2, cclimbr2, cclimbr2, ROT0, "Nichibutsu", "Crazy Climber 2 (Japan, Harder)", GAME_SUPPORTS_SAVE| GAME_IMPERFECT_COLORS ) -GAME( 1988, armedf, 0, armedf, armedf, armedf, ROT270, "Nichibutsu", "Armed Formation", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_COLORS ) -GAME( 1988, armedff, armedf, armedf, armedf, armedf, ROT270, "Nichibutsu (Fillmore license)", "Armed Formation (Fillmore license)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_COLORS ) +GAME( 1987, legion, 0, legion, legion, legion, ROT270, "Nichibutsu", "Legion - Spinner-87 (World ver 2.03)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) +GAME( 1987, legiono, legion, legiono, legion, legiono, ROT270, "Nichibutsu", "Chouji Meikyuu Legion (Japan bootleg ver 1.05)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) /* bootleg? */ +GAME( 1987, terraf, 0, terraf, terraf, terraf, ROT0, "bootleg", "Terra Force (bootleg)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) //world bootleg? +GAME( 1987, terrafb, terraf, terrafb, terraf, terrafb, ROT0, "bootleg", "Terra Force (Japan bootleg with additional Z80)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) +GAME( 1987, terrafu, terraf, terraf, terraf, terrafu, ROT0, "Nichibutsu USA", "Terra Force (US set 1)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) +GAME( 1987, terrafa, terraf, terraf, terraf, terrafu, ROT0, "Nichibutsu USA", "Terra Force (US set 2)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) //world? +GAME( 1987, kozure, 0, kozure, kozure, kozure, ROT0, "Nichibutsu", "Kozure Ookami (Japan)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) +GAME( 1988, cclimbr2, 0, cclimbr2, cclimbr2, cclimbr2, ROT0, "Nichibutsu", "Crazy Climber 2 (Japan)", GAME_SUPPORTS_SAVE| GAME_IMPERFECT_GRAPHICS ) +GAME( 1988, cclimbr2a,cclimbr2, cclimbr2, cclimbr2, cclimbr2, ROT0, "Nichibutsu", "Crazy Climber 2 (Japan, Harder)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) +GAME( 1988, armedf, 0, armedf, armedf, armedf, ROT270, "Nichibutsu", "Armed Formation", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) +GAME( 1988, armedff, armedf, armedf, armedf, armedf, ROT270, "Nichibutsu (Fillmore license)", "Armed Formation (Fillmore license)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS ) diff --git a/src/mame/machine/armedf.c b/src/mame/machine/armedf.c index 8e1b313704b..25f4e2e4be3 100644 --- a/src/mame/machine/armedf.c +++ b/src/mame/machine/armedf.c @@ -8,11 +8,11 @@ This is some fancy MCU / blitter that copies text strings in various Nihon Bussa TODO: - Device-ify this; -- merge implementations - where is the condition that makes "insert coin" text to properly blink? - first byte meaning is completely unknown; - Kozure Ookami "credit X" message during attract mode completely clears the status bar, dunno how it's supposed to be displayed; +- (after device-ifization) hook this up for Ninja Emaki; Notes: - Just before any string in the "MCU" rom, there's a control byte, this meaning is as follows: @@ -37,10 +37,10 @@ static void nichibutsu_1414m4_dma(address_space *space,UINT16 src,UINT16 dst,UIN for(i=0;im_text_videoram[i+dst+0x000] = (condition) ? (data[i+(0)+src] & 0xff) : 0x00; + state->m_text_videoram[i+dst+0x000] = (condition) ? (data[i+(0)+src] & 0xff) : data[0x320]; state->m_text_videoram[i+dst+0x400] = data[i+(size)+src] & 0xff; } } @@ -52,7 +52,7 @@ static void nichibutsu_1414m4_fill(address_space *space,UINT16 dst,UINT8 tile,UI for(i=0;i<0x400;i++) { - if(i+dst+0x000 < 18) + if(i+dst+0x000 < 18) //avoid param overwrite continue; state->m_text_videoram[i+dst+0x000] = tile; @@ -276,6 +276,13 @@ static void nichibutsu_1414m4_0e00(address_space *space,UINT16 mcu_cmd) void nb_1414m4_exec(address_space *space,UINT16 mcu_cmd) { + armedf_state *state = space->machine().driver_data(); + + /* latch fg scroll values */ + state->m_fg_scrollx = (state->m_text_videoram[0x0d] & 0xff) | ((state->m_text_videoram[0x0e] & 0x3) << 8); + state->m_fg_scrolly = (state->m_text_videoram[0x0b] & 0xff) | ((state->m_text_videoram[0x0c] & 0x3) << 8); + + /* process the command */ switch(mcu_cmd & 0xff00) { /* title screen / continue screens */ @@ -293,4 +300,7 @@ void nb_1414m4_exec(address_space *space,UINT16 mcu_cmd) popmessage("NB 1414M4 executes %04x command, contact MAMEdev\n",mcu_cmd); break; } + + /* mark tiles dirty */ + tilemap_mark_all_tiles_dirty(state->m_tx_tilemap); } diff --git a/src/mame/video/armedf.c b/src/mame/video/armedf.c index 4d04b538839..5c992a667c1 100644 --- a/src/mame/video/armedf.c +++ b/src/mame/video/armedf.c @@ -37,37 +37,20 @@ static TILE_GET_INFO( get_tx_tile_info ) int tile_number = state->m_text_videoram[tile_index] & 0xff; int attributes; + /* TODO: Armed F doesn't seem to use the NB1414M4! */ if (state->m_scroll_type == 1) attributes = state->m_text_videoram[tile_index + 0x800] & 0xff; else + { attributes = state->m_text_videoram[tile_index + 0x400] & 0xff; - SET_TILE_INFO( - 0, - tile_number + 256 * (attributes & 0x3), - attributes >> 4, - 0); -} - -static TILE_GET_INFO( get_legion_tx_tile_info ) -{ - armedf_state *state = machine.driver_data(); - - int tile_number = state->m_text_videoram[tile_index] & 0xff; - - if(tile_index<0x10) tile_number=0x20; - - int attributes; - - attributes = state->m_text_videoram[tile_index + 0x400] & 0xff; - - tileinfo->category = 0; - - if((attributes & 0x3) == 3) - { - tileinfo->category = 1; + if(tile_index < 0x12) /* don't draw the NB1414M4 params! TODO: could be a better fix */ + tile_number = attributes = 0x00; } + /* bit 3 controls priority, (0) nb1414m4 has priority over all the other video layers */ + tileinfo->category = (attributes & 0x8) >> 3; + SET_TILE_INFO( 0, tile_number + 256 * (attributes & 0x3), @@ -123,7 +106,7 @@ VIDEO_START( armedf ) break; case 2: /* legion */ - state->m_tx_tilemap = tilemap_create(machine, get_legion_tx_tile_info, armedf_scan_type3, 8, 8, 64, 32); + state->m_tx_tilemap = tilemap_create(machine, get_tx_tile_info, armedf_scan_type3, 8, 8, 64, 32); break; default: @@ -153,16 +136,6 @@ WRITE16_HANDLER( armedf_text_videoram_w ) tilemap_mark_tile_dirty(state->m_tx_tilemap, offset & 0x7ff); else tilemap_mark_tile_dirty(state->m_tx_tilemap, offset & 0xbff); -/* - if (offset < 0x10) - logerror("%04x %04x %04x %04x %04x %04x %04x %04x-%04x %04x %04x %04x %04x %04x %04x %04x (%04x)\n", - state->m_text_videoram[0], state->m_text_videoram[1], state->m_text_videoram[2], - state->m_text_videoram[3], state->m_text_videoram[4], state->m_text_videoram[5], - state->m_text_videoram[6], state->m_text_videoram[7], state->m_text_videoram[8], - state->m_text_videoram[9], state->m_text_videoram[10], state->m_text_videoram[11], - state->m_text_videoram[12], state->m_text_videoram[13], state->m_text_videoram[14], - state->m_text_videoram[15], offset); -*/ } WRITE16_HANDLER( armedf_fg_videoram_w ) @@ -306,50 +279,24 @@ SCREEN_UPDATE( armedf ) } - bitmap_fill(bitmap, cliprect , 0xff); - if(state->m_scroll_type == 2) /* legion / legiono */ - { - tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, 1, 0); - } + tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, TILEMAP_DRAW_CATEGORY(1), 0); - if (state->m_vreg & 0x0800) - tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0); -#if 0 - if(state->m_vreg & 0x0800) - { - tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0); - } - else - { - bitmap_fill(bitmap, cliprect , get_black_pen(screen->machine()) & 0x0f); - } -#endif - - if ((state->m_vreg & 0x0030) == 0x0030) - tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0); if (sprite_enable) draw_sprites(screen->machine(), bitmap, cliprect, 2); - if ((state->m_vreg & 0x0030) == 0x0020) - tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, 0, 0); - tilemap_draw(bitmap, cliprect, state->m_fg_tilemap, 0, 0); - if ((state->m_vreg & 0x0030) == 0x0010) - tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, 0, 0); - if (sprite_enable) draw_sprites(screen->machine(), bitmap, cliprect, 1); - if ((state->m_vreg & 0x0030) == 0x0000) - tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, 0, 0); - if (sprite_enable) draw_sprites(screen->machine(), bitmap, cliprect, 0); + tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, TILEMAP_DRAW_CATEGORY(0), 0); return 0; }