diff --git a/src/mame/drivers/namcona1.c b/src/mame/drivers/namcona1.c index 5274431aa2a..65017e8826e 100644 --- a/src/mame/drivers/namcona1.c +++ b/src/mame/drivers/namcona1.c @@ -974,9 +974,9 @@ static void namcona1_blit( running_machine *machine ) int num_bytes = namcona1_vreg[0xb]; - int dest_offset, source_offset; - int dest_bytes_per_row, dst_pitch; - int source_bytes_per_row, src_pitch; + int dst_offset, src_offset; + int dst_bytes_per_row, dst_pitch; + int src_bytes_per_row, src_pitch; (void)dst2; (void)dst0; @@ -990,8 +990,8 @@ static void namcona1_blit( running_machine *machine ) dst0,dst1,dst2, gfxbank );*/ - blit_setup( dst1, &dest_bytes_per_row, &dst_pitch, gfxbank); - blit_setup( src1, &source_bytes_per_row, &src_pitch, gfxbank ); + blit_setup( dst1, &dst_bytes_per_row, &dst_pitch, gfxbank); + blit_setup( src1, &src_bytes_per_row, &src_pitch, gfxbank ); if( num_bytes&1 ) { @@ -1002,33 +1002,38 @@ static void namcona1_blit( running_machine *machine ) { dst_baseaddr += 0xf40000; } + if( input_code_pressed(KEYCODE_N) ) + { + printf( "src format=%04x baseaddr=%x width=%x pitch=%x\n", src1, src_baseaddr, src_bytes_per_row, src_pitch ); + printf( "dst format=%04x baseaddr=%x width=%x pitch=%x\n", dst1, dst_baseaddr, dst_bytes_per_row, dst_pitch ); + } - dest_offset = 0; - source_offset = 0; + dst_offset = 0; + src_offset = 0; while( num_bytes>0 ) { if( transfer_dword(machine, - dst_baseaddr + dest_offset, - src_baseaddr + source_offset ) ) + dst_baseaddr + dst_offset, + src_baseaddr + src_offset ) ) { return; } num_bytes -= 2; - dest_offset+=2; - if( dest_offset >= dest_bytes_per_row ) + dst_offset+=2; + if( dst_offset >= dst_bytes_per_row ) { dst_baseaddr += dst_pitch; - dest_offset = 0; + dst_offset = 0; } - source_offset+=2; - if( source_offset >= source_bytes_per_row ) + src_offset+=2; + if( src_offset >= src_bytes_per_row ) { src_baseaddr += src_pitch; - source_offset = 0; + src_offset = 0; } } } /* namcona1_blit */ @@ -1085,8 +1090,9 @@ static ADDRESS_MAP_START( namcona1_main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xefff00, 0xefffff) AM_READWRITE(namcona1_vreg_r, namcona1_vreg_w) AM_BASE(&namcona1_vreg) AM_RANGE(0xf00000, 0xf01fff) AM_READWRITE(namcona1_paletteram_r, namcona1_paletteram_w) AM_BASE(&paletteram16) AM_RANGE(0xf40000, 0xf7ffff) AM_READWRITE(namcona1_gfxram_r, namcona1_gfxram_w) - AM_RANGE(0xff0000, 0xff7fff) AM_READWRITE(namcona1_videoram_r, namcona1_videoram_w) AM_BASE(&videoram16) - AM_RANGE(0xff8000, 0xffdfff) AM_RAM AM_BASE(&namcona1_sparevram) /* spare videoram */ + AM_RANGE(0xff0000, 0xff7fff) AM_READWRITE(namcona1_videoram_r, namcona1_videoram_w) AM_BASE(&videoram16) + AM_RANGE(0xff8000, 0xff8fff) AM_READWRITE(namcona1_rozvideoram_r, namcona1_rozvideoram_w) AM_BASE(&namcona1_rozvideoram) + AM_RANGE(0xff9000, 0xffdfff) AM_RAM AM_BASE(&namcona1_sparevram) /* spare videoram */ AM_RANGE(0xffe000, 0xffefff) AM_RAM AM_BASE(&namcona1_scroll) /* scroll registers */ AM_RANGE(0xfff000, 0xffffff) AM_RAM AM_BASE(&spriteram16) /* spriteram */ ADDRESS_MAP_END @@ -1270,17 +1276,38 @@ static ADDRESS_MAP_START( namcona1_mcu_io_map, ADDRESS_SPACE_IO, 8 ) AM_RANGE(0x10, 0x1f) AM_READ( portana_r ) ADDRESS_MAP_END +static TIMER_CALLBACK( namcona1_posirq ) +{ + video_screen_update_partial(machine->primary_screen, param); + cpunum_set_input_line(machine, 0/*CPU*/, 2+1, HOLD_LINE); +} + static INTERRUPT_GEN( namcona1_interrupt ) { int level = cpu_getiloops(); /* 0,1,2,3,4 */ + int posirq = input_code_pressed(KEYCODE_M); + if( level==0 ) { simulate_mcu(machine); + if( mEnableInterrupts && posirq ) + { + if( level==2 && namcona1_vreg[0x1a/2]&(1<<2) ) + { + int scanline = 192;//namcona1_vreg[0xac/2]; + timer_set(video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, namcona1_posirq ); + } + if( level==3 && namcona1_vreg[0x1a/2]&(1<<3) ) + { + cpunum_set_input_line(machine, 0, 3+1, HOLD_LINE); + } + } } - if( mEnableInterrupts ) + if( mEnableInterrupts && !posirq ) { if( (namcona1_vreg[0x1a/2]&(1<>12; + } + if( data & 0x8000 ) + { + SET_TILE_INFO( gfx,tile,tilemap_color,TILE_FORCE_LAYER0 ); + } + else + { +#ifdef LSB_FIRST + UINT16 *source; + static UINT8 mask_data[8]; + source = shaperam+4*tile; + mask_data[0] = source[0]>>8; + mask_data[1] = source[0]&0xff; + mask_data[2] = source[1]>>8; + mask_data[3] = source[1]&0xff; + mask_data[4] = source[2]>>8; + mask_data[5] = source[2]&0xff; + mask_data[6] = source[3]>>8; + mask_data[7] = source[3]&0xff; +#else + UINT8 *mask_data = (UINT8 *)(shaperam+4*tile); +#endif + SET_TILE_INFO( gfx,tile,tilemap_color,0 ); + tileinfo->mask_data = mask_data; + } +} /* roz_get_info */ + +WRITE16_HANDLER( namcona1_rozvideoram_w ) +{ + COMBINE_DATA( &namcona1_rozvideoram[offset] ); + roz_dirty = 1; +} +READ16_HANDLER( namcona1_rozvideoram_r ) +{ + return namcona1_rozvideoram[offset]; +} /*************************************************************************/ @@ -229,7 +287,7 @@ static void update_gfx(running_machine *machine) if( dirtygfx ) { - for( page = 0; page<4; page++ ) + for( page = 0; pagetotal_colors = machine->config->total_colors/256; - machine->gfx[0] = gfx0; + gfx0 = allocgfx( &cg_layout_8bpp ); + gfx0->total_colors = machine->config->total_colors/256; + machine->gfx[0] = gfx0; - gfx1->total_colors = machine->config->total_colors/16; - machine->gfx[1] = gfx1; + gfx1 = allocgfx( &cg_layout_4bpp ); + gfx1->total_colors = machine->config->total_colors/16; + machine->gfx[1] = gfx1; - gfx2->total_colors = machine->config->total_colors/2; - machine->gfx[2] = gfx2; + gfx2 = allocgfx( &shape_layout ); + gfx2->total_colors = machine->config->total_colors/2; + machine->gfx[2] = gfx2; } /* namcona1_vh_start */ /*************************************************************************/ @@ -309,7 +377,7 @@ static void pdraw_tile(running_machine *machine, UINT8 *mask_base = mask->gfxdata + (code % mask->total_elements) * mask->char_modulo; int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16; - int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16; + int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16; if (sprite_screen_width && sprite_screen_height) { @@ -404,22 +472,24 @@ static void pdraw_tile(running_machine *machine, int c = source[x_index>>16]; /* render a shadow only if the sprites color is $F (8bpp) or $FF (4bpp) */ - if( bShadow && ((gfx_region == 0 && color == 0x0f) || (gfx_region == 1 && color == 0xff))) + if( bShadow ) { - pen_t *palette_shadow_table = machine->shadow_table; - dest[x] = palette_shadow_table[dest[x]]; - } - else if( bShadow && !((gfx_region == 0 && color == 0x0f) || (gfx_region == 1 && color == 0xff))) - { - //bad colors! - dest[x] = pal_base + c; + if( (gfx_region == 0 && color == 0x0f) || + (gfx_region == 1 && color == 0xff) ) + { + pen_t *palette_shadow_table = machine->shadow_table; + dest[x] = palette_shadow_table[dest[x]]; + } + else + { + dest[x] = pal_base + c; + } } else { dest[x] = pal_base + c; } } - pri[x] = 0xff; } } @@ -483,6 +553,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { sx+=col*8; } + sx = ((sx+16)&0x1ff)-8; + sy = ((sy+8)&0x1ff)-8; if(color & 8) { @@ -491,9 +563,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta cliprect, (tile & 0xfff) + row*64+col, ((color>>4)&0xf) * 0x10 + ((color & 0xf00) >> 8), - ((sx+16)&0x1ff)-8, - ((sy+8)&0x1ff)-8, - flipx,flipy, + sx,sy,flipx,flipy, priority, color & 0x4000, /* shadow */ tile & 0x8000, /* opaque */ @@ -506,9 +576,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta cliprect, (tile & 0xfff) + row*64+col, (color>>4)&0xf, - ((sx+16)&0x1ff)-8, - ((sy+8)&0x1ff)-8, - flipx,flipy, + sx,sy,flipx,flipy, priority, color & 0x4000, /* shadow */ tile & 0x8000, /* opaque */ @@ -593,7 +661,7 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re else { // used in emeraldia - if(which == 1 && namcona1_vreg[0x8a/2] == 0xfd /* maybe reg & 0x4 */) + if(which == NAMCONA1_NUM_TILEMAPS )// && namcona1_vreg[0x8a/2] == 0xfd /* maybe reg & 0x4 */) { int incxx = ((INT16)namcona1_vreg[0xc0/2])<<8; // or incyy ? int incxy = ((INT16)namcona1_vreg[0xc2/2])<<8; @@ -610,10 +678,9 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re UINT32 startx = (xoffset<<12)+incxx*dx+incyx*dy; UINT32 starty = (yoffset<<12)+incxy*dx+incyy*dy; - tilemap_draw_roz_primask(bitmap, &clip, bg_tilemap[which], + tilemap_draw_roz_primask(bitmap, &clip, roz_tilemap, startx, starty, incxx, incxy, incyx, incyy, 0, 0, primask, 0); - } else { @@ -646,30 +713,61 @@ VIDEO_UPDATE( namcona1 ) update_gfx(screen->machine); for( which=0; which=0; which-- ) + for( which=4; which>=0; which-- ) { - if( (namcona1_vreg[0x50+which]&0x7) == priority ) + int pri = namcona1_vreg[0xa0/2+which]&0x7; /* likely wrong for roz plane */ + if( pri == priority ) { draw_background(screen->machine,bitmap,cliprect,which,priority); } } /* next tilemap */ } /* next priority level */ + draw_sprites(screen->machine,bitmap,cliprect); } /* gfx enabled */ return 0; } + +/* +$efff20: sprite control: 0x3a,0x3e,0x3f + bit 0x01 selects spriteram bank + + 0 2 4 6 8 a c e +$efff00: src0 src1 src2 dst0 dst1 dst2 BANK [src +$efff10: src] [dst dst] #BYT BLIT eINT 001f 0001 +$efff20: 003f 003f IACK ---- ---- ---- ---- ---- +$efff80: 0050 0170 0020 0100 0000 00?? 0000 GFXE +$efff90: 0000 0001 0002 0003 FLIP ---- ---- ---- +$efffa0: PRI PRI PRI PRI ---- PRI? POSI ---- priority (0..7) + scanline interrupt? +$efffb0: CLR CLR CLR CLR 0001 CLR? BPP ---- color (0..f), bpp flag per layer +$efffc0: RZXX RZXY RZYX RZYY RZX0 RZY0 ???? ---- ROZ +*/ +