trunk/src/mame/drivers/r2dx_v33.c
| r21028 | r21029 | |
| 72 | 72 | virtual void video_start(); |
| 73 | 73 | UINT32 screen_update_rdx_v33(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 74 | 74 | INTERRUPT_GEN_MEMBER(rdx_v33_interrupt); |
| 75 | void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri); |
| 75 | 76 | }; |
| 76 | 77 | |
| 77 | 78 | |
| r21028 | r21029 | |
| 116 | 117 | } |
| 117 | 118 | |
| 118 | 119 | /* copied from Legionnaire */ |
| 119 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri) |
| 120 | void r2dx_v33_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri) |
| 120 | 121 | { |
| 121 | | r2dx_v33_state *state = machine.driver_data<r2dx_v33_state>(); |
| 122 | | UINT16 *spriteram16 = state->m_spriteram; |
| 122 | UINT16 *spriteram16 = m_spriteram; |
| 123 | 123 | int offs,fx,fy,x,y,color,sprite; |
| 124 | 124 | // int cur_pri; |
| 125 | 125 | int dx,dy,ax,ay; |
| r21028 | r21029 | |
| 160 | 160 | for (ax=0; ax<dx; ax++) |
| 161 | 161 | for (ay=0; ay<dy; ay++) |
| 162 | 162 | { |
| 163 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 163 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 164 | 164 | sprite++, |
| 165 | 165 | color,fx,fy,x+ax*16,y+ay*16,15); |
| 166 | 166 | } |
| r21028 | r21029 | |
| 170 | 170 | for (ax=0; ax<dx; ax++) |
| 171 | 171 | for (ay=0; ay<dy; ay++) |
| 172 | 172 | { |
| 173 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 173 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 174 | 174 | sprite++, |
| 175 | 175 | color,fx,fy,x+ax*16,y+(dy-ay-1)*16,15); |
| 176 | 176 | } |
| r21028 | r21029 | |
| 183 | 183 | for (ax=0; ax<dx; ax++) |
| 184 | 184 | for (ay=0; ay<dy; ay++) |
| 185 | 185 | { |
| 186 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 186 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 187 | 187 | sprite++, |
| 188 | 188 | color,fx,fy,x+(dx-ax-1)*16,y+ay*16,15); |
| 189 | 189 | } |
| r21028 | r21029 | |
| 193 | 193 | for (ax=0; ax<dx; ax++) |
| 194 | 194 | for (ay=0; ay<dy; ay++) |
| 195 | 195 | { |
| 196 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 196 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 197 | 197 | sprite++, |
| 198 | 198 | color,fx,fy,x+(dx-ax-1)*16,y+(dy-ay-1)*16,15); |
| 199 | 199 | } |
| r21028 | r21029 | |
| 223 | 223 | m_md_tilemap->draw(bitmap, cliprect, 0, 0); |
| 224 | 224 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 225 | 225 | |
| 226 | | draw_sprites(machine(),bitmap,cliprect,0); |
| 226 | draw_sprites(bitmap,cliprect,0); |
| 227 | 227 | |
| 228 | 228 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 229 | 229 | |
trunk/src/mame/drivers/rabbit.c
| r21028 | r21029 | |
| 140 | 140 | UINT32 screen_update_rabbit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 141 | 141 | INTERRUPT_GEN_MEMBER(rabbit_vblank_interrupt); |
| 142 | 142 | TIMER_CALLBACK_MEMBER(rabbit_blit_done); |
| 143 | inline void get_rabbit_tilemap_info(tile_data &tileinfo, int tile_index, int whichtilemap, int tilesize); |
| 144 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ); |
| 145 | void rabbit_clearspritebitmap( bitmap_ind16 &bitmap, const rectangle &cliprect ); |
| 146 | void draw_sprite_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect ); |
| 147 | void rabbit_drawtilemap( bitmap_ind16 &bitmap, const rectangle &cliprect, int whichtilemap ); |
| 148 | void rabbit_do_blit(); |
| 143 | 149 | }; |
| 144 | 150 | |
| 145 | 151 | |
| 146 | 152 | /* call with tilesize = 0 for 8x8 or 1 for 16x16 */ |
| 147 | | INLINE void get_rabbit_tilemap_info(running_machine &machine, tile_data &tileinfo, int tile_index, int whichtilemap, int tilesize) |
| 153 | void rabbit_state::get_rabbit_tilemap_info(tile_data &tileinfo, int tile_index, int whichtilemap, int tilesize) |
| 148 | 154 | { |
| 149 | | rabbit_state *state = machine.driver_data<rabbit_state>(); |
| 150 | 155 | /* fedcba98 76543210 fedcba98 76543210 |
| 151 | 156 | x color mask? how exactly does it relate to color bits? |
| 152 | 157 | xx flip |
| r21028 | r21029 | |
| 155 | 160 | xxxx bank |
| 156 | 161 | xxxxxxxx xxxxxxxx tile |
| 157 | 162 | */ |
| 158 | | int depth = (state->m_tilemap_ram[whichtilemap][tile_index]&0x10000000)>>28; |
| 159 | | int tileno = state->m_tilemap_ram[whichtilemap][tile_index]&0xffff; |
| 160 | | int bank = (state->m_tilemap_ram[whichtilemap][tile_index]&0x000f0000)>>16; |
| 161 | | int colour = (state->m_tilemap_ram[whichtilemap][tile_index]>>20)&0xff; |
| 162 | | int cmask = state->m_tilemap_ram[whichtilemap][tile_index]>>31&1; |
| 163 | | int flipxy = (state->m_tilemap_ram[whichtilemap][tile_index]>>29)&3; |
| 163 | int depth = (m_tilemap_ram[whichtilemap][tile_index]&0x10000000)>>28; |
| 164 | int tileno = m_tilemap_ram[whichtilemap][tile_index]&0xffff; |
| 165 | int bank = (m_tilemap_ram[whichtilemap][tile_index]&0x000f0000)>>16; |
| 166 | int colour = (m_tilemap_ram[whichtilemap][tile_index]>>20)&0xff; |
| 167 | int cmask = m_tilemap_ram[whichtilemap][tile_index]>>31&1; |
| 168 | int flipxy = (m_tilemap_ram[whichtilemap][tile_index]>>29)&3; |
| 164 | 169 | |
| 165 | | if (state->m_banking) |
| 170 | if (m_banking) |
| 166 | 171 | { |
| 167 | 172 | switch (bank) |
| 168 | 173 | { |
| r21028 | r21029 | |
| 193 | 198 | colour &= 0x0f; |
| 194 | 199 | colour += 0x20; |
| 195 | 200 | tileinfo.group = 1; |
| 196 | | SET_TILE_INFO(6+tilesize,tileno,colour,TILE_FLIPXY(flipxy)); |
| 201 | SET_TILE_INFO_MEMBER(6+tilesize,tileno,colour,TILE_FLIPXY(flipxy)); |
| 197 | 202 | } |
| 198 | 203 | else |
| 199 | 204 | { |
| r21028 | r21029 | |
| 201 | 206 | if (cmask) colour&=0x3f; // see health bars |
| 202 | 207 | colour += 0x200; |
| 203 | 208 | tileinfo.group = 0; |
| 204 | | SET_TILE_INFO(4+tilesize,tileno,colour,TILE_FLIPXY(flipxy)); |
| 209 | SET_TILE_INFO_MEMBER(4+tilesize,tileno,colour,TILE_FLIPXY(flipxy)); |
| 205 | 210 | } |
| 206 | 211 | } |
| 207 | 212 | |
| 208 | 213 | TILE_GET_INFO_MEMBER(rabbit_state::get_rabbit_tilemap0_tile_info) |
| 209 | 214 | { |
| 210 | | get_rabbit_tilemap_info(machine(),tileinfo,tile_index,0,1); |
| 215 | get_rabbit_tilemap_info(tileinfo,tile_index,0,1); |
| 211 | 216 | } |
| 212 | 217 | |
| 213 | 218 | TILE_GET_INFO_MEMBER(rabbit_state::get_rabbit_tilemap1_tile_info) |
| 214 | 219 | { |
| 215 | | get_rabbit_tilemap_info(machine(),tileinfo,tile_index,1,1); |
| 220 | get_rabbit_tilemap_info(tileinfo,tile_index,1,1); |
| 216 | 221 | } |
| 217 | 222 | |
| 218 | 223 | TILE_GET_INFO_MEMBER(rabbit_state::get_rabbit_tilemap2_tile_info) |
| 219 | 224 | { |
| 220 | | get_rabbit_tilemap_info(machine(),tileinfo,tile_index,2,1); |
| 225 | get_rabbit_tilemap_info(tileinfo,tile_index,2,1); |
| 221 | 226 | } |
| 222 | 227 | |
| 223 | 228 | TILE_GET_INFO_MEMBER(rabbit_state::get_rabbit_tilemap3_tile_info) |
| 224 | 229 | { |
| 225 | | get_rabbit_tilemap_info(machine(),tileinfo,tile_index,3,0); |
| 230 | get_rabbit_tilemap_info(tileinfo,tile_index,3,0); |
| 226 | 231 | } |
| 227 | 232 | |
| 228 | 233 | WRITE32_MEMBER(rabbit_state::rabbit_tilemap0_w) |
| r21028 | r21029 | |
| 269 | 274 | |
| 270 | 275 | */ |
| 271 | 276 | |
| 272 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 277 | void rabbit_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 273 | 278 | { |
| 274 | | rabbit_state *state = machine.driver_data<rabbit_state>(); |
| 275 | 279 | int xpos,ypos,tileno,xflip,yflip, colr; |
| 276 | | gfx_element *gfx = machine.gfx[1]; |
| 277 | | int todraw = (state->m_spriteregs[5]&0x0fff0000)>>16; // how many sprites to draw (start/end reg..) what is the other half? |
| 280 | gfx_element *gfx = machine().gfx[1]; |
| 281 | int todraw = (m_spriteregs[5]&0x0fff0000)>>16; // how many sprites to draw (start/end reg..) what is the other half? |
| 278 | 282 | |
| 279 | | UINT32 *source = (state->m_spriteram+ (todraw*2))-2; |
| 280 | | UINT32 *finish = state->m_spriteram; |
| 283 | UINT32 *source = (m_spriteram+ (todraw*2))-2; |
| 284 | UINT32 *finish = m_spriteram; |
| 281 | 285 | |
| 282 | | // state->m_sprite_bitmap->fill(0x0, state->m_sprite_clip); // sloooow |
| 286 | // m_sprite_bitmap->fill(0x0, m_sprite_clip); // sloooow |
| 283 | 287 | |
| 284 | 288 | while( source>=finish ) |
| 285 | 289 | { |
| r21028 | r21029 | |
| 296 | 300 | |
| 297 | 301 | if(xpos&0x800)xpos-=0x1000; |
| 298 | 302 | |
| 299 | | drawgfx_transpen(*state->m_sprite_bitmap,state->m_sprite_clip,gfx,tileno,colr,!xflip/*wrongdecode?*/,yflip,xpos+0x20-8/*-(state->m_spriteregs[0]&0x00000fff)*/,ypos-24/*-((state->m_spriteregs[1]&0x0fff0000)>>16)*/,15); |
| 300 | | // drawgfx_transpen(bitmap,cliprect,gfx,tileno,colr,!xflip/*wrongdecode?*/,yflip,xpos+0xa0-8/*-(state->m_spriteregs[0]&0x00000fff)*/,ypos-24+0x80/*-((state->m_spriteregs[1]&0x0fff0000)>>16)*/,0); |
| 303 | drawgfx_transpen(*m_sprite_bitmap,m_sprite_clip,gfx,tileno,colr,!xflip/*wrongdecode?*/,yflip,xpos+0x20-8/*-(m_spriteregs[0]&0x00000fff)*/,ypos-24/*-((m_spriteregs[1]&0x0fff0000)>>16)*/,15); |
| 304 | // drawgfx_transpen(bitmap,cliprect,gfx,tileno,colr,!xflip/*wrongdecode?*/,yflip,xpos+0xa0-8/*-(m_spriteregs[0]&0x00000fff)*/,ypos-24+0x80/*-((m_spriteregs[1]&0x0fff0000)>>16)*/,0); |
| 301 | 305 | |
| 302 | 306 | |
| 303 | 307 | source-=2; |
| r21028 | r21029 | |
| 307 | 311 | } |
| 308 | 312 | |
| 309 | 313 | /* the sprite bitmap can probably be handled better than this ... */ |
| 310 | | static void rabbit_clearspritebitmap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 314 | void rabbit_state::rabbit_clearspritebitmap( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 311 | 315 | { |
| 312 | | rabbit_state *state = machine.driver_data<rabbit_state>(); |
| 313 | 316 | int startx, starty; |
| 314 | 317 | int y; |
| 315 | 318 | int amountx,amounty; |
| 316 | 319 | UINT16 *dstline; |
| 317 | 320 | |
| 318 | 321 | /* clears a *sensible* amount of the sprite bitmap */ |
| 319 | | startx = (state->m_spriteregs[0]&0x00000fff); |
| 320 | | starty = (state->m_spriteregs[1]&0x0fff0000)>>16; |
| 322 | startx = (m_spriteregs[0]&0x00000fff); |
| 323 | starty = (m_spriteregs[1]&0x0fff0000)>>16; |
| 321 | 324 | |
| 322 | 325 | startx-=200; |
| 323 | 326 | starty-=200; |
| r21028 | r21029 | |
| 329 | 332 | |
| 330 | 333 | for (y=0; y<amounty;y++) |
| 331 | 334 | { |
| 332 | | dstline = &state->m_sprite_bitmap->pix16((starty+y)&0xfff); |
| 335 | dstline = &m_sprite_bitmap->pix16((starty+y)&0xfff); |
| 333 | 336 | memset(dstline+startx,0x00,amountx*2); |
| 334 | 337 | } |
| 335 | 338 | } |
| 336 | 339 | |
| 337 | 340 | /* todo: fix zoom, its inaccurate and this code is ugly */ |
| 338 | | static void draw_sprite_bitmap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 341 | void rabbit_state::draw_sprite_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 339 | 342 | { |
| 340 | | rabbit_state *state = machine.driver_data<rabbit_state>(); |
| 341 | 343 | |
| 342 | 344 | UINT32 x,y; |
| 343 | 345 | UINT16 *srcline; |
| r21028 | r21029 | |
| 348 | 350 | UINT32 xstep,ystep; |
| 349 | 351 | |
| 350 | 352 | int startx, starty; |
| 351 | | startx = ((state->m_spriteregs[0]&0x00000fff)); |
| 352 | | starty = ((state->m_spriteregs[1]&0x0fff0000)>>16); |
| 353 | startx = ((m_spriteregs[0]&0x00000fff)); |
| 354 | starty = ((m_spriteregs[1]&0x0fff0000)>>16); |
| 353 | 355 | |
| 354 | 356 | /* zoom compensation? */ |
| 355 | | startx-=((state->m_spriteregs[1]&0x000001ff)>>1); |
| 356 | | starty-=((state->m_spriteregs[1]&0x000001ff)>>1); |
| 357 | startx-=((m_spriteregs[1]&0x000001ff)>>1); |
| 358 | starty-=((m_spriteregs[1]&0x000001ff)>>1); |
| 357 | 359 | |
| 358 | 360 | |
| 359 | | xsize = ((state->m_spriteregs[2]&0x0000ffff)); |
| 360 | | ysize = ((state->m_spriteregs[3]&0x0000ffff)); |
| 361 | xsize = ((m_spriteregs[2]&0x0000ffff)); |
| 362 | ysize = ((m_spriteregs[3]&0x0000ffff)); |
| 361 | 363 | xsize+=0x80; |
| 362 | 364 | ysize+=0x80; |
| 363 | 365 | xstep = ((320*128)<<16) / xsize; |
| r21028 | r21029 | |
| 370 | 372 | |
| 371 | 373 | if ((ydrawpos >= cliprect.min_y) && (ydrawpos <= cliprect.max_y)) |
| 372 | 374 | { |
| 373 | | srcline = &state->m_sprite_bitmap->pix16((starty+(y>>7))&0xfff); |
| 375 | srcline = &m_sprite_bitmap->pix16((starty+(y>>7))&0xfff); |
| 374 | 376 | dstline = &bitmap.pix16(ydrawpos); |
| 375 | 377 | |
| 376 | 378 | for (x=0;x<xsize;x+=0x80) |
| r21028 | r21029 | |
| 439 | 441 | |
| 440 | 442 | */ |
| 441 | 443 | |
| 442 | | static void rabbit_drawtilemap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int whichtilemap ) |
| 444 | void rabbit_state::rabbit_drawtilemap( bitmap_ind16 &bitmap, const rectangle &cliprect, int whichtilemap ) |
| 443 | 445 | { |
| 444 | | rabbit_state *state = machine.driver_data<rabbit_state>(); |
| 445 | 446 | INT32 startx, starty, incxx, incxy, incyx, incyy, tran; |
| 446 | 447 | |
| 447 | | startx=((state->m_tilemap_regs[whichtilemap][1]&0x0000ffff)); // >>4 for nonzoomed pixel scroll value |
| 448 | | starty=((state->m_tilemap_regs[whichtilemap][1]&0xffff0000)>>16); // >> 20 for nonzoomed pixel scroll value |
| 449 | | incxx= ((state->m_tilemap_regs[whichtilemap][3]&0x00000fff)); // 0x800 when non-zoomed |
| 450 | | incyy= ((state->m_tilemap_regs[whichtilemap][4]&0x0fff0000)>>16); |
| 448 | startx=((m_tilemap_regs[whichtilemap][1]&0x0000ffff)); // >>4 for nonzoomed pixel scroll value |
| 449 | starty=((m_tilemap_regs[whichtilemap][1]&0xffff0000)>>16); // >> 20 for nonzoomed pixel scroll value |
| 450 | incxx= ((m_tilemap_regs[whichtilemap][3]&0x00000fff)); // 0x800 when non-zoomed |
| 451 | incyy= ((m_tilemap_regs[whichtilemap][4]&0x0fff0000)>>16); |
| 451 | 452 | |
| 452 | 453 | incxy = 0; incyx = 0; |
| 453 | 454 | tran = 1; |
| r21028 | r21029 | |
| 457 | 458 | startx/starty are also 16.16 scrolling |
| 458 | 459 | */ |
| 459 | 460 | |
| 460 | | state->m_tilemap[whichtilemap]->draw_roz(bitmap, cliprect, startx << 12,starty << 12, |
| 461 | m_tilemap[whichtilemap]->draw_roz(bitmap, cliprect, startx << 12,starty << 12, |
| 461 | 462 | incxx << 5,incxy << 8,incyx << 8,incyy << 5, |
| 462 | 463 | 1, /* wraparound */ |
| 463 | 464 | tran ? 0 : TILEMAP_DRAW_OPAQUE,0); |
| r21028 | r21029 | |
| 485 | 486 | /* prio isnt certain but seems to work.. */ |
| 486 | 487 | for (prilevel = 0xf; prilevel >0; prilevel--) |
| 487 | 488 | { |
| 488 | | if (prilevel == ((m_tilemap_regs[3][0]&0x0f000000)>>24)) rabbit_drawtilemap(machine(),bitmap,cliprect, 3); |
| 489 | | if (prilevel == ((m_tilemap_regs[2][0]&0x0f000000)>>24)) rabbit_drawtilemap(machine(),bitmap,cliprect, 2); |
| 490 | | if (prilevel == ((m_tilemap_regs[1][0]&0x0f000000)>>24)) rabbit_drawtilemap(machine(),bitmap,cliprect, 1); |
| 491 | | if (prilevel == ((m_tilemap_regs[0][0]&0x0f000000)>>24)) rabbit_drawtilemap(machine(),bitmap,cliprect, 0); |
| 489 | if (prilevel == ((m_tilemap_regs[3][0]&0x0f000000)>>24)) rabbit_drawtilemap(bitmap,cliprect, 3); |
| 490 | if (prilevel == ((m_tilemap_regs[2][0]&0x0f000000)>>24)) rabbit_drawtilemap(bitmap,cliprect, 2); |
| 491 | if (prilevel == ((m_tilemap_regs[1][0]&0x0f000000)>>24)) rabbit_drawtilemap(bitmap,cliprect, 1); |
| 492 | if (prilevel == ((m_tilemap_regs[0][0]&0x0f000000)>>24)) rabbit_drawtilemap(bitmap,cliprect, 0); |
| 492 | 493 | |
| 493 | 494 | if (prilevel == 0x09) // should it be selectable? |
| 494 | 495 | { |
| 495 | | rabbit_clearspritebitmap(machine(),bitmap,cliprect); |
| 496 | | draw_sprites(machine(),bitmap,cliprect); // render to bitmap |
| 497 | | draw_sprite_bitmap(machine(),bitmap,cliprect); // copy bitmap to screen |
| 496 | rabbit_clearspritebitmap(bitmap,cliprect); |
| 497 | draw_sprites(bitmap,cliprect); // render to bitmap |
| 498 | draw_sprite_bitmap(bitmap,cliprect); // copy bitmap to screen |
| 498 | 499 | } |
| 499 | 500 | } |
| 500 | 501 | return 0; |
| r21028 | r21029 | |
| 563 | 564 | machine().device("maincpu")->execute().set_input_line(m_bltirqlevel, HOLD_LINE); |
| 564 | 565 | } |
| 565 | 566 | |
| 566 | | static void rabbit_do_blit(running_machine &machine) |
| 567 | void rabbit_state::rabbit_do_blit() |
| 567 | 568 | { |
| 568 | | rabbit_state *state = machine.driver_data<rabbit_state>(); |
| 569 | | UINT8 *blt_data = state->memregion("gfx1")->base(); |
| 570 | | int blt_source = (state->m_blitterregs[0]&0x000fffff)>>0; |
| 571 | | int blt_column = (state->m_blitterregs[1]&0x00ff0000)>>16; |
| 572 | | int blt_line = (state->m_blitterregs[1]&0x000000ff); |
| 573 | | int blt_tilemp = (state->m_blitterregs[2]&0x0000e000)>>13; |
| 574 | | int blt_oddflg = (state->m_blitterregs[2]&0x00000001)>>0; |
| 569 | UINT8 *blt_data = memregion("gfx1")->base(); |
| 570 | int blt_source = (m_blitterregs[0]&0x000fffff)>>0; |
| 571 | int blt_column = (m_blitterregs[1]&0x00ff0000)>>16; |
| 572 | int blt_line = (m_blitterregs[1]&0x000000ff); |
| 573 | int blt_tilemp = (m_blitterregs[2]&0x0000e000)>>13; |
| 574 | int blt_oddflg = (m_blitterregs[2]&0x00000001)>>0; |
| 575 | 575 | int mask,shift; |
| 576 | 576 | |
| 577 | 577 | |
| 578 | | if(BLITCMDLOG) mame_printf_debug("BLIT command %08x %08x %08x\n", state->m_blitterregs[0], state->m_blitterregs[1], state->m_blitterregs[2]); |
| 578 | if(BLITCMDLOG) mame_printf_debug("BLIT command %08x %08x %08x\n", m_blitterregs[0], m_blitterregs[1], m_blitterregs[2]); |
| 579 | 579 | |
| 580 | 580 | if (blt_oddflg&1) |
| 581 | 581 | { |
| r21028 | r21029 | |
| 608 | 608 | if (!blt_amount) |
| 609 | 609 | { |
| 610 | 610 | if(BLITLOG) mame_printf_debug("end of blit list\n"); |
| 611 | | machine.scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(rabbit_state::rabbit_blit_done),state)); |
| 611 | machine().scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(rabbit_state::rabbit_blit_done),this)); |
| 612 | 612 | return; |
| 613 | 613 | } |
| 614 | 614 | |
| r21028 | r21029 | |
| 618 | 618 | blt_value = ((blt_data[blt_source+1]<<8)|(blt_data[blt_source+0])); |
| 619 | 619 | blt_source+=2; |
| 620 | 620 | writeoffs=blt_oddflg+blt_column; |
| 621 | | state->m_tilemap_ram[blt_tilemp][writeoffs]=(state->m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 622 | | state->m_tilemap[blt_tilemp]->mark_tile_dirty(writeoffs); |
| 621 | m_tilemap_ram[blt_tilemp][writeoffs]=(m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 622 | m_tilemap[blt_tilemp]->mark_tile_dirty(writeoffs); |
| 623 | 623 | |
| 624 | 624 | blt_column++; |
| 625 | 625 | blt_column&=0x7f; |
| r21028 | r21029 | |
| 635 | 635 | for (loopcount=0;loopcount<blt_amount;loopcount++) |
| 636 | 636 | { |
| 637 | 637 | writeoffs=blt_oddflg+blt_column; |
| 638 | | state->m_tilemap_ram[blt_tilemp][writeoffs]=(state->m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 639 | | state->m_tilemap[blt_tilemp]->mark_tile_dirty(writeoffs); |
| 638 | m_tilemap_ram[blt_tilemp][writeoffs]=(m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 639 | m_tilemap[blt_tilemp]->mark_tile_dirty(writeoffs); |
| 640 | 640 | blt_column++; |
| 641 | 641 | blt_column&=0x7f; |
| 642 | 642 | } |
| r21028 | r21029 | |
| 645 | 645 | |
| 646 | 646 | case 0x03: /* next line */ |
| 647 | 647 | if(BLITLOG) mame_printf_debug("blit: move to next line\n"); |
| 648 | | blt_column = (state->m_blitterregs[1]&0x00ff0000)>>16; /* --CC---- */ |
| 648 | blt_column = (m_blitterregs[1]&0x00ff0000)>>16; /* --CC---- */ |
| 649 | 649 | blt_oddflg+=128; |
| 650 | 650 | break; |
| 651 | 651 | |
| r21028 | r21029 | |
| 665 | 665 | |
| 666 | 666 | if (offset == 0x0c/4) |
| 667 | 667 | { |
| 668 | | rabbit_do_blit(machine()); |
| 668 | rabbit_do_blit(); |
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | |
trunk/src/mame/drivers/crystal.c
| r21028 | r21029 | |
| 196 | 196 | TIMER_CALLBACK_MEMBER(Timercb); |
| 197 | 197 | IRQ_CALLBACK_MEMBER(icallback); |
| 198 | 198 | void crystal_banksw_postload(); |
| 199 | void IntReq( int num ); |
| 200 | inline void Timer_w( address_space &space, int which, UINT32 data, UINT32 mem_mask ); |
| 201 | inline void DMA_w( address_space &space, int which, UINT32 data, UINT32 mem_mask ); |
| 202 | void PatchReset( ); |
| 203 | UINT16 GetVidReg( address_space &space, UINT16 reg ); |
| 204 | void SetVidReg( address_space &space, UINT16 reg, UINT16 val ); |
| 199 | 205 | }; |
| 200 | 206 | |
| 201 | | static void IntReq( running_machine &machine, int num ) |
| 207 | void crystal_state::IntReq( int num ) |
| 202 | 208 | { |
| 203 | | crystal_state *state = machine.driver_data<crystal_state>(); |
| 204 | | address_space &space = state->m_maincpu->space(AS_PROGRAM); |
| 209 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 205 | 210 | UINT32 IntEn = space.read_dword(0x01800c08); |
| 206 | 211 | UINT32 IntPend = space.read_dword(0x01800c0c); |
| 207 | 212 | if (IntEn & (1 << num)) |
| 208 | 213 | { |
| 209 | 214 | IntPend |= (1 << num); |
| 210 | 215 | space.write_dword(0x01800c0c, IntPend); |
| 211 | | state->m_maincpu->set_input_line(SE3208_INT, ASSERT_LINE); |
| 216 | m_maincpu->set_input_line(SE3208_INT, ASSERT_LINE); |
| 212 | 217 | } |
| 213 | 218 | #ifdef IDLE_LOOP_SPEEDUP |
| 214 | | state->m_FlipCntRead = 0; |
| 215 | | state->m_maincpu->resume(SUSPEND_REASON_SPIN); |
| 219 | m_FlipCntRead = 0; |
| 220 | m_maincpu->resume(SUSPEND_REASON_SPIN); |
| 216 | 221 | #endif |
| 217 | 222 | } |
| 218 | 223 | |
| r21028 | r21029 | |
| 249 | 254 | { |
| 250 | 255 | UINT8 Port4 = ioport("SYSTEM")->read(); |
| 251 | 256 | if (!(Port4 & 0x10) && ((m_OldPort4 ^ Port4) & 0x10)) //coin buttons trigger IRQs |
| 252 | | IntReq(machine(), 12); |
| 257 | IntReq(12); |
| 253 | 258 | if (!(Port4 & 0x20) && ((m_OldPort4 ^ Port4) & 0x20)) |
| 254 | | IntReq(machine(), 19); |
| 259 | IntReq(19); |
| 255 | 260 | m_OldPort4 = Port4; |
| 256 | 261 | return /*dips*/ioport("DSW")->read() | (Port4 << 16); |
| 257 | 262 | } |
| r21028 | r21029 | |
| 306 | 311 | if (!(m_Timerctrl[which] & 2)) |
| 307 | 312 | m_Timerctrl[which] &= ~1; |
| 308 | 313 | |
| 309 | | IntReq(machine(), num[which]); |
| 314 | IntReq(num[which]); |
| 310 | 315 | } |
| 311 | 316 | |
| 312 | | INLINE void Timer_w( address_space &space, int which, UINT32 data, UINT32 mem_mask ) |
| 317 | void crystal_state::Timer_w( address_space &space, int which, UINT32 data, UINT32 mem_mask ) |
| 313 | 318 | { |
| 314 | | crystal_state *state = space.machine().driver_data<crystal_state>(); |
| 315 | | |
| 316 | | if (((data ^ state->m_Timerctrl[which]) & 1) && (data & 1)) //Timer activate |
| 319 | if (((data ^ m_Timerctrl[which]) & 1) && (data & 1)) //Timer activate |
| 317 | 320 | { |
| 318 | 321 | int PD = (data >> 8) & 0xff; |
| 319 | 322 | int TCV = space.read_dword(0x01801404 + which * 8); |
| 320 | 323 | attotime period = attotime::from_hz(43000000) * ((PD + 1) * (TCV + 1)); |
| 321 | 324 | |
| 322 | | if (state->m_Timerctrl[which] & 2) |
| 323 | | state->m_Timer[which]->adjust(period, 0, period); |
| 325 | if (m_Timerctrl[which] & 2) |
| 326 | m_Timer[which]->adjust(period, 0, period); |
| 324 | 327 | else |
| 325 | | state->m_Timer[which]->adjust(period); |
| 328 | m_Timer[which]->adjust(period); |
| 326 | 329 | } |
| 327 | | COMBINE_DATA(&state->m_Timerctrl[which]); |
| 330 | COMBINE_DATA(&m_Timerctrl[which]); |
| 328 | 331 | } |
| 329 | 332 | |
| 330 | 333 | WRITE32_MEMBER(crystal_state::Timer0_w) |
| r21028 | r21029 | |
| 417 | 420 | COMBINE_DATA(&m_PIO); |
| 418 | 421 | } |
| 419 | 422 | |
| 420 | | INLINE void DMA_w( address_space &space, int which, UINT32 data, UINT32 mem_mask ) |
| 423 | void crystal_state::DMA_w( address_space &space, int which, UINT32 data, UINT32 mem_mask ) |
| 421 | 424 | { |
| 422 | | crystal_state *state = space.machine().driver_data<crystal_state>(); |
| 423 | | |
| 424 | | if (((data ^ state->m_DMActrl[which]) & (1 << 10)) && (data & (1 << 10))) //DMAOn |
| 425 | if (((data ^ m_DMActrl[which]) & (1 << 10)) && (data & (1 << 10))) //DMAOn |
| 425 | 426 | { |
| 426 | 427 | UINT32 CTR = data; |
| 427 | 428 | UINT32 SRC = space.read_dword(0x01800804 + which * 0x10); |
| r21028 | r21029 | |
| 455 | 456 | } |
| 456 | 457 | data &= ~(1 << 10); |
| 457 | 458 | space.write_dword(0x0180080C + which * 0x10, 0); |
| 458 | | IntReq(space.machine(), 7 + which); |
| 459 | IntReq(7 + which); |
| 459 | 460 | } |
| 460 | | COMBINE_DATA(&state->m_DMActrl[which]); |
| 461 | COMBINE_DATA(&m_DMActrl[which]); |
| 461 | 462 | } |
| 462 | 463 | |
| 463 | 464 | READ32_MEMBER(crystal_state::DMA0_r) |
| r21028 | r21029 | |
| 515 | 516 | |
| 516 | 517 | ADDRESS_MAP_END |
| 517 | 518 | |
| 518 | | static void PatchReset( running_machine &machine ) |
| 519 | void crystal_state::PatchReset( ) |
| 519 | 520 | { |
| 520 | 521 | //The test menu reset routine seems buggy |
| 521 | 522 | //it reads the reset vector from 0x02000000 but it should be |
| r21028 | r21029 | |
| 539 | 540 | JMP Loop1 |
| 540 | 541 | */ |
| 541 | 542 | |
| 542 | | crystal_state *state = machine.driver_data<crystal_state>(); |
| 543 | 543 | |
| 544 | 544 | #if 1 |
| 545 | 545 | static const UINT32 Patch[] = |
| r21028 | r21029 | |
| 552 | 552 | 0xdef4d4fa |
| 553 | 553 | }; |
| 554 | 554 | |
| 555 | | memcpy(state->m_reset_patch, Patch, sizeof(Patch)); |
| 555 | memcpy(m_reset_patch, Patch, sizeof(Patch)); |
| 556 | 556 | #else |
| 557 | 557 | static const UINT8 Patch[] = |
| 558 | 558 | { |
| r21028 | r21029 | |
| 561 | 561 | 0x20,0x3A,0xD0,0xA1,0xFA,0xD4,0xF4,0xDE |
| 562 | 562 | }; |
| 563 | 563 | |
| 564 | | memcpy(state->m_reset_patch, Patch, sizeof(Patch)); |
| 564 | memcpy(m_reset_patch, Patch, sizeof(Patch)); |
| 565 | 565 | #endif |
| 566 | 566 | } |
| 567 | 567 | |
| r21028 | r21029 | |
| 585 | 585 | for (i = 0; i < 4; i++) |
| 586 | 586 | m_Timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(crystal_state::Timercb),this), (void*)(FPTR)i); |
| 587 | 587 | |
| 588 | | PatchReset(machine()); |
| 588 | PatchReset(); |
| 589 | 589 | |
| 590 | 590 | #ifdef IDLE_LOOP_SPEEDUP |
| 591 | 591 | save_item(NAME(m_FlipCntRead)); |
| r21028 | r21029 | |
| 630 | 630 | m_FlipCntRead = 0; |
| 631 | 631 | #endif |
| 632 | 632 | |
| 633 | | PatchReset(machine()); |
| 633 | PatchReset(); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | | static UINT16 GetVidReg( address_space &space, UINT16 reg ) |
| 636 | UINT16 crystal_state::GetVidReg( address_space &space, UINT16 reg ) |
| 637 | 637 | { |
| 638 | 638 | return space.read_word(0x03000000 + reg); |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | | static void SetVidReg( address_space &space, UINT16 reg, UINT16 val ) |
| 641 | void crystal_state::SetVidReg( address_space &space, UINT16 reg, UINT16 val ) |
| 642 | 642 | { |
| 643 | 643 | space.write_word(0x03000000 + reg, val); |
| 644 | 644 | } |
| r21028 | r21029 | |
| 739 | 739 | |
| 740 | 740 | INTERRUPT_GEN_MEMBER(crystal_state::crystal_interrupt) |
| 741 | 741 | { |
| 742 | | IntReq(machine(), 24); //VRender0 VBlank |
| 742 | IntReq(24); //VRender0 VBlank |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | static INPUT_PORTS_START(crystal) |
trunk/src/mame/drivers/tmmjprd.c
| r21028 | r21029 | |
| 71 | 71 | UINT32 screen_update_tmmjprd_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 72 | 72 | TIMER_CALLBACK_MEMBER(tmmjprd_blit_done); |
| 73 | 73 | TIMER_DEVICE_CALLBACK_MEMBER(tmmjprd_scanline); |
| 74 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int screen); |
| 75 | void ttmjprd_draw_tile(bitmap_ind16 &bitmap, const rectangle &cliprect, int x,int y,int sizex,int sizey, UINT32 tiledata, UINT8* rom); |
| 76 | void ttmjprd_draw_tilemap(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32*tileram, UINT32*tileregs, UINT8*rom ); |
| 77 | void tmmjprd_do_blit(); |
| 74 | 78 | }; |
| 75 | 79 | |
| 76 | 80 | |
| r21028 | r21029 | |
| 96 | 100 | COMBINE_DATA(&m_tilemap_ram[3][offset]); |
| 97 | 101 | } |
| 98 | 102 | |
| 99 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int screen) |
| 103 | void tmmjprd_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int screen) |
| 100 | 104 | { |
| 101 | | tmmjprd_state *state = machine.driver_data<tmmjprd_state>(); |
| 102 | 105 | int xpos,ypos,tileno,xflip,yflip, colr; |
| 103 | | gfx_element *gfx = machine.gfx[0]; |
| 106 | gfx_element *gfx = machine().gfx[0]; |
| 104 | 107 | int xoffs; |
| 105 | | // int todraw = (state->m_spriteregs[5]&0x0fff0000)>>16; // how many sprites to draw (start/end reg..) what is the other half? |
| 108 | // int todraw = (m_spriteregs[5]&0x0fff0000)>>16; // how many sprites to draw (start/end reg..) what is the other half? |
| 106 | 109 | |
| 107 | | // UINT32 *source = (state->m_spriteram+ (todraw*2))-2; |
| 108 | | // UINT32 *finish = state->m_spriteram; |
| 110 | // UINT32 *source = (m_spriteram+ (todraw*2))-2; |
| 111 | // UINT32 *finish = m_spriteram; |
| 109 | 112 | |
| 110 | | UINT32 *source = state->m_spriteram+(0xc000/4)-2; |
| 111 | | UINT32 *finish = state->m_spriteram; |
| 113 | UINT32 *source = m_spriteram+(0xc000/4)-2; |
| 114 | UINT32 *finish = m_spriteram; |
| 112 | 115 | xoffs = (screen & 1)*320; |
| 113 | 116 | |
| 114 | 117 | for(;source>finish;source-=2) |
| r21028 | r21029 | |
| 173 | 176 | } |
| 174 | 177 | } |
| 175 | 178 | |
| 176 | | static void ttmjprd_draw_tile(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int x,int y,int sizex,int sizey, UINT32 tiledata, UINT8* rom) |
| 179 | void tmmjprd_state::ttmjprd_draw_tile(bitmap_ind16 &bitmap, const rectangle &cliprect, int x,int y,int sizex,int sizey, UINT32 tiledata, UINT8* rom) |
| 177 | 180 | { |
| 178 | 181 | /* note, it's tile address _NOT_ tile number, 'sub-tile' access is possible, hence using the custom rendering */ |
| 179 | 182 | int tileaddr = (tiledata&0x000fffff)>>0; |
| r21028 | r21029 | |
| 252 | 255 | } |
| 253 | 256 | } |
| 254 | 257 | |
| 255 | | static void ttmjprd_draw_tilemap(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32*tileram, UINT32*tileregs, UINT8*rom ) |
| 258 | void tmmjprd_state::ttmjprd_draw_tilemap(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32*tileram, UINT32*tileregs, UINT8*rom ) |
| 256 | 259 | { |
| 257 | 260 | int y,x; |
| 258 | 261 | int count; |
| r21028 | r21029 | |
| 286 | 289 | { |
| 287 | 290 | UINT32 tiledata = tileram[count]; |
| 288 | 291 | // todo: handle wraparound |
| 289 | | ttmjprd_draw_tile(machine,bitmap,cliprect,(x*tile_sizex)-scrollx,(y*tile_sizey)-scrolly,tile_sizex,tile_sizey, tiledata, rom); |
| 292 | ttmjprd_draw_tile(bitmap,cliprect,(x*tile_sizex)-scrollx,(y*tile_sizey)-scrolly,tile_sizex,tile_sizey, tiledata, rom); |
| 290 | 293 | count++; |
| 291 | 294 | } |
| 292 | 295 | } |
| r21028 | r21029 | |
| 299 | 302 | |
| 300 | 303 | bitmap.fill(get_black_pen(machine()), cliprect); |
| 301 | 304 | |
| 302 | | ttmjprd_draw_tilemap( machine(), bitmap, cliprect, m_tilemap_ram[3], m_tilemap_regs[3], gfxroms ); |
| 303 | | draw_sprites(machine(),bitmap,cliprect, 1); |
| 304 | | ttmjprd_draw_tilemap( machine(), bitmap, cliprect, m_tilemap_ram[2], m_tilemap_regs[2], gfxroms ); |
| 305 | ttmjprd_draw_tilemap(bitmap, cliprect, m_tilemap_ram[3], m_tilemap_regs[3], gfxroms ); |
| 306 | draw_sprites(bitmap,cliprect, 1); |
| 307 | ttmjprd_draw_tilemap(bitmap, cliprect, m_tilemap_ram[2], m_tilemap_regs[2], gfxroms ); |
| 305 | 308 | |
| 306 | 309 | /* |
| 307 | 310 | popmessage("%08x %08x %08x %08x %08x %08x", |
| r21028 | r21029 | |
| 333 | 336 | |
| 334 | 337 | bitmap.fill(get_black_pen(machine()), cliprect); |
| 335 | 338 | |
| 336 | | ttmjprd_draw_tilemap( machine(), bitmap, cliprect, m_tilemap_ram[1], m_tilemap_regs[1], gfxroms ); |
| 337 | | draw_sprites(machine(),bitmap,cliprect, 0); |
| 338 | | ttmjprd_draw_tilemap( machine(), bitmap, cliprect, m_tilemap_ram[0], m_tilemap_regs[0], gfxroms ); |
| 339 | ttmjprd_draw_tilemap(bitmap, cliprect, m_tilemap_ram[1], m_tilemap_regs[1], gfxroms ); |
| 340 | draw_sprites(bitmap,cliprect, 0); |
| 341 | ttmjprd_draw_tilemap(bitmap, cliprect, m_tilemap_ram[0], m_tilemap_regs[0], gfxroms ); |
| 339 | 342 | |
| 340 | 343 | return 0; |
| 341 | 344 | } |
| r21028 | r21029 | |
| 385 | 388 | machine().device("maincpu")->execute().set_input_line(3, HOLD_LINE); |
| 386 | 389 | } |
| 387 | 390 | |
| 388 | | static void tmmjprd_do_blit(running_machine &machine) |
| 391 | void tmmjprd_state::tmmjprd_do_blit() |
| 389 | 392 | { |
| 390 | | tmmjprd_state *state = machine.driver_data<tmmjprd_state>(); |
| 391 | | UINT8 *blt_data = state->memregion("gfx1")->base(); |
| 393 | UINT8 *blt_data = memregion("gfx1")->base(); |
| 392 | 394 | int blt_source = (tmmjprd_blitterregs[0]&0x000fffff)>>0; |
| 393 | 395 | int blt_column = (tmmjprd_blitterregs[1]&0x00ff0000)>>16; |
| 394 | 396 | int blt_line = (tmmjprd_blitterregs[1]&0x000000ff); |
| r21028 | r21029 | |
| 430 | 432 | if (!blt_amount) |
| 431 | 433 | { |
| 432 | 434 | if(BLITLOG) mame_printf_debug("end of blit list\n"); |
| 433 | | machine.scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(tmmjprd_state::tmmjprd_blit_done),this)); |
| 435 | machine().scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(tmmjprd_state::tmmjprd_blit_done),this)); |
| 434 | 436 | return; |
| 435 | 437 | } |
| 436 | 438 | |
| r21028 | r21029 | |
| 440 | 442 | blt_value = ((blt_data[blt_source+1]<<8)|(blt_data[blt_source+0])); |
| 441 | 443 | blt_source+=2; |
| 442 | 444 | writeoffs=blt_oddflg+blt_column; |
| 443 | | state->m_tilemap_ram[blt_tilemp][writeoffs]=(state->m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 445 | m_tilemap_ram[blt_tilemp][writeoffs]=(m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 444 | 446 | tmmjprd_tilemap[blt_tilemp]->mark_tile_dirty(writeoffs); |
| 445 | 447 | |
| 446 | 448 | blt_column++; |
| r21028 | r21029 | |
| 457 | 459 | for (loopcount=0;loopcount<blt_amount;loopcount++) |
| 458 | 460 | { |
| 459 | 461 | writeoffs=blt_oddflg+blt_column; |
| 460 | | state->m_tilemap_ram[blt_tilemp][writeoffs]=(state->m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 462 | m_tilemap_ram[blt_tilemp][writeoffs]=(m_tilemap_ram[blt_tilemp][writeoffs]&mask)|(blt_value<<shift); |
| 461 | 463 | tmmjprd_tilemap[blt_tilemp]->mark_tile_dirty(writeoffs); |
| 462 | 464 | blt_column++; |
| 463 | 465 | blt_column&=0x7f; |
trunk/src/mame/drivers/witch.c
| r21028 | r21029 | |
| 270 | 270 | UINT32 screen_update_witch(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 271 | 271 | INTERRUPT_GEN_MEMBER(witch_main_interrupt); |
| 272 | 272 | INTERRUPT_GEN_MEMBER(witch_sub_interrupt); |
| 273 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 273 | 274 | }; |
| 274 | 275 | |
| 275 | 276 | |
| r21028 | r21029 | |
| 757 | 758 | m_gfx1_tilemap->set_palette_offset(0x200); |
| 758 | 759 | } |
| 759 | 760 | |
| 760 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 761 | void witch_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 761 | 762 | { |
| 762 | | witch_state *state = machine.driver_data<witch_state>(); |
| 763 | 763 | int i,sx,sy,tileno,flags,color; |
| 764 | 764 | int flipx=0; |
| 765 | 765 | int flipy=0; |
| 766 | 766 | |
| 767 | 767 | for(i=0;i<0x800;i+=0x20) { |
| 768 | | sx = state->m_sprite_ram[i+1]; |
| 768 | sx = m_sprite_ram[i+1]; |
| 769 | 769 | if(sx!=0xF8) { |
| 770 | | tileno = (state->m_sprite_ram[i]<<2) | (( state->m_sprite_ram[i+0x800] & 0x07 ) << 10 ); |
| 770 | tileno = (m_sprite_ram[i]<<2) | (( m_sprite_ram[i+0x800] & 0x07 ) << 10 ); |
| 771 | 771 | |
| 772 | | sy = state->m_sprite_ram[i+2]; |
| 773 | | flags = state->m_sprite_ram[i+3]; |
| 772 | sy = m_sprite_ram[i+2]; |
| 773 | flags = m_sprite_ram[i+3]; |
| 774 | 774 | |
| 775 | 775 | flipx = (flags & 0x10 ) ? 1 : 0; |
| 776 | 776 | flipy = (flags & 0x20 ) ? 1 : 0; |
| r21028 | r21029 | |
| 778 | 778 | color = flags & 0x0f; |
| 779 | 779 | |
| 780 | 780 | |
| 781 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 781 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 782 | 782 | tileno, color, |
| 783 | 783 | flipx, flipy, |
| 784 | 784 | sx+8*flipx,sy+8*flipy,0); |
| 785 | 785 | |
| 786 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 786 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 787 | 787 | tileno+1, color, |
| 788 | 788 | flipx, flipy, |
| 789 | 789 | sx+8-8*flipx,sy+8*flipy,0); |
| 790 | 790 | |
| 791 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 791 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 792 | 792 | tileno+2, color, |
| 793 | 793 | flipx, flipy, |
| 794 | 794 | sx+8*flipx,sy+8-8*flipy,0); |
| 795 | 795 | |
| 796 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 796 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 797 | 797 | tileno+3, color, |
| 798 | 798 | flipx, flipy, |
| 799 | 799 | sx+8-8*flipx,sy+8-8*flipy,0); |
| r21028 | r21029 | |
| 812 | 812 | |
| 813 | 813 | m_gfx1_tilemap->draw(bitmap, cliprect, 0,0); |
| 814 | 814 | m_gfx0a_tilemap->draw(bitmap, cliprect, 0,0); |
| 815 | | draw_sprites(machine(), bitmap, cliprect); |
| 815 | draw_sprites(bitmap, cliprect); |
| 816 | 816 | m_gfx0b_tilemap->draw(bitmap, cliprect, 0,0); |
| 817 | 817 | return 0; |
| 818 | 818 | } |
trunk/src/mame/drivers/namcos10.c
| r21028 | r21029 | |
| 316 | 316 | DECLARE_DRIVER_INIT(mrdrilrg); |
| 317 | 317 | DECLARE_DRIVER_INIT(chocovdr); |
| 318 | 318 | DECLARE_MACHINE_RESET(namcos10); |
| 319 | void memn_driver_init( ); |
| 319 | 320 | }; |
| 320 | 321 | |
| 321 | 322 | |
| r21028 | r21029 | |
| 498 | 499 | AM_IMPORT_FROM(namcos10_map) |
| 499 | 500 | ADDRESS_MAP_END |
| 500 | 501 | |
| 501 | | static void memn_driver_init( running_machine &machine ) |
| 502 | void namcos10_state::memn_driver_init( ) |
| 502 | 503 | { |
| 503 | | namcos10_state *state = machine.driver_data<namcos10_state>(); |
| 504 | | UINT8 *BIOS = (UINT8 *)state->memregion( "user1" )->base(); |
| 505 | | state->nand_base = (UINT8 *)state->memregion( "user2" )->base(); |
| 504 | UINT8 *BIOS = (UINT8 *)memregion( "user1" )->base(); |
| 505 | nand_base = (UINT8 *)memregion( "user2" )->base(); |
| 506 | 506 | |
| 507 | | state->nand_copy( (UINT32 *)( BIOS + 0x0000000 ), 0x08000, 0x001c000 ); |
| 508 | | state->nand_copy( (UINT32 *)( BIOS + 0x0020000 ), 0x24000, 0x03e0000 ); |
| 507 | nand_copy( (UINT32 *)( BIOS + 0x0000000 ), 0x08000, 0x001c000 ); |
| 508 | nand_copy( (UINT32 *)( BIOS + 0x0020000 ), 0x24000, 0x03e0000 ); |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | static void decrypt_bios( running_machine &machine, const char *regionName, int start, int b15, int b14, int b13, int b12, int b11, int b10, int b9, int b8, |
| r21028 | r21029 | |
| 530 | 530 | DRIVER_INIT_MEMBER(namcos10_state,gjspace) |
| 531 | 531 | { |
| 532 | 532 | decrypt_bios( machine(), "user2", 0x8400, 0x0, 0x2, 0xe, 0xd, 0xf, 0x6, 0xc, 0x7, 0x5, 0x1, 0x9, 0x8, 0xa, 0x3, 0x4, 0xb ); |
| 533 | | memn_driver_init(machine()); |
| 533 | memn_driver_init(); |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | DRIVER_INIT_MEMBER(namcos10_state,mrdrilrg) |
| 537 | 537 | { |
| 538 | 538 | decrypt_bios( machine(), "user2", 0x8400, 0x6, 0x4, 0x7, 0x5, 0x2, 0x1, 0x0, 0x3, 0xc, 0xd, 0xe, 0xf, 0x8, 0x9, 0xb, 0xa ); |
| 539 | | memn_driver_init(machine()); |
| 539 | memn_driver_init(); |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | DRIVER_INIT_MEMBER(namcos10_state,knpuzzle) |
| 543 | 543 | { |
| 544 | 544 | decrypt_bios( machine(), "user2", 0x8400, 0x6, 0x7, 0x4, 0x5, 0x2, 0x0, 0x3, 0x1, 0xc, 0xd, 0xe, 0xf, 0x9, 0xb, 0x8, 0xa ); |
| 545 | | memn_driver_init(machine()); |
| 545 | memn_driver_init(); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | DRIVER_INIT_MEMBER(namcos10_state,startrgn) |
| 549 | 549 | { |
| 550 | 550 | decrypt_bios( machine(), "user2", 0x8400, 0x6, 0x5, 0x4, 0x7, 0x1, 0x3, 0x0, 0x2, 0xc, 0xd, 0xe, 0xf, 0x8, 0xb, 0xa, 0x9 ); |
| 551 | | memn_driver_init(machine()); |
| 551 | memn_driver_init(); |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | DRIVER_INIT_MEMBER(namcos10_state,gamshara) |
| 555 | 555 | { |
| 556 | 556 | decrypt_bios( machine(), "user2", 0x8400, 0x5, 0x4, 0x7, 0x6, 0x0, 0x1, 0x3, 0x2, 0xd, 0xf, 0xc, 0xe, 0x8, 0x9, 0xa, 0xb ); |
| 557 | | memn_driver_init(machine()); |
| 557 | memn_driver_init(); |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | DRIVER_INIT_MEMBER(namcos10_state,gunbalna) |
| 561 | 561 | { |
| 562 | 562 | decrypt_bios( machine(), "user2", 0x8400, 0x5, 0x4, 0x7, 0x6, 0x0, 0x1, 0x3, 0x2, 0xd, 0xf, 0xc, 0xe, 0x9, 0x8, 0xa, 0xb ); |
| 563 | | memn_driver_init(machine()); |
| 563 | memn_driver_init(); |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | DRIVER_INIT_MEMBER(namcos10_state,chocovdr) |
| r21028 | r21029 | |
| 569 | 569 | // BAD? 0 or 9 1 or 8 0 or 9 |
| 570 | 570 | // ok! ok! ok! ok! ok! ok! ok! ok! ok! ok! ok! ok! |
| 571 | 571 | decrypt_bios( machine(), "user2", 0x8400, 0x5, 0x4, 0x6, 0x7, 0x1, 0x0, 0x2, 0x3, 0xc, 0xf, 0xe, 0xd, 0x8, 0xb, 0xa, 0x9 ); |
| 572 | | memn_driver_init(machine()); |
| 572 | memn_driver_init(); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | DRIVER_INIT_MEMBER(namcos10_state,panikuru) |
| 576 | 576 | { |
| 577 | 577 | decrypt_bios( machine(), "user2", 0x8400, 0x6, 0x4, 0x7, 0x5, 0x0, 0x1, 0x2, 0x3, 0xc, 0xf, 0xe, 0xd, 0x9, 0x8, 0xb, 0xa ); |
| 578 | | memn_driver_init(machine()); |
| 578 | memn_driver_init(); |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | DRIVER_INIT_MEMBER(namcos10_state,nflclsfb) |
| 582 | 582 | { |
| 583 | 583 | decrypt_bios( machine(), "user2", 0x8400, 0x6, 0x5, 0x4, 0x7, 0x1, 0x3, 0x0, 0x2, 0xc, 0xd, 0xe, 0xf, 0x8, 0xb, 0xa, 0x9 ); |
| 584 | | memn_driver_init(machine()); |
| 584 | memn_driver_init(); |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | |