diff options
Diffstat (limited to 'src/mame/drivers/wheelfir.c')
-rw-r--r-- | src/mame/drivers/wheelfir.c | 374 |
1 files changed, 187 insertions, 187 deletions
diff --git a/src/mame/drivers/wheelfir.c b/src/mame/drivers/wheelfir.c index 018450c28cd..935833c0374 100644 --- a/src/mame/drivers/wheelfir.c +++ b/src/mame/drivers/wheelfir.c @@ -1,18 +1,18 @@ -/**************************************************************** +/**************************************************************** -Wheels & Fire +Wheels & Fire driver by David Haywood Tomasz Slanina - - + + TODO: - sound comms - eeprom - various gfx size/pos glitches (gaps, extra rows of pixels here and there) - real gfx zoom, based on the zoom params, not lookup table -- apply double buffering (sometimes gfx is displayed at y+256 every other frame (extra bits are currently masked out)) +- apply double buffering (sometimes gfx is displayed at y+256 every other frame (extra bits are currently masked out)) - fix road/sky (extra bits in teh scroll reg. are there two bitmap buffers? ) - bitmap layer clearing - fix wrong coords of sprites rendered into the bitmap layer (intro car) @@ -63,73 +63,73 @@ level 1 interrupt = blitter interrupt Blitter data foramt ( offset in words, offset in bytes, offset inside ram data table ) - - fedcba9876543210 + + fedcba9876543210 0 0 0 - --------76543210 dest_x0 bits 0-7 - 76543210-------- src_x0 bits 0-7 - + --------76543210 dest_x0 bits 0-7 + 76543210-------- src_x0 bits 0-7 + 1 2 2 - --------76543210 dest_x1 bits 0-7 - + --------76543210 dest_x1 bits 0-7 + 2 4 4 - --------76543210 dest_y0 bits 0-7 - 76543210-------- src_y0 bits 0-7 + --------76543210 dest_y0 bits 0-7 + 76543210-------- src_y0 bits 0-7 3 6 6 - --------76543210 dest_y1 bits 0-7 - + --------76543210 dest_y1 bits 0-7 + 4 8 -5 a +5 a 6 c 8 - ??------???????? image flags (directly copied from image info table, page and ?) - --3210---------- image page - -------8-------- src_x0 bit 8 - ------8--------- src_y0 bit 8 + ??------???????? image flags (directly copied from image info table, page and ?) + --3210---------- image page + -------8-------- src_x0 bit 8 + ------8--------- src_y0 bit 8 7 e a - ????????--?----- flags - ---------------X X direction (src?) - --------------Y- Y direction (src?) - ---------8------ dest_x0 bit 8 - --------8------- dest_y0 bit 8 - -----------L---- dest layer - ------------??-- unknown bits, set usually when rendering target = bitmap layer - - -8 10 c - -------5-------- x scale data1 bit 5 - ------5--------- y scale data1 bit 5 - -----5---------- x scale data2 bit 5 - ----5----------- y scala data2 bit 5 - ---D------------ x scale >200% - --D------------- y scale >200% - -x-------------- X direction (dest?) - Y--------------- Y direction (dest?) - ---------8------ scroll x bit 8 - --------8------- scroll y bit 8 - ----------?----- set for road ? buffer num (is there double buffering ? or two bitmap layers?) - + ????????--?----- flags + ---------------X X direction (src?) + --------------Y- Y direction (src?) + ---------8------ dest_x0 bit 8 + --------8------- dest_y0 bit 8 + -----------L---- dest layer + ------------??-- unknown bits, set usually when rendering target = bitmap layer + + +8 10 c + -------5-------- x scale data1 bit 5 + ------5--------- y scale data1 bit 5 + -----5---------- x scale data2 bit 5 + ----5----------- y scala data2 bit 5 + ---D------------ x scale >200% + --D------------- y scale >200% + -x-------------- X direction (dest?) + Y--------------- Y direction (dest?) + ---------8------ scroll x bit 8 + --------8------- scroll y bit 8 + ----------?----- set for road ? buffer num (is there double buffering ? or two bitmap layers?) + 9 12 e - ---------------H x scale < 50% - --------------H- y scale < 50% - -------------8-- dest_x1 bit 8 - ------------8--- dest_y1 bit 8 - - -a 14 10 - ---43210-------- x scale data1 bits 0-4 - -4-------------- y scale data1 bit 4 - --------76543210 scroll x of bitmap layer - + ---------------H x scale < 50% + --------------H- y scale < 50% + -------------8-- dest_x1 bit 8 + ------------8--- dest_y1 bit 8 + + +a 14 10 + ---43210-------- x scale data1 bits 0-4 + -4-------------- y scale data1 bit 4 + --------76543210 scroll x of bitmap layer + b 16 12 - ---43210-------- x scale data2 bits 0-4 - 10-------------- y scale data1 bits 0-1 - --------76543210 scroll y of bitmap layer + ---43210-------- x scale data2 bits 0-4 + 10-------------- y scale data1 bits 0-1 + --------76543210 scroll y of bitmap layer c 18 14 - ---43210-------- y scale data2 bits 0-4 - 32-------------- y scale data1 bits 2-3 + ---43210-------- y scale data2 bits 0-4 + 32-------------- y scale data1 bits 2-3 d 1a e 1c f 1e @@ -161,7 +161,7 @@ BITS FGHIJ = DATA2 (0-31) BIT K - ( scale > 200% ) ? 1 : 0 BIT L - ( DATA2 != 0) ? 1 : 0 (or DATA2 MSB) BIT M - ( DATA1 != 0) ? 1 : 0 (or DATA1 MSB) -BIT N - ( scale < 50% ) ? 1 : 0 +BIT N - ( scale < 50% ) ? 1 : 0 pcb linking @@ -193,7 +193,7 @@ suspicious code: 0A53CE: 3180 0000 move.w D0, (A0,D0.w) ; write offset 0A53D2: 3180 0000 move.w D0, (A0,D0.w) ; again -0A53D6: 3239 007E 0000 move.w $7e0000.l, D1 +0A53D6: 3239 007E 0000 move.w $7e0000.l, D1 0A53DC: 0801 000D btst #$d, D1 ; flag test 0A53E0: 67F4 beq $a53d6 @@ -228,8 +228,8 @@ struct scroll_info class wheelfir_state { public: - static void *alloc(running_machine &machine) - { + static void *alloc(running_machine &machine) + { return auto_alloc_clear(&machine, wheelfir_state(machine)); } @@ -239,30 +239,30 @@ public: running_device *subcpu; running_device *screen; running_device *eeprom; - + INT32 *zoom_table; UINT16 *blitter_data; - + UINT8 *palette; INT32 palpos; - + INT32 current_scanline; scroll_info *scanlines; INT32 soundlatch; - + INT32 direct_write_x0; INT32 direct_write_x1; INT32 direct_write_y0; INT32 direct_write_y1; INT32 direct_write_idx; - + INT32 toggle_bit; INT16 scanline_cnt; - - + + bitmap_t *tmp_bitmap[2]; - + INT32 get_scale(INT32 index) { while(index<ZOOM_TABLE_SIZE) @@ -270,7 +270,7 @@ public: if(zoom_table[index]>=0) { return zoom_table[index]; - } + } ++index; } return 0; @@ -282,15 +282,15 @@ static timer_device* scanline_timer; static READ16_HANDLER( wheelfir_status_r ) { /* - fedcba9876543210 - x--------------- vblank ? - --x------------- ? must be 1 - --------------x- ? eeprom - ---------------x ? eeprom + fedcba9876543210 + x--------------- vblank ? + --x------------- ? must be 1 + --------------x- ? eeprom + ---------------x ? eeprom */ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data; - return state->toggle_bit| (mame_rand(space->machine)&0x2000); + return state->toggle_bit| (mame_rand(space->machine)&0x2000); } static WRITE16_HANDLER( wheelfir_scanline_cnt_w ) @@ -309,127 +309,127 @@ static WRITE16_HANDLER(wheelfir_blit_w) if(!ACCESSING_BITS_8_15 && offset==0x6) //LSB only! { int x,y; - - + + int direct_width=state->direct_write_x1-state->direct_write_x0+1; int direct_height=state->direct_write_y1-state->direct_write_y0+1; - + int sixdat = data&0xff; - + if(direct_width>0 && direct_height>0) { x= state->direct_write_idx % direct_width; y = (state->direct_write_idx / direct_width) %direct_height; - + x+=state->direct_write_x0; y+=state->direct_write_y0; - + if(x<512 && y <512) { *BITMAP_ADDR16(state->tmp_bitmap[LAYER_BG], y, x) = sixdat; } } - + ++state->direct_write_idx; - + return; } int yscroll=-1; int xscroll=-1; - + if(offset==0x0a && ACCESSING_BITS_0_7) { xscroll = (state->blitter_data[0xa]&0x00ff) | (state->blitter_data[0x8]&0x0040) << 2; } - + if(offset==0x0b && ACCESSING_BITS_0_7) { yscroll = (state->blitter_data[0xb]&0x00ff) | (state->blitter_data[0x8]&0x0080) << 1; } - + if(offset==0x8 && ACCESSING_BITS_0_7) { xscroll = (state->blitter_data[0xa]&0x00ff) | (state->blitter_data[0x8]&0x0040) << 2; yscroll = (state->blitter_data[0xb]&0x00ff) | (state->blitter_data[0x8]&0x0080) << 1; } - + if(xscroll>=0) { int scl=state->current_scanline>=NUM_SCANLINES?0:state->current_scanline; state->scanlines[scl].x=xscroll; state->scanlines[scl].unkbits=state->blitter_data[0x8]&0xff; } - + if(yscroll>=0) { int scl=state->current_scanline>=NUM_SCANLINES?0:state->current_scanline; state->scanlines[scl].y=yscroll; state->scanlines[scl].unkbits=state->blitter_data[0x8]&0xff; } - + if(offset==0xf && data==0xffff) { - cputag_set_input_line(space->machine, "maincpu", 1, HOLD_LINE); - + cputag_set_input_line(space->machine, "maincpu", 1, HOLD_LINE); + { UINT8 *rom = memory_region(space->machine, "gfx1"); - + int width = space->machine->primary_screen->width(); int height = space->machine->primary_screen->height(); - + int src_x0=(state->blitter_data[0]>>8)+((state->blitter_data[6]&0x100)?256:0); int src_y0=(state->blitter_data[2]>>8)+((state->blitter_data[6]&0x200)?256:0); - + int dst_x0=(state->blitter_data[0]&0xff)+((state->blitter_data[7]&0x40)?256:0); int dst_y0=(state->blitter_data[2]&0xff)+((state->blitter_data[7]&0x80)?256:0); int dst_x1=(state->blitter_data[1]&0xff)+((state->blitter_data[9]&4)?256:0); int dst_y1=(state->blitter_data[3]&0xff)+((state->blitter_data[9]&8)?256:0); - + int x_dst_step=(state->blitter_data[7]&0x1)?1:-1; int y_dst_step=(state->blitter_data[7]&0x2)?1:-1; - + int x_src_step=(state->blitter_data[8]&0x4000)?1:-1; int y_src_step=(state->blitter_data[8]&0x8000)?1:-1; - - int page=((state->blitter_data[6])>>10)*0x40000; - + int page=((state->blitter_data[6])>>10)*0x40000; + + if(page>=0x400000) /* src set to unav. page before direct write to the framebuffer */ { - + state->direct_write_x0=dst_x0; state->direct_write_x1=dst_x1; state->direct_write_y0=dst_y0; state->direct_write_y1=dst_y1; state->direct_write_idx=0; - + } - + if(x_dst_step<0) { if(dst_x0<=dst_x1) { - + return; } - + } else { - + if(dst_x0>=dst_x1) { return; } - + } - + if(y_dst_step<0) { if(dst_y0<=dst_y1) @@ -439,81 +439,81 @@ static WRITE16_HANDLER(wheelfir_blit_w) } else { - + if(dst_y0>=dst_y1) { return; } - + } - - - //additional checks - + + + //additional checks + int d1, d2, hflag, dflag, index; - + d1=((state->blitter_data[0x0a]&0x1f00)>>8); - + d2=((state->blitter_data[0x0b]&0x1f00)>>8); - - + + d1|=((state->blitter_data[0x8]&0x100)>>3); d2|=((state->blitter_data[0x8]&0x400)>>5); hflag=(state->blitter_data[0x9]&0x1)?1:0; dflag=(state->blitter_data[0x8]&0x1000)?1:0; index=d1|(d2<<6)|(hflag<<12)|(dflag<<13); - - + + float scale_x=state->get_scale(index); - + d1=((state->blitter_data[0x0b]&0xc000)>>14) | ((state->blitter_data[0x0c]&0xc000)>>12) | ((state->blitter_data[0x0a]&0x4000)>>10); - + d2=((state->blitter_data[0x0c]&0x1f00)>>8); - - + + d1|=((state->blitter_data[0x8]&0x200)>>4); d2|=((state->blitter_data[0x8]&0x800)>>6); - + hflag=(state->blitter_data[0x9]&0x2)?1:0; dflag=(state->blitter_data[0x8]&0x2000)?1:0; index=d1|(d2<<6)|(hflag<<12)|(dflag<<13); - - + + float scale_y=state->get_scale(index); - - + + if(scale_x==0 || scale_y==0) return; - - + + float scale_x_step=100.f/scale_x; float scale_y_step=100.f/scale_y; - - - + + + int x,y; float idx_x,idx_y; - + int vpage=LAYER_FG; if(state->blitter_data[0x7]&0x10) { vpage=LAYER_BG; -/* - printf("bg -> %d %d %d %d %d %d @ %x\n",dst_x0,dst_y0, dst_x1,dst_y1, dst_x1-dst_x0, dst_y1-dst_y0,cpu_get_pc(space->cpu)); - - for(int i=0;i<16;++i) - { - printf("%x = %.4x\n",i,state->blitter_data[i]); - } - - printf("\n"); +/* + printf("bg -> %d %d %d %d %d %d @ %x\n",dst_x0,dst_y0, dst_x1,dst_y1, dst_x1-dst_x0, dst_y1-dst_y0,cpu_get_pc(space->cpu)); + + for(int i=0;i<16;++i) + { + printf("%x = %.4x\n",i,state->blitter_data[i]); + } + + printf("\n"); */ } - + bool endx=false; bool endy=false; - + if(state->blitter_data[0x7]&0x0c) { //??? @@ -530,21 +530,21 @@ static WRITE16_HANDLER(wheelfir_blit_w) int xx=src_x0+x_src_step*idx_x; int yy=src_y0+y_src_step*idx_y; - + int address=page+yy*512+xx; int pix = rom[address&(0x1000000-1)]; - + int screen_x=x; int screen_y=y; - - + + if(page>=0x400000) { //hack for clear if(screen_x >0 && screen_y >0 && screen_x < width && screen_y <height) { - // *BITMAP_ADDR16(state->tmp_bitmap[vpage], screen_y , screen_x ) =0; + // *BITMAP_ADDR16(state->tmp_bitmap[vpage], screen_y , screen_x ) =0; } } else @@ -565,21 +565,21 @@ static WRITE16_HANDLER(wheelfir_blit_w) static VIDEO_START(wheelfir) { wheelfir_state *state = (wheelfir_state *)machine->driver_data; - state->tmp_bitmap[0] = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16); - state->tmp_bitmap[1] = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16); + state->tmp_bitmap[0] = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16); + state->tmp_bitmap[1] = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16); } static VIDEO_UPDATE(wheelfir) { wheelfir_state *state = (wheelfir_state *)screen->machine->driver_data; - + bitmap_fill(bitmap, cliprect,0); for(int y=0;y<NUM_SCANLINES;++y) { UINT16 *source = BITMAP_ADDR16(state->tmp_bitmap[LAYER_BG],( (state->scanlines[y].y)&511), 0); UINT16 *dest = BITMAP_ADDR16(bitmap, y, 0); - + for (int x=0;x<336;x++) { @@ -589,12 +589,12 @@ static VIDEO_UPDATE(wheelfir) } copybitmap_trans(bitmap, state->tmp_bitmap[LAYER_FG], 0, 0, 0, 0, cliprect, 0); - + /* - { - bitmap_fill(state->tmp_bitmap[LAYER_BG], &screen->visible_area(),0); + { + bitmap_fill(state->tmp_bitmap[LAYER_BG], &screen->visible_area(),0); - } + } */ return 0; @@ -621,7 +621,7 @@ static WRITE16_HANDLER( pal_data_w ) ++state->palpos; state->palpos %=NUM_COLORS*3; - + { int r = state->palette[color*3]; int g = state->palette[color*3+1]; @@ -645,7 +645,7 @@ static WRITE16_HANDLER(wheelfir_snd_w) } static READ16_HANDLER( wheelfir_snd_r ) -{ +{ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data; return state->soundlatch; } @@ -654,7 +654,7 @@ static WRITE16_HANDLER(coin_cnt_w) { /* bits 0/1 coin counters */ coin_counter_w(space->machine, 0, data & 0x01); - coin_counter_w(space->machine, 1, data & 0x02); + coin_counter_w(space->machine, 1, data & 0x02); } @@ -663,7 +663,7 @@ static ADDRESS_MAP_START( wheelfir_main, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_RANGE(0x700000, 0x70001f) AM_WRITE(wheelfir_blit_w) - AM_RANGE(0x720000, 0x720001) AM_WRITE(pal_reset_pos_w) + AM_RANGE(0x720000, 0x720001) AM_WRITE(pal_reset_pos_w) AM_RANGE(0x720002, 0x720003) AM_WRITE(pal_data_w) AM_RANGE(0x720004, 0x720005) AM_WRITENOP // always ffff? AM_RANGE(0x740000, 0x740001) AM_WRITE(wheelfir_snd_w) @@ -683,7 +683,7 @@ static ADDRESS_MAP_START( wheelfir_sub, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_RANGE(0x780000, 0x780001) AM_READ(wheelfir_snd_r) - + AM_RANGE(0x700000, 0x700001) AM_DEVWRITE8("dac1", dac_w, 0xff00) //guess for now AM_RANGE(0x740000, 0x740001) AM_DEVWRITE8("dac2", dac_w, 0xff00) ADDRESS_MAP_END @@ -704,7 +704,7 @@ static INPUT_PORTS_START( wheelfir ) PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_DIPNAME( 0x1000, 0x1000, "Test / Game?" ) - PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED ) /* net comm flag ? */ PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -731,11 +731,11 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) if(state->current_scanline<NUM_SCANLINES) { //visible scanline - + state->toggle_bit = 0x0000; - + --state->scanline_cnt; - + if(state->current_scanline>0) { //copy scanline offset @@ -743,18 +743,18 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) state->scanlines[state->current_scanline].y=(state->scanlines[state->current_scanline-1].y+1); state->scanlines[state->current_scanline].unkbits=state->scanlines[state->current_scanline-1].unkbits; } - + if(state->scanline_cnt==0) //<=0 ? { cputag_set_input_line(timer.machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road } - + } else { if(state->current_scanline==NUM_SCANLINES) /* vblank */ { - state->toggle_bit = 0x8000; + state->toggle_bit = 0x8000; cputag_set_input_line(timer.machine, "maincpu", 3, HOLD_LINE); } } @@ -778,30 +778,30 @@ static MACHINE_START( wheelfir ) state->zoom_table = auto_alloc_array(machine, INT32, ZOOM_TABLE_SIZE); state->blitter_data = auto_alloc_array(machine, UINT16, 16); - + state->scanlines = reinterpret_cast<scroll_info*>(auto_alloc_array(machine, UINT8, sizeof(scroll_info)*(NUM_SCANLINES+NUM_VBLANK_LINES))); state->palette=auto_alloc_array(machine, UINT8, NUM_COLORS*3); - - + + for(int i=0;i<(ZOOM_TABLE_SIZE);++i) { state->zoom_table[i]=-1; } - + UINT16 *ROM = (UINT16 *)memory_region(machine, "maincpu"); - + for(int j=0;j<400;++j) { int i=j<<3; int d1=ROM[0x200+i]&0x1f; int d0=(ROM[0x200+i]>>8)&0x1f; - + d0|=(ROM[0x200+1+i]&1)?0x20:0; d1|=(ROM[0x200+1+i]&4)?0x20:0; - + int hflag=(ROM[0x200+2+i]&0x100)?1:0; int dflag=(ROM[0x200+1+i]&0x10)?1:0; - + int index=d0|(d1<<6)|(hflag<<12)|(dflag<<13); state->zoom_table[index]=j; } @@ -817,7 +817,7 @@ static MACHINE_DRIVER_START( wheelfir ) MDRV_CPU_ADD("subcpu", M68000, 32000000/2) MDRV_CPU_PROGRAM_MAP(wheelfir_sub) //MDRV_CPU_VBLANK_INT_HACK(irq1_line_hold,256) - + MDRV_QUANTUM_TIME(HZ(12000)) MDRV_MACHINE_RESET (wheelfir) @@ -827,21 +827,21 @@ static MACHINE_DRIVER_START( wheelfir ) MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) - + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) MDRV_SCREEN_SIZE(336, NUM_SCANLINES+NUM_VBLANK_LINES) MDRV_SCREEN_VISIBLE_AREA(0,335, 0, NUM_SCANLINES-1) MDRV_PALETTE_LENGTH(NUM_COLORS) - + MDRV_EEPROM_93C46_ADD("eeprom") - + MDRV_MACHINE_START(wheelfir) MDRV_VIDEO_START(wheelfir) MDRV_VIDEO_UPDATE(wheelfir) MDRV_VIDEO_EOF(wheelfir) - + /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -869,7 +869,7 @@ ROM_START( wheelfir ) ROM_LOAD( "tch8.u56", 0x200000, 0x80000, CRC(22b661fe) SHA1(b6edf8e1e8b479ee8813502157615f54627dc7c1) ) ROM_LOAD( "tch9.u57", 0x280000, 0x80000, CRC(83c66de3) SHA1(50deaf3338d590340b928f891548c47ba8f3ca38) ) ROM_LOAD( "tch10.u58",0x300000, 0x80000, CRC(2036ed80) SHA1(910381e2ccdbc2d06f873021d8af02795d22f595) ) - ROM_LOAD( "tch12.u59",0x380000, 0x80000, CRC(cce2e675) SHA1(f3d8916077b2e057169d0f254005cd959789a3b3) ) + ROM_LOAD( "tch12.u59",0x380000, 0x80000, CRC(cce2e675) SHA1(f3d8916077b2e057169d0f254005cd959789a3b3) ) ROM_END static DRIVER_INIT(wheelfir) |