trunk/src/mame/video/combatsc.c
| r20746 | r20747 | |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
| 93 | | static void set_pens( running_machine &machine ) |
| 93 | void combatsc_state::set_pens( ) |
| 94 | 94 | { |
| 95 | | combatsc_state *state = machine.driver_data<combatsc_state>(); |
| 96 | 95 | int i; |
| 97 | 96 | |
| 98 | 97 | for (i = 0x00; i < 0x100; i += 2) |
| 99 | 98 | { |
| 100 | | UINT16 data = state->m_paletteram[i] | (state->m_paletteram[i | 1] << 8); |
| 99 | UINT16 data = m_paletteram[i] | (m_paletteram[i | 1] << 8); |
| 101 | 100 | |
| 102 | 101 | rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); |
| 103 | 102 | |
| 104 | | colortable_palette_set_color(machine.colortable, i >> 1, color); |
| 103 | colortable_palette_set_color(machine().colortable, i >> 1, color); |
| 105 | 104 | } |
| 106 | 105 | } |
| 107 | 106 | |
| r20746 | r20747 | |
| 380 | 379 | |
| 381 | 380 | ***************************************************************************/ |
| 382 | 381 | |
| 383 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit, UINT32 pri_mask ) |
| 382 | void combatsc_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit, UINT32 pri_mask ) |
| 384 | 383 | { |
| 385 | | combatsc_state *state = machine.driver_data<combatsc_state>(); |
| 386 | | device_t *k007121 = circuit ? state->m_k007121_2 : state->m_k007121_1; |
| 387 | | address_space &space = machine.driver_data()->generic_space(); |
| 384 | device_t *k007121 = circuit ? m_k007121_2 : m_k007121_1; |
| 385 | address_space &space = machine().driver_data()->generic_space(); |
| 388 | 386 | int base_color = (circuit * 4) * 16 + (k007121_ctrlram_r(k007121, space, 6) & 0x10) * 2; |
| 389 | 387 | |
| 390 | | k007121_sprites_draw(k007121, bitmap, cliprect, machine.gfx[circuit], machine.colortable, source, base_color, 0, 0, pri_mask); |
| 388 | k007121_sprites_draw(k007121, bitmap, cliprect, machine().gfx[circuit], machine().colortable, source, base_color, 0, 0, pri_mask); |
| 391 | 389 | } |
| 392 | 390 | |
| 393 | 391 | |
| r20746 | r20747 | |
| 395 | 393 | { |
| 396 | 394 | int i; |
| 397 | 395 | |
| 398 | | set_pens(machine()); |
| 396 | set_pens(); |
| 399 | 397 | |
| 400 | 398 | address_space &space = machine().driver_data()->generic_space(); |
| 401 | 399 | if (k007121_ctrlram_r(m_k007121_1, space, 1) & 0x02) |
| r20746 | r20747 | |
| 435 | 433 | m_bg_tilemap[0]->draw(bitmap, cliprect, 1, 2); |
| 436 | 434 | |
| 437 | 435 | /* we use the priority buffer so sprites are drawn front to back */ |
| 438 | | draw_sprites(machine(), bitmap, cliprect, m_spriteram[1], 1, 0x0f00); |
| 439 | | draw_sprites(machine(), bitmap, cliprect, m_spriteram[0], 0, 0x4444); |
| 436 | draw_sprites(bitmap, cliprect, m_spriteram[1], 1, 0x0f00); |
| 437 | draw_sprites(bitmap, cliprect, m_spriteram[0], 0, 0x4444); |
| 440 | 438 | } |
| 441 | 439 | else |
| 442 | 440 | { |
| r20746 | r20747 | |
| 446 | 444 | m_bg_tilemap[1]->draw(bitmap, cliprect, 0, 8); |
| 447 | 445 | |
| 448 | 446 | /* we use the priority buffer so sprites are drawn front to back */ |
| 449 | | draw_sprites(machine(), bitmap, cliprect, m_spriteram[1], 1, 0x0f00); |
| 450 | | draw_sprites(machine(), bitmap, cliprect, m_spriteram[0], 0, 0x4444); |
| 447 | draw_sprites(bitmap, cliprect, m_spriteram[1], 1, 0x0f00); |
| 448 | draw_sprites(bitmap, cliprect, m_spriteram[0], 0, 0x4444); |
| 451 | 449 | } |
| 452 | 450 | |
| 453 | 451 | if (k007121_ctrlram_r(m_k007121_1, space, 1) & 0x08) |
| r20746 | r20747 | |
| 503 | 501 | |
| 504 | 502 | ***************************************************************************/ |
| 505 | 503 | |
| 506 | | static void bootleg_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit ) |
| 504 | void combatsc_state::bootleg_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit ) |
| 507 | 505 | { |
| 508 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 509 | | gfx_element *gfx = machine.gfx[circuit + 2]; |
| 506 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 507 | gfx_element *gfx = machine().gfx[circuit + 2]; |
| 510 | 508 | |
| 511 | 509 | int limit = circuit ? (space.read_byte(0xc2) * 256 + space.read_byte(0xc3)) : (space.read_byte(0xc0) * 256 + space.read_byte(0xc1)); |
| 512 | 510 | const UINT8 *finish; |
| r20746 | r20747 | |
| 536 | 534 | color = (circuit * 4) * 16 + (color >> 4); |
| 537 | 535 | |
| 538 | 536 | /* hacks to select alternate palettes */ |
| 539 | | // if(state->m_vreg == 0x40 && (attributes & 0x40)) color += 1*16; |
| 540 | | // if(state->m_vreg == 0x23 && (attributes & 0x02)) color += 1*16; |
| 541 | | // if(state->m_vreg == 0x66 ) color += 2*16; |
| 537 | // if(m_vreg == 0x40 && (attributes & 0x40)) color += 1*16; |
| 538 | // if(m_vreg == 0x23 && (attributes & 0x02)) color += 1*16; |
| 539 | // if(m_vreg == 0x66 ) color += 2*16; |
| 542 | 540 | |
| 543 | 541 | drawgfx_transpen( bitmap, cliprect, gfx, |
| 544 | 542 | number, color, |
| r20746 | r20747 | |
| 553 | 551 | { |
| 554 | 552 | int i; |
| 555 | 553 | |
| 556 | | set_pens(machine()); |
| 554 | set_pens(); |
| 557 | 555 | |
| 558 | 556 | for (i = 0; i < 32; i++) |
| 559 | 557 | { |
| r20746 | r20747 | |
| 566 | 564 | if (m_priority == 0) |
| 567 | 565 | { |
| 568 | 566 | m_bg_tilemap[1]->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 569 | | bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[0], 0); |
| 567 | bootleg_draw_sprites(bitmap,cliprect, m_page[0], 0); |
| 570 | 568 | m_bg_tilemap[0]->draw(bitmap, cliprect, 0 ,0); |
| 571 | | bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[1], 1); |
| 569 | bootleg_draw_sprites(bitmap,cliprect, m_page[1], 1); |
| 572 | 570 | } |
| 573 | 571 | else |
| 574 | 572 | { |
| 575 | 573 | m_bg_tilemap[0]->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 576 | | bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[0], 0); |
| 574 | bootleg_draw_sprites(bitmap,cliprect, m_page[0], 0); |
| 577 | 575 | m_bg_tilemap[1]->draw(bitmap, cliprect, 0, 0); |
| 578 | | bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[1], 1); |
| 576 | bootleg_draw_sprites(bitmap,cliprect, m_page[1], 1); |
| 579 | 577 | } |
| 580 | 578 | |
| 581 | 579 | m_textlayer->draw(bitmap, cliprect, 0, 0); |
trunk/src/mame/video/cosmic.c
| r20746 | r20747 | |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
| 251 | | static void draw_bitmap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 251 | void cosmic_state::draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 252 | 252 | { |
| 253 | | cosmic_state *state = machine.driver_data<cosmic_state>(); |
| 254 | 253 | offs_t offs; |
| 255 | 254 | |
| 256 | | for (offs = 0; offs < state->m_videoram.bytes(); offs++) |
| 255 | for (offs = 0; offs < m_videoram.bytes(); offs++) |
| 257 | 256 | { |
| 258 | 257 | int i; |
| 259 | | UINT8 data = state->m_videoram[offs]; |
| 258 | UINT8 data = m_videoram[offs]; |
| 260 | 259 | |
| 261 | 260 | UINT8 x = offs << 3; |
| 262 | 261 | UINT8 y = offs >> 5; |
| 263 | 262 | |
| 264 | | pen_t pen = state->m_map_color(machine, x, y); |
| 263 | pen_t pen = m_map_color(machine(), x, y); |
| 265 | 264 | |
| 266 | 265 | for (i = 0; i < 8; i++) |
| 267 | 266 | { |
| 268 | 267 | if (data & 0x80) |
| 269 | 268 | { |
| 270 | | if (state->flip_screen()) |
| 269 | if (flip_screen()) |
| 271 | 270 | bitmap.pix16(255-y, 255-x) = pen; |
| 272 | 271 | else |
| 273 | 272 | bitmap.pix16(y, x) = pen; |
| r20746 | r20747 | |
| 280 | 279 | } |
| 281 | 280 | |
| 282 | 281 | |
| 283 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int extra_sprites ) |
| 282 | void cosmic_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int extra_sprites ) |
| 284 | 283 | { |
| 285 | | cosmic_state *state = machine.driver_data<cosmic_state>(); |
| 286 | 284 | int offs; |
| 287 | 285 | |
| 288 | | for (offs = state->m_spriteram.bytes() - 4;offs >= 0;offs -= 4) |
| 286 | for (offs = m_spriteram.bytes() - 4;offs >= 0;offs -= 4) |
| 289 | 287 | { |
| 290 | | if (state->m_spriteram[offs] != 0) |
| 288 | if (m_spriteram[offs] != 0) |
| 291 | 289 | { |
| 292 | 290 | int code, color; |
| 293 | 291 | |
| 294 | | code = ~state->m_spriteram[offs] & 0x3f; |
| 295 | | color = ~state->m_spriteram[offs + 3] & color_mask; |
| 292 | code = ~m_spriteram[offs] & 0x3f; |
| 293 | color = ~m_spriteram[offs + 3] & color_mask; |
| 296 | 294 | |
| 297 | 295 | if (extra_sprites) |
| 298 | | code |= (state->m_spriteram[offs + 3] & 0x08) << 3; |
| 296 | code |= (m_spriteram[offs + 3] & 0x08) << 3; |
| 299 | 297 | |
| 300 | | if (state->m_spriteram[offs] & 0x80) |
| 298 | if (m_spriteram[offs] & 0x80) |
| 301 | 299 | /* 16x16 sprite */ |
| 302 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 300 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 303 | 301 | code, color, |
| 304 | | 0, ~state->m_spriteram[offs] & 0x40, |
| 305 | | 256-state->m_spriteram[offs + 2],state->m_spriteram[offs + 1],0); |
| 302 | 0, ~m_spriteram[offs] & 0x40, |
| 303 | 256-m_spriteram[offs + 2],m_spriteram[offs + 1],0); |
| 306 | 304 | else |
| 307 | 305 | /* 32x32 sprite */ |
| 308 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 306 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 309 | 307 | code >> 2, color, |
| 310 | | 0, ~state->m_spriteram[offs] & 0x40, |
| 311 | | 256-state->m_spriteram[offs + 2],state->m_spriteram[offs + 1],0); |
| 308 | 0, ~m_spriteram[offs] & 0x40, |
| 309 | 256-m_spriteram[offs + 2],m_spriteram[offs + 1],0); |
| 312 | 310 | } |
| 313 | 311 | } |
| 314 | 312 | } |
| 315 | 313 | |
| 316 | 314 | |
| 317 | | static void cosmica_draw_starfield( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 315 | void cosmic_state::cosmica_draw_starfield( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 318 | 316 | { |
| 319 | | cosmic_state *state = screen.machine().driver_data<cosmic_state>(); |
| 320 | 317 | UINT8 y = 0; |
| 321 | 318 | UINT8 map = 0; |
| 322 | | UINT8 *PROM = state->memregion("user2")->base(); |
| 319 | UINT8 *PROM = memregion("user2")->base(); |
| 323 | 320 | |
| 324 | 321 | while (1) |
| 325 | 322 | { |
| r20746 | r20747 | |
| 333 | 330 | UINT8 x1; |
| 334 | 331 | int hc, hb_; |
| 335 | 332 | |
| 336 | | if (state->flip_screen()) |
| 333 | if (flip_screen()) |
| 337 | 334 | x1 = x - screen.frame_number(); |
| 338 | 335 | else |
| 339 | 336 | x1 = x + screen.frame_number(); |
| r20746 | r20747 | |
| 364 | 361 | } |
| 365 | 362 | |
| 366 | 363 | |
| 367 | | static void devzone_draw_grid( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 364 | void cosmic_state::devzone_draw_grid( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 368 | 365 | { |
| 369 | | cosmic_state *state = machine.driver_data<cosmic_state>(); |
| 370 | 366 | UINT8 y; |
| 371 | | UINT8 *horz_PROM = state->memregion("user2")->base(); |
| 372 | | UINT8 *vert_PROM = state->memregion("user3")->base(); |
| 367 | UINT8 *horz_PROM = memregion("user2")->base(); |
| 368 | UINT8 *vert_PROM = memregion("user3")->base(); |
| 373 | 369 | offs_t horz_addr = 0; |
| 374 | 370 | |
| 375 | 371 | UINT8 count = 0; |
| r20746 | r20747 | |
| 405 | 401 | if (!(vert_data & horz_data & 0x80)) /* NAND gate */ |
| 406 | 402 | { |
| 407 | 403 | /* blue */ |
| 408 | | if (state->flip_screen()) |
| 404 | if (flip_screen()) |
| 409 | 405 | bitmap.pix16(255-y, 255-x) = 4; |
| 410 | 406 | else |
| 411 | 407 | bitmap.pix16(y, x) = 4; |
| r20746 | r20747 | |
| 423 | 419 | } |
| 424 | 420 | |
| 425 | 421 | |
| 426 | | static void nomnlnd_draw_background( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 422 | void cosmic_state::nomnlnd_draw_background( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 427 | 423 | { |
| 428 | | cosmic_state *state = screen.machine().driver_data<cosmic_state>(); |
| 429 | 424 | UINT8 y = 0; |
| 430 | 425 | UINT8 water = screen.frame_number(); |
| 431 | | UINT8 *PROM = state->memregion("user2")->base(); |
| 426 | UINT8 *PROM = memregion("user2")->base(); |
| 432 | 427 | |
| 433 | 428 | /* all positioning is via logic gates: |
| 434 | 429 | |
| r20746 | r20747 | |
| 491 | 486 | if ((!hd_) & hc_ & (!hb_)) |
| 492 | 487 | { |
| 493 | 488 | offs_t offs = ((x >> 3) & 0x03) | ((y & 0x1f) << 2) | |
| 494 | | (state->flip_screen() ? 0x80 : 0); |
| 489 | (flip_screen() ? 0x80 : 0); |
| 495 | 490 | |
| 496 | 491 | UINT8 plane1 = PROM[offs ] << (x & 0x07); |
| 497 | 492 | UINT8 plane2 = PROM[offs | 0x0400] << (x & 0x07); |
| r20746 | r20747 | |
| 525 | 520 | |
| 526 | 521 | if (color != 0) |
| 527 | 522 | { |
| 528 | | if (state->flip_screen()) |
| 523 | if (flip_screen()) |
| 529 | 524 | bitmap.pix16(255-y, 255-x) = color; |
| 530 | 525 | else |
| 531 | 526 | bitmap.pix16(y, x) = color; |
| r20746 | r20747 | |
| 549 | 544 | UINT32 cosmic_state::screen_update_cosmicg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 550 | 545 | { |
| 551 | 546 | bitmap.fill(0, cliprect); |
| 552 | | draw_bitmap(machine(), bitmap, cliprect); |
| 547 | draw_bitmap(bitmap, cliprect); |
| 553 | 548 | return 0; |
| 554 | 549 | } |
| 555 | 550 | |
| r20746 | r20747 | |
| 557 | 552 | UINT32 cosmic_state::screen_update_panic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 558 | 553 | { |
| 559 | 554 | bitmap.fill(0, cliprect); |
| 560 | | draw_bitmap(machine(), bitmap, cliprect); |
| 561 | | draw_sprites(machine(), bitmap, cliprect, 0x07, 1); |
| 555 | draw_bitmap(bitmap, cliprect); |
| 556 | draw_sprites(bitmap, cliprect, 0x07, 1); |
| 562 | 557 | return 0; |
| 563 | 558 | } |
| 564 | 559 | |
| r20746 | r20747 | |
| 567 | 562 | { |
| 568 | 563 | bitmap.fill(0, cliprect); |
| 569 | 564 | cosmica_draw_starfield(screen, bitmap, cliprect); |
| 570 | | draw_bitmap(machine(), bitmap, cliprect); |
| 571 | | draw_sprites(machine(), bitmap, cliprect, 0x0f, 0); |
| 565 | draw_bitmap(bitmap, cliprect); |
| 566 | draw_sprites(bitmap, cliprect, 0x0f, 0); |
| 572 | 567 | return 0; |
| 573 | 568 | } |
| 574 | 569 | |
| r20746 | r20747 | |
| 576 | 571 | UINT32 cosmic_state::screen_update_magspot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 577 | 572 | { |
| 578 | 573 | bitmap.fill(0, cliprect); |
| 579 | | draw_bitmap(machine(), bitmap, cliprect); |
| 580 | | draw_sprites(machine(), bitmap, cliprect, 0x07, 0); |
| 574 | draw_bitmap(bitmap, cliprect); |
| 575 | draw_sprites(bitmap, cliprect, 0x07, 0); |
| 581 | 576 | return 0; |
| 582 | 577 | } |
| 583 | 578 | |
| r20746 | r20747 | |
| 587 | 582 | bitmap.fill(0, cliprect); |
| 588 | 583 | |
| 589 | 584 | if (m_background_enable) |
| 590 | | devzone_draw_grid(machine(), bitmap, cliprect); |
| 585 | devzone_draw_grid(bitmap, cliprect); |
| 591 | 586 | |
| 592 | | draw_bitmap(machine(), bitmap, cliprect); |
| 593 | | draw_sprites(machine(), bitmap, cliprect, 0x07, 0); |
| 587 | draw_bitmap(bitmap, cliprect); |
| 588 | draw_sprites(bitmap, cliprect, 0x07, 0); |
| 594 | 589 | return 0; |
| 595 | 590 | } |
| 596 | 591 | |
| r20746 | r20747 | |
| 601 | 596 | have the highest priority */ |
| 602 | 597 | |
| 603 | 598 | bitmap.fill(0, cliprect); |
| 604 | | draw_bitmap(machine(), bitmap, cliprect); |
| 605 | | draw_sprites(machine(), bitmap, cliprect, 0x07, 0); |
| 599 | draw_bitmap(bitmap, cliprect); |
| 600 | draw_sprites(bitmap, cliprect, 0x07, 0); |
| 606 | 601 | |
| 607 | 602 | if (m_background_enable) |
| 608 | 603 | nomnlnd_draw_background(screen, bitmap, cliprect); |
trunk/src/mame/video/carpolo.c
| r20746 | r20747 | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
| 189 | | static void remap_sprite_code(running_machine &machine, int bank, int code, int *remapped_code, int *flipy) |
| 189 | void carpolo_state::remap_sprite_code(int bank, int code, int *remapped_code, int *flipy) |
| 190 | 190 | { |
| 191 | | UINT8* PROM = machine.root_device().memregion("user1")->base(); |
| 191 | UINT8* PROM = machine().root_device().memregion("user1")->base(); |
| 192 | 192 | |
| 193 | 193 | code = (bank << 4) | code; |
| 194 | 194 | *remapped_code = PROM[code] & 0x0f; |
| r20746 | r20747 | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
| 199 | | static void draw_sprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, |
| 199 | void carpolo_state::draw_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, |
| 200 | 200 | UINT8 x, UINT8 y, int bank, int code, int col) |
| 201 | 201 | { |
| 202 | 202 | int remapped_code, flipy; |
| 203 | 203 | |
| 204 | | remap_sprite_code(machine, bank, code, &remapped_code, &flipy); |
| 204 | remap_sprite_code(bank, code, &remapped_code, &flipy); |
| 205 | 205 | |
| 206 | 206 | x = 240 - x; |
| 207 | 207 | y = 240 - y; |
| 208 | 208 | |
| 209 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 209 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 210 | 210 | remapped_code, col, |
| 211 | 211 | 0, flipy, |
| 212 | 212 | x, y,0); |
| 213 | 213 | |
| 214 | 214 | /* draw with wrap around */ |
| 215 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 215 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 216 | 216 | remapped_code, col, |
| 217 | 217 | 0, flipy, |
| 218 | 218 | (INT16)x - 256, y,0); |
| r20746 | r20747 | |
| 230 | 230 | bitmap.plot_box(0,TOP_BORDER,RIGHT_BORDER+1,BOTTOM_BORDER-TOP_BORDER+1,FIELD_PEN); |
| 231 | 231 | |
| 232 | 232 | /* car 1 */ |
| 233 | | draw_sprite(machine(), bitmap, cliprect, |
| 233 | draw_sprite(bitmap, cliprect, |
| 234 | 234 | m_spriteram[0x00], m_spriteram[0x01], |
| 235 | 235 | 0, m_spriteram[0x0c] & 0x0f, CAR1_COLOR); |
| 236 | 236 | |
| r20746 | r20747 | |
| 241 | 241 | bitmap.plot_box(RIGHT_BORDER,TOP_BORDER,1,BOTTOM_BORDER-TOP_BORDER+1,LINE_PEN); |
| 242 | 242 | |
| 243 | 243 | /* car 4 */ |
| 244 | | draw_sprite(machine(), bitmap, cliprect, |
| 244 | draw_sprite(bitmap, cliprect, |
| 245 | 245 | m_spriteram[0x06], m_spriteram[0x07], |
| 246 | 246 | 0, m_spriteram[0x0d] >> 4, CAR4_COLOR); |
| 247 | 247 | |
| 248 | 248 | /* car 3 */ |
| 249 | | draw_sprite(machine(), bitmap, cliprect, |
| 249 | draw_sprite(bitmap, cliprect, |
| 250 | 250 | m_spriteram[0x04], m_spriteram[0x05], |
| 251 | 251 | 0, m_spriteram[0x0d] & 0x0f, CAR3_COLOR); |
| 252 | 252 | |
| 253 | 253 | /* car 2 */ |
| 254 | | draw_sprite(machine(), bitmap, cliprect, |
| 254 | draw_sprite(bitmap, cliprect, |
| 255 | 255 | m_spriteram[0x02], m_spriteram[0x03], |
| 256 | 256 | 0, m_spriteram[0x0c] >> 4, CAR2_COLOR); |
| 257 | 257 | |
| 258 | 258 | /* ball */ |
| 259 | | draw_sprite(machine(), bitmap, cliprect, |
| 259 | draw_sprite(bitmap, cliprect, |
| 260 | 260 | m_spriteram[0x08], m_spriteram[0x09], |
| 261 | 261 | 1, m_spriteram[0x0e] & 0x0f, BALL_COLOR); |
| 262 | 262 | |
| r20746 | r20747 | |
| 281 | 281 | popmessage("WIDE!\n"); |
| 282 | 282 | |
| 283 | 283 | if (m_spriteram[0x0f] & 0x01) |
| 284 | | draw_sprite(machine(), bitmap, cliprect, |
| 284 | draw_sprite(bitmap, cliprect, |
| 285 | 285 | m_spriteram[0x0a], m_spriteram[0x0b], |
| 286 | 286 | 1, m_spriteram[0x0e] >> 4, SPECIAL_CHAR_COLOR); |
| 287 | 287 | |
| r20746 | r20747 | |
| 311 | 311 | * |
| 312 | 312 | *************************************/ |
| 313 | 313 | |
| 314 | | static void normalize_coordinates(int *x1, int *y1, int *x2, int *y2) |
| 314 | void carpolo_state::normalize_coordinates(int *x1, int *y1, int *x2, int *y2) |
| 315 | 315 | { |
| 316 | 316 | if (*x1 < *x2) |
| 317 | 317 | { |
| r20746 | r20747 | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | |
| 340 | | static int check_sprite_sprite_collision(running_machine &machine, |
| 341 | | int x1, int y1, int code1, int flipy1, |
| 340 | int carpolo_state::check_sprite_sprite_collision(int x1, int y1, int code1, int flipy1, |
| 342 | 341 | int x2, int y2, int code2, int flipy2, |
| 343 | 342 | int *col_x, int *col_y) |
| 344 | 343 | { |
| 345 | | carpolo_state *state = machine.driver_data<carpolo_state>(); |
| 346 | 344 | int collided = 0; |
| 347 | 345 | |
| 348 | 346 | x1 = 240 - x1; |
| r20746 | r20747 | |
| 357 | 355 | |
| 358 | 356 | normalize_coordinates(&x1, &y1, &x2, &y2); |
| 359 | 357 | |
| 360 | | state->m_sprite_sprite_collision_bitmap1->fill(0); |
| 361 | | state->m_sprite_sprite_collision_bitmap2->fill(0); |
| 358 | m_sprite_sprite_collision_bitmap1->fill(0); |
| 359 | m_sprite_sprite_collision_bitmap2->fill(0); |
| 362 | 360 | |
| 363 | | drawgfx_opaque(*state->m_sprite_sprite_collision_bitmap1,state->m_sprite_sprite_collision_bitmap1->cliprect(),machine.gfx[0], |
| 361 | drawgfx_opaque(*m_sprite_sprite_collision_bitmap1,m_sprite_sprite_collision_bitmap1->cliprect(),machine().gfx[0], |
| 364 | 362 | code1,0, |
| 365 | 363 | 0,flipy1, |
| 366 | 364 | x1,y1); |
| 367 | 365 | |
| 368 | | drawgfx_opaque(*state->m_sprite_sprite_collision_bitmap2,state->m_sprite_sprite_collision_bitmap2->cliprect(),machine.gfx[0], |
| 366 | drawgfx_opaque(*m_sprite_sprite_collision_bitmap2,m_sprite_sprite_collision_bitmap2->cliprect(),machine().gfx[0], |
| 369 | 367 | code2,0, |
| 370 | 368 | 0,flipy2, |
| 371 | 369 | x2,y2); |
| 372 | 370 | |
| 373 | 371 | for (x = x1; x < x1 + SPRITE_WIDTH; x++) |
| 374 | 372 | for (y = y1; y < y1 + SPRITE_HEIGHT; y++) |
| 375 | | if ((state->m_sprite_sprite_collision_bitmap1->pix16(y, x) == 1) && |
| 376 | | (state->m_sprite_sprite_collision_bitmap2->pix16(y, x) == 1)) |
| 373 | if ((m_sprite_sprite_collision_bitmap1->pix16(y, x) == 1) && |
| 374 | (m_sprite_sprite_collision_bitmap2->pix16(y, x) == 1)) |
| 377 | 375 | { |
| 378 | 376 | *col_x = (x1 + x) & 0x0f; |
| 379 | 377 | *col_y = (y1 + y) & 0x0f; |
| r20746 | r20747 | |
| 390 | 388 | |
| 391 | 389 | /* returns 1 for collision with goal post, |
| 392 | 390 | 2 for collision with scoring area */ |
| 393 | | static int check_sprite_left_goal_collision(running_machine &machine, int x1, int y1, int code1, int flipy1, int goalpost_only) |
| 391 | int carpolo_state::check_sprite_left_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only) |
| 394 | 392 | { |
| 395 | | carpolo_state *state = machine.driver_data<carpolo_state>(); |
| 396 | 393 | int collided = 0; |
| 397 | 394 | |
| 398 | 395 | x1 = 240 - x1; |
| r20746 | r20747 | |
| 411 | 408 | |
| 412 | 409 | normalize_coordinates(&x1, &y1, &x2, &y2); |
| 413 | 410 | |
| 414 | | state->m_sprite_goal_collision_bitmap1->fill(0); |
| 415 | | state->m_sprite_goal_collision_bitmap2->fill(0); |
| 411 | m_sprite_goal_collision_bitmap1->fill(0); |
| 412 | m_sprite_goal_collision_bitmap2->fill(0); |
| 416 | 413 | |
| 417 | | drawgfx_opaque(*state->m_sprite_goal_collision_bitmap1,state->m_sprite_goal_collision_bitmap1->cliprect(),machine.gfx[0], |
| 414 | drawgfx_opaque(*m_sprite_goal_collision_bitmap1,m_sprite_goal_collision_bitmap1->cliprect(),machine().gfx[0], |
| 418 | 415 | code1,0, |
| 419 | 416 | 0,flipy1, |
| 420 | 417 | x1,y1); |
| 421 | 418 | |
| 422 | | drawgfxzoom_transpen(*state->m_sprite_goal_collision_bitmap2,state->m_sprite_goal_collision_bitmap2->cliprect(),machine.gfx[1], |
| 419 | drawgfxzoom_transpen(*m_sprite_goal_collision_bitmap2,m_sprite_goal_collision_bitmap2->cliprect(),machine().gfx[1], |
| 423 | 420 | 0,0, |
| 424 | 421 | 0,0, |
| 425 | 422 | x2,y2, |
| r20746 | r20747 | |
| 427 | 424 | |
| 428 | 425 | for (x = x1; x < x1 + SPRITE_WIDTH; x++) |
| 429 | 426 | for (y = y1; y < y1 + SPRITE_HEIGHT; y++) |
| 430 | | if (state->m_sprite_goal_collision_bitmap1->pix16(y, x) == 1) |
| 427 | if (m_sprite_goal_collision_bitmap1->pix16(y, x) == 1) |
| 431 | 428 | { |
| 432 | | pen_t pix = state->m_sprite_goal_collision_bitmap2->pix16(y, x); |
| 429 | pen_t pix = m_sprite_goal_collision_bitmap2->pix16(y, x); |
| 433 | 430 | |
| 434 | 431 | if (pix == LEFT_GOAL_PEN) |
| 435 | 432 | { |
| r20746 | r20747 | |
| 449 | 446 | } |
| 450 | 447 | |
| 451 | 448 | |
| 452 | | static int check_sprite_right_goal_collision(running_machine &machine, int x1, int y1, int code1, int flipy1, int goalpost_only) |
| 449 | int carpolo_state::check_sprite_right_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only) |
| 453 | 450 | { |
| 454 | | carpolo_state *state = machine.driver_data<carpolo_state>(); |
| 455 | 451 | int collided = 0; |
| 456 | 452 | |
| 457 | 453 | x1 = 240 - x1; |
| r20746 | r20747 | |
| 469 | 465 | |
| 470 | 466 | normalize_coordinates(&x1, &y1, &x2, &y2); |
| 471 | 467 | |
| 472 | | state->m_sprite_goal_collision_bitmap1->fill(0); |
| 473 | | state->m_sprite_goal_collision_bitmap2->fill(0); |
| 468 | m_sprite_goal_collision_bitmap1->fill(0); |
| 469 | m_sprite_goal_collision_bitmap2->fill(0); |
| 474 | 470 | |
| 475 | | drawgfx_opaque(*state->m_sprite_goal_collision_bitmap1,state->m_sprite_goal_collision_bitmap1->cliprect(),machine.gfx[0], |
| 471 | drawgfx_opaque(*m_sprite_goal_collision_bitmap1,m_sprite_goal_collision_bitmap1->cliprect(),machine().gfx[0], |
| 476 | 472 | code1,0, |
| 477 | 473 | 0,flipy1, |
| 478 | 474 | x1,y1); |
| 479 | 475 | |
| 480 | | drawgfxzoom_transpen(*state->m_sprite_goal_collision_bitmap2,state->m_sprite_goal_collision_bitmap2->cliprect(),machine.gfx[1], |
| 476 | drawgfxzoom_transpen(*m_sprite_goal_collision_bitmap2,m_sprite_goal_collision_bitmap2->cliprect(),machine().gfx[1], |
| 481 | 477 | 0,1, |
| 482 | 478 | 1,0, |
| 483 | 479 | x2,y2, |
| r20746 | r20747 | |
| 485 | 481 | |
| 486 | 482 | for (x = x1; x < x1 + SPRITE_WIDTH; x++) |
| 487 | 483 | for (y = y1; y < y1 + SPRITE_HEIGHT; y++) |
| 488 | | if (state->m_sprite_goal_collision_bitmap1->pix16(y, x) == 1) |
| 484 | if (m_sprite_goal_collision_bitmap1->pix16(y, x) == 1) |
| 489 | 485 | { |
| 490 | | pen_t pix = state->m_sprite_goal_collision_bitmap2->pix16(y, x); |
| 486 | pen_t pix = m_sprite_goal_collision_bitmap2->pix16(y, x); |
| 491 | 487 | |
| 492 | 488 | if (pix == RIGHT_GOAL_PEN) |
| 493 | 489 | { |
| r20746 | r20747 | |
| 509 | 505 | |
| 510 | 506 | /* returns 1 for collision with vertical border, |
| 511 | 507 | 2 for collision with horizontal border */ |
| 512 | | static int check_sprite_border_collision(running_machine &machine, UINT8 x1, UINT8 y1, int code1, int flipy1) |
| 508 | int carpolo_state::check_sprite_border_collision(UINT8 x1, UINT8 y1, int code1, int flipy1) |
| 513 | 509 | { |
| 514 | | carpolo_state *state = machine.driver_data<carpolo_state>(); |
| 515 | 510 | UINT8 x,y; |
| 516 | 511 | int collided = 0; |
| 517 | 512 | |
| 518 | 513 | x1 = 240 - x1; |
| 519 | 514 | y1 = 240 - y1; |
| 520 | 515 | |
| 521 | | drawgfx_opaque(*state->m_sprite_border_collision_bitmap,state->m_sprite_border_collision_bitmap->cliprect(),machine.gfx[0], |
| 516 | drawgfx_opaque(*m_sprite_border_collision_bitmap,m_sprite_border_collision_bitmap->cliprect(),machine().gfx[0], |
| 522 | 517 | code1,0, |
| 523 | 518 | 0,flipy1, |
| 524 | 519 | 0,0); |
| 525 | 520 | |
| 526 | 521 | for (x = 0; x < SPRITE_WIDTH; x++) |
| 527 | 522 | for (y = 0; y < SPRITE_HEIGHT; y++) |
| 528 | | if (state->m_sprite_border_collision_bitmap->pix16(y, x) == 1) |
| 523 | if (m_sprite_border_collision_bitmap->pix16(y, x) == 1) |
| 529 | 524 | { |
| 530 | 525 | if (((UINT8)(x1 + x) == LEFT_BORDER) || |
| 531 | 526 | ((UINT8)(x1 + x) == RIGHT_BORDER)) |
| r20746 | r20747 | |
| 562 | 557 | |
| 563 | 558 | car1_x = m_spriteram[0x00]; |
| 564 | 559 | car1_y = m_spriteram[0x01]; |
| 565 | | remap_sprite_code(machine(), 0, m_spriteram[0x0c] & 0x0f, &car1_code, &car1_flipy); |
| 560 | remap_sprite_code(0, m_spriteram[0x0c] & 0x0f, &car1_code, &car1_flipy); |
| 566 | 561 | |
| 567 | 562 | car2_x = m_spriteram[0x02]; |
| 568 | 563 | car2_y = m_spriteram[0x03]; |
| 569 | | remap_sprite_code(machine(), 0, m_spriteram[0x0c] >> 4, &car2_code, &car2_flipy); |
| 564 | remap_sprite_code(0, m_spriteram[0x0c] >> 4, &car2_code, &car2_flipy); |
| 570 | 565 | |
| 571 | 566 | car3_x = m_spriteram[0x04]; |
| 572 | 567 | car3_y = m_spriteram[0x05]; |
| 573 | | remap_sprite_code(machine(), 0, m_spriteram[0x0d] & 0x0f, &car3_code, &car3_flipy); |
| 568 | remap_sprite_code(0, m_spriteram[0x0d] & 0x0f, &car3_code, &car3_flipy); |
| 574 | 569 | |
| 575 | 570 | car4_x = m_spriteram[0x06]; |
| 576 | 571 | car4_y = m_spriteram[0x07]; |
| 577 | | remap_sprite_code(machine(), 0, m_spriteram[0x0d] >> 4, &car4_code, &car4_flipy); |
| 572 | remap_sprite_code(0, m_spriteram[0x0d] >> 4, &car4_code, &car4_flipy); |
| 578 | 573 | |
| 579 | 574 | ball_x = m_spriteram[0x08]; |
| 580 | 575 | ball_y = m_spriteram[0x09]; |
| 581 | | remap_sprite_code(machine(), 1, m_spriteram[0x0e] & 0x0f, &ball_code, &ball_flipy); |
| 576 | remap_sprite_code(1, m_spriteram[0x0e] & 0x0f, &ball_code, &ball_flipy); |
| 582 | 577 | |
| 583 | 578 | |
| 584 | 579 | /* cars 1 and 2 */ |
| 585 | | if (check_sprite_sprite_collision(machine(), |
| 586 | | car1_x, car1_y, car1_code, car1_flipy, |
| 580 | if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy, |
| 587 | 581 | car2_x, car2_y, car2_code, car2_flipy, |
| 588 | 582 | &col_x, &col_y)) |
| 589 | | carpolo_generate_car_car_interrupt(machine(), 0, 1); |
| 583 | carpolo_generate_car_car_interrupt(0, 1); |
| 590 | 584 | |
| 591 | 585 | /* cars 1 and 3 */ |
| 592 | | else if (check_sprite_sprite_collision(machine(), |
| 593 | | car1_x, car1_y, car1_code, car1_flipy, |
| 586 | else if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy, |
| 594 | 587 | car3_x, car3_y, car3_code, car3_flipy, |
| 595 | 588 | &col_x, &col_y)) |
| 596 | | carpolo_generate_car_car_interrupt(machine(), 0, 2); |
| 589 | carpolo_generate_car_car_interrupt(0, 2); |
| 597 | 590 | |
| 598 | 591 | /* cars 1 and 4 */ |
| 599 | | else if (check_sprite_sprite_collision(machine(), |
| 600 | | car1_x, car1_y, car1_code, car1_flipy, |
| 592 | else if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy, |
| 601 | 593 | car4_x, car4_y, car4_code, car4_flipy, |
| 602 | 594 | &col_x, &col_y)) |
| 603 | | carpolo_generate_car_car_interrupt(machine(), 0, 3); |
| 595 | carpolo_generate_car_car_interrupt(0, 3); |
| 604 | 596 | |
| 605 | 597 | /* cars 2 and 3 */ |
| 606 | | else if (check_sprite_sprite_collision(machine(), |
| 607 | | car2_x, car2_y, car2_code, car2_flipy, |
| 598 | else if (check_sprite_sprite_collision(car2_x, car2_y, car2_code, car2_flipy, |
| 608 | 599 | car3_x, car3_y, car3_code, car3_flipy, |
| 609 | 600 | &col_x, &col_y)) |
| 610 | | carpolo_generate_car_car_interrupt(machine(), 1, 2); |
| 601 | carpolo_generate_car_car_interrupt(1, 2); |
| 611 | 602 | |
| 612 | 603 | /* cars 2 and 4 */ |
| 613 | | else if (check_sprite_sprite_collision(machine(), |
| 614 | | car2_x, car2_y, car2_code, car2_flipy, |
| 604 | else if (check_sprite_sprite_collision(car2_x, car2_y, car2_code, car2_flipy, |
| 615 | 605 | car4_x, car4_y, car4_code, car4_flipy, |
| 616 | 606 | &col_x, &col_y)) |
| 617 | | carpolo_generate_car_car_interrupt(machine(), 1, 3); |
| 607 | carpolo_generate_car_car_interrupt(1, 3); |
| 618 | 608 | |
| 619 | 609 | /* cars 3 and 4 */ |
| 620 | | else if (check_sprite_sprite_collision(machine(), |
| 621 | | car3_x, car3_y, car3_code, car3_flipy, |
| 610 | else if (check_sprite_sprite_collision(car3_x, car3_y, car3_code, car3_flipy, |
| 622 | 611 | car4_x, car4_y, car4_code, car4_flipy, |
| 623 | 612 | &col_x, &col_y)) |
| 624 | | carpolo_generate_car_car_interrupt(machine(), 2, 3); |
| 613 | carpolo_generate_car_car_interrupt(2, 3); |
| 625 | 614 | |
| 626 | 615 | |
| 627 | 616 | |
| 628 | 617 | /* check car-ball collision */ |
| 629 | | if (check_sprite_sprite_collision(machine(), |
| 630 | | car1_x, car1_y, car1_code, car1_flipy, |
| 618 | if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy, |
| 631 | 619 | ball_x, ball_y, ball_code, ball_flipy, |
| 632 | 620 | &col_x, &col_y)) |
| 633 | | carpolo_generate_car_ball_interrupt(machine(), 0, col_x, col_y); |
| 621 | carpolo_generate_car_ball_interrupt(0, col_x, col_y); |
| 634 | 622 | |
| 635 | | else if (check_sprite_sprite_collision(machine(), |
| 636 | | car2_x, car2_y, car2_code, car2_flipy, |
| 623 | else if (check_sprite_sprite_collision(car2_x, car2_y, car2_code, car2_flipy, |
| 637 | 624 | ball_x, ball_y, ball_code, ball_flipy, |
| 638 | 625 | &col_x, &col_y)) |
| 639 | | carpolo_generate_car_ball_interrupt(machine(), 1, col_x, col_y); |
| 626 | carpolo_generate_car_ball_interrupt(1, col_x, col_y); |
| 640 | 627 | |
| 641 | | else if (check_sprite_sprite_collision(machine(), |
| 642 | | car3_x, car3_y, car3_code, car3_flipy, |
| 628 | else if (check_sprite_sprite_collision(car3_x, car3_y, car3_code, car3_flipy, |
| 643 | 629 | ball_x, ball_y, ball_code, ball_flipy, |
| 644 | 630 | &col_x, &col_y)) |
| 645 | | carpolo_generate_car_ball_interrupt(machine(), 2, col_x, col_y); |
| 631 | carpolo_generate_car_ball_interrupt(2, col_x, col_y); |
| 646 | 632 | |
| 647 | | else if (check_sprite_sprite_collision(machine(), |
| 648 | | car4_x, car4_y, car4_code, car4_flipy, |
| 633 | else if (check_sprite_sprite_collision(car4_x, car4_y, car4_code, car4_flipy, |
| 649 | 634 | ball_x, ball_y, ball_code, ball_flipy, |
| 650 | 635 | &col_x, &col_y)) |
| 651 | | carpolo_generate_car_ball_interrupt(machine(), 3, col_x, col_y); |
| 636 | carpolo_generate_car_ball_interrupt(3, col_x, col_y); |
| 652 | 637 | |
| 653 | 638 | |
| 654 | 639 | /* check car-goal collision */ |
| 655 | | if (check_sprite_left_goal_collision(machine(), car1_x, car1_y, car1_code, car1_flipy, 1)) |
| 656 | | carpolo_generate_car_goal_interrupt(machine(), 0, 0); |
| 640 | if (check_sprite_left_goal_collision(car1_x, car1_y, car1_code, car1_flipy, 1)) |
| 641 | carpolo_generate_car_goal_interrupt(0, 0); |
| 657 | 642 | |
| 658 | | else if (check_sprite_right_goal_collision(machine(), car1_x, car1_y, car1_code, car1_flipy, 1)) |
| 659 | | carpolo_generate_car_goal_interrupt(machine(), 0, 1); |
| 643 | else if (check_sprite_right_goal_collision(car1_x, car1_y, car1_code, car1_flipy, 1)) |
| 644 | carpolo_generate_car_goal_interrupt(0, 1); |
| 660 | 645 | |
| 661 | | else if (check_sprite_left_goal_collision(machine(), car2_x, car2_y, car2_code, car2_flipy, 1)) |
| 662 | | carpolo_generate_car_goal_interrupt(machine(), 1, 0); |
| 646 | else if (check_sprite_left_goal_collision(car2_x, car2_y, car2_code, car2_flipy, 1)) |
| 647 | carpolo_generate_car_goal_interrupt(1, 0); |
| 663 | 648 | |
| 664 | | else if (check_sprite_right_goal_collision(machine(), car2_x, car2_y, car2_code, car2_flipy, 1)) |
| 665 | | carpolo_generate_car_goal_interrupt(machine(), 1, 1); |
| 649 | else if (check_sprite_right_goal_collision(car2_x, car2_y, car2_code, car2_flipy, 1)) |
| 650 | carpolo_generate_car_goal_interrupt(1, 1); |
| 666 | 651 | |
| 667 | | else if (check_sprite_left_goal_collision(machine(), car3_x, car3_y, car3_code, car3_flipy, 1)) |
| 668 | | carpolo_generate_car_goal_interrupt(machine(), 2, 0); |
| 652 | else if (check_sprite_left_goal_collision(car3_x, car3_y, car3_code, car3_flipy, 1)) |
| 653 | carpolo_generate_car_goal_interrupt(2, 0); |
| 669 | 654 | |
| 670 | | else if (check_sprite_right_goal_collision(machine(), car3_x, car3_y, car3_code, car3_flipy, 1)) |
| 671 | | carpolo_generate_car_goal_interrupt(machine(), 2, 1); |
| 655 | else if (check_sprite_right_goal_collision(car3_x, car3_y, car3_code, car3_flipy, 1)) |
| 656 | carpolo_generate_car_goal_interrupt(2, 1); |
| 672 | 657 | |
| 673 | | else if (check_sprite_left_goal_collision(machine(), car4_x, car4_y, car4_code, car4_flipy, 1)) |
| 674 | | carpolo_generate_car_goal_interrupt(machine(), 3, 0); |
| 658 | else if (check_sprite_left_goal_collision(car4_x, car4_y, car4_code, car4_flipy, 1)) |
| 659 | carpolo_generate_car_goal_interrupt(3, 0); |
| 675 | 660 | |
| 676 | | else if (check_sprite_right_goal_collision(machine(), car4_x, car4_y, car4_code, car4_flipy, 1)) |
| 677 | | carpolo_generate_car_goal_interrupt(machine(), 3, 1); |
| 661 | else if (check_sprite_right_goal_collision(car4_x, car4_y, car4_code, car4_flipy, 1)) |
| 662 | carpolo_generate_car_goal_interrupt(3, 1); |
| 678 | 663 | |
| 679 | 664 | |
| 680 | 665 | /* check ball collision with static screen elements */ |
| 681 | 666 | { |
| 682 | 667 | int col; |
| 683 | 668 | |
| 684 | | col = check_sprite_left_goal_collision(machine(), ball_x, ball_y, ball_code, ball_flipy, 0); |
| 669 | col = check_sprite_left_goal_collision(ball_x, ball_y, ball_code, ball_flipy, 0); |
| 685 | 670 | |
| 686 | | if (col == 1) carpolo_generate_ball_screen_interrupt(machine(), 0x05); |
| 687 | | if (col == 2) carpolo_generate_ball_screen_interrupt(machine(), 0x03); |
| 671 | if (col == 1) carpolo_generate_ball_screen_interrupt(0x05); |
| 672 | if (col == 2) carpolo_generate_ball_screen_interrupt(0x03); |
| 688 | 673 | |
| 689 | 674 | |
| 690 | | col = check_sprite_right_goal_collision(machine(), ball_x, ball_y, ball_code, ball_flipy, 0); |
| 675 | col = check_sprite_right_goal_collision(ball_x, ball_y, ball_code, ball_flipy, 0); |
| 691 | 676 | |
| 692 | | if (col == 1) carpolo_generate_ball_screen_interrupt(machine(), 0x05 | 0x08); |
| 693 | | if (col == 2) carpolo_generate_ball_screen_interrupt(machine(), 0x03 | 0x08); |
| 677 | if (col == 1) carpolo_generate_ball_screen_interrupt(0x05 | 0x08); |
| 678 | if (col == 2) carpolo_generate_ball_screen_interrupt(0x03 | 0x08); |
| 694 | 679 | |
| 695 | 680 | |
| 696 | | if (check_sprite_border_collision(machine(), ball_x, ball_y, ball_code, ball_flipy)) |
| 697 | | carpolo_generate_ball_screen_interrupt(machine(), 0x06); |
| 681 | if (check_sprite_border_collision(ball_x, ball_y, ball_code, ball_flipy)) |
| 682 | carpolo_generate_ball_screen_interrupt(0x06); |
| 698 | 683 | } |
| 699 | 684 | |
| 700 | 685 | |
| r20746 | r20747 | |
| 702 | 687 | { |
| 703 | 688 | int col; |
| 704 | 689 | |
| 705 | | col = check_sprite_border_collision(machine(), car1_x, car1_y, car1_code, car1_flipy); |
| 690 | col = check_sprite_border_collision(car1_x, car1_y, car1_code, car1_flipy); |
| 706 | 691 | |
| 707 | 692 | if (col) |
| 708 | | carpolo_generate_car_border_interrupt(machine(), 0, (col == 2)); |
| 693 | carpolo_generate_car_border_interrupt(0, (col == 2)); |
| 709 | 694 | else |
| 710 | 695 | { |
| 711 | | col = check_sprite_border_collision(machine(), car2_x, car2_y, car2_code, car2_flipy); |
| 696 | col = check_sprite_border_collision(car2_x, car2_y, car2_code, car2_flipy); |
| 712 | 697 | |
| 713 | 698 | if (col) |
| 714 | | carpolo_generate_car_border_interrupt(machine(), 1, (col == 2)); |
| 699 | carpolo_generate_car_border_interrupt(1, (col == 2)); |
| 715 | 700 | else |
| 716 | 701 | { |
| 717 | | col = check_sprite_border_collision(machine(), car3_x, car3_y, car3_code, car3_flipy); |
| 702 | col = check_sprite_border_collision(car3_x, car3_y, car3_code, car3_flipy); |
| 718 | 703 | |
| 719 | 704 | if (col) |
| 720 | | carpolo_generate_car_border_interrupt(machine(), 2, (col == 2)); |
| 705 | carpolo_generate_car_border_interrupt(2, (col == 2)); |
| 721 | 706 | else |
| 722 | 707 | { |
| 723 | | col = check_sprite_border_collision(machine(), car4_x, car4_y, car4_code, car4_flipy); |
| 708 | col = check_sprite_border_collision(car4_x, car4_y, car4_code, car4_flipy); |
| 724 | 709 | |
| 725 | 710 | if (col) |
| 726 | | carpolo_generate_car_border_interrupt(machine(), 3, (col == 2)); |
| 711 | carpolo_generate_car_border_interrupt(3, (col == 2)); |
| 727 | 712 | } |
| 728 | 713 | } |
| 729 | 714 | } |
trunk/src/mame/video/changela.c
| r20746 | r20747 | |
| 40 | 40 | |
| 41 | 41 | ***************************************************************************/ |
| 42 | 42 | |
| 43 | | static void draw_obj0( running_machine &machine, bitmap_ind16 &bitmap, int sy ) |
| 43 | void changela_state::draw_obj0( bitmap_ind16 &bitmap, int sy ) |
| 44 | 44 | { |
| 45 | | changela_state *state = machine.driver_data<changela_state>(); |
| 46 | 45 | int sx, i; |
| 47 | 46 | |
| 48 | | UINT8* ROM = state->memregion("user1")->base(); |
| 49 | | UINT8* RAM = state->m_spriteram; |
| 47 | UINT8* ROM = memregion("user1")->base(); |
| 48 | UINT8* RAM = m_spriteram; |
| 50 | 49 | |
| 51 | 50 | for (sx = 0; sx < 256; sx++) |
| 52 | 51 | { |
| r20746 | r20747 | |
| 103 | 102 | |
| 104 | 103 | ***************************************************************************/ |
| 105 | 104 | |
| 106 | | static void draw_obj1( running_machine &machine, bitmap_ind16 &bitmap ) |
| 105 | void changela_state::draw_obj1( bitmap_ind16 &bitmap ) |
| 107 | 106 | { |
| 108 | | changela_state *state = machine.driver_data<changela_state>(); |
| 109 | 107 | int sx, sy; |
| 110 | 108 | |
| 111 | | UINT8* ROM = state->memregion("gfx2")->base(); |
| 112 | | UINT8* RAM = state->m_videoram; |
| 109 | UINT8* ROM = memregion("gfx2")->base(); |
| 110 | UINT8* RAM = m_videoram; |
| 113 | 111 | |
| 114 | 112 | UINT8 reg[4] = { 0 }; /* 4x4-bit registers (U58, U59) */ |
| 115 | 113 | |
| r20746 | r20747 | |
| 168 | 166 | |
| 169 | 167 | ***************************************************************************/ |
| 170 | 168 | |
| 171 | | static void draw_river( running_machine &machine, bitmap_ind16 &bitmap, int sy ) |
| 169 | void changela_state::draw_river( bitmap_ind16 &bitmap, int sy ) |
| 172 | 170 | { |
| 173 | | changela_state *state = machine.driver_data<changela_state>(); |
| 174 | 171 | int sx, i, j; |
| 175 | 172 | |
| 176 | | UINT8* ROM = state->memregion("user2")->base(); |
| 177 | | UINT8* RAM = state->m_memory_devices + 0x800; |
| 178 | | UINT8* TILE_ROM = state->memregion("gfx1")->base(); |
| 179 | | UINT8* TILE_RAM = state->m_memory_devices + 0x1000; |
| 180 | | UINT8* PROM = state->memregion("proms")->base(); |
| 173 | UINT8* ROM = memregion("user2")->base(); |
| 174 | UINT8* RAM = m_memory_devices + 0x800; |
| 175 | UINT8* TILE_ROM = memregion("gfx1")->base(); |
| 176 | UINT8* TILE_RAM = m_memory_devices + 0x1000; |
| 177 | UINT8* PROM = memregion("proms")->base(); |
| 181 | 178 | |
| 182 | 179 | int preload = ((sy < 32) ? 1 : 0); |
| 183 | 180 | |
| r20746 | r20747 | |
| 194 | 191 | int carry = 0; |
| 195 | 192 | |
| 196 | 193 | /* Update Counters */ |
| 197 | | if (sy == 30) state->m_v_count_river = state->m_horizon; |
| 198 | | state->m_v_count_river = (state->m_v_count_river + 1) & 0xff; |
| 194 | if (sy == 30) m_v_count_river = m_horizon; |
| 195 | m_v_count_river = (m_v_count_river + 1) & 0xff; |
| 199 | 196 | |
| 200 | 197 | /* ----- STATE MACHINE ----- */ |
| 201 | 198 | for (i = 0; i < 0x20; i++) |
| r20746 | r20747 | |
| 219 | 216 | if (prev_state & 0x10) |
| 220 | 217 | hosc = (math_train[8] << 4) | math_train[9]; |
| 221 | 218 | |
| 222 | | rom_addr = state->m_slopeROM_bank | ((state->m_v_count_river & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); |
| 219 | rom_addr = m_slopeROM_bank | ((m_v_count_river & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); |
| 223 | 220 | ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01; |
| 224 | 221 | ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5); |
| 225 | 222 | mux45 = rom_count & 0x01; |
| 226 | | mux61 = state->m_v_count_river & 0x01; |
| 223 | mux61 = m_v_count_river & 0x01; |
| 227 | 224 | |
| 228 | 225 | switch (curr_state) |
| 229 | 226 | { |
| r20746 | r20747 | |
| 270 | 267 | prev_state = curr_state; |
| 271 | 268 | } |
| 272 | 269 | |
| 273 | | if (!(state->m_v_count_river & 0x80)) |
| 270 | if (!(m_v_count_river & 0x80)) |
| 274 | 271 | { |
| 275 | 272 | int h_count = 0x80 | (hosc >> 1); |
| 276 | 273 | int tile_v = ((math_train[3] & 0x0c) >> 2) | ((math_train[2] & 0x0f) << 2) | ((math_train[1] & 0x07) << 6); |
| r20746 | r20747 | |
| 347 | 344 | |
| 348 | 345 | ***************************************************************************/ |
| 349 | 346 | |
| 350 | | static void draw_tree( running_machine &machine, bitmap_ind16 &bitmap, int sy, int tree_num ) |
| 347 | void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num ) |
| 351 | 348 | { |
| 352 | | changela_state *state = machine.driver_data<changela_state>(); |
| 353 | 349 | int sx, i, j; |
| 354 | 350 | |
| 355 | 351 | /* State machine */ |
| 356 | | UINT8* ROM = state->memregion("user2")->base(); |
| 357 | | UINT8* RAM = state->m_memory_devices + 0x840 + 0x40 * tree_num; |
| 358 | | UINT8* PROM = state->memregion("proms")->base(); |
| 352 | UINT8* ROM = memregion("user2")->base(); |
| 353 | UINT8* RAM = m_memory_devices + 0x840 + 0x40 * tree_num; |
| 354 | UINT8* PROM = memregion("proms")->base(); |
| 359 | 355 | |
| 360 | 356 | /* Tree Data */ |
| 361 | | UINT8* RAM2 = state->m_tree_ram + 0x20 * tree_num; |
| 362 | | UINT8* TILE_ROM = (tree_num ? (state->memregion("user3")->base() + 0x1000) : (state->memregion("gfx1")->base() + 0x2000)); |
| 363 | | UINT8* TILE_RAM = (tree_num ? (state->memregion("user3")->base()) : (state->m_memory_devices + 0x1800)); |
| 357 | UINT8* RAM2 = m_tree_ram + 0x20 * tree_num; |
| 358 | UINT8* TILE_ROM = (tree_num ? (memregion("user3")->base() + 0x1000) : (memregion("gfx1")->base() + 0x2000)); |
| 359 | UINT8* TILE_RAM = (tree_num ? (memregion("user3")->base()) : (m_memory_devices + 0x1800)); |
| 364 | 360 | |
| 365 | 361 | int preload = ((sy < 32) ? 1 : 0); |
| 366 | 362 | |
| r20746 | r20747 | |
| 384 | 380 | /* Update Counters */ |
| 385 | 381 | if (sy == 30) |
| 386 | 382 | { |
| 387 | | state->m_tree_on[tree_num] = 0; |
| 383 | m_tree_on[tree_num] = 0; |
| 388 | 384 | if (tree_num == 0) |
| 389 | | state->m_v_count_tree = state->m_horizon; |
| 385 | m_v_count_tree = m_horizon; |
| 390 | 386 | } |
| 391 | 387 | if (tree_num == 0) |
| 392 | | state->m_v_count_tree = (state->m_v_count_tree + 1) & 0xff; |
| 388 | m_v_count_tree = (m_v_count_tree + 1) & 0xff; |
| 393 | 389 | |
| 394 | 390 | /* ----- STATE MACHINE ----- */ |
| 395 | 391 | for (i = 0; i < 0x20; i++) |
| r20746 | r20747 | |
| 416 | 412 | if (prev_state & 0x10) |
| 417 | 413 | hosc = (math_train[8] << 4) | math_train[9]; |
| 418 | 414 | |
| 419 | | rom_addr = state->m_slopeROM_bank | ((state->m_v_count_tree & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); |
| 415 | rom_addr = m_slopeROM_bank | ((m_v_count_tree & 0x7e) << 2) | ((rom_count & 0x0e) >> 1); |
| 420 | 416 | ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01; |
| 421 | 417 | ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5); |
| 422 | 418 | ram2_addr = (ram_count << 1) | ((curr_state & 0x20) >> 5); |
| 423 | 419 | mux45 = rom_count & 0x01; |
| 424 | | mux61 = state->m_v_count_tree & 0x01; |
| 420 | mux61 = m_v_count_tree & 0x01; |
| 425 | 421 | |
| 426 | 422 | switch(curr_state) |
| 427 | 423 | { |
| r20746 | r20747 | |
| 441 | 437 | break; |
| 442 | 438 | } |
| 443 | 439 | |
| 444 | | if (!state->m_tree_on[tree_num]) |
| 440 | if (!m_tree_on[tree_num]) |
| 445 | 441 | { |
| 446 | | int mux82 = (state->m_v_count_tree & 0x01) ^ 0x01; |
| 442 | int mux82 = (m_v_count_tree & 0x01) ^ 0x01; |
| 447 | 443 | |
| 448 | 444 | switch(curr_state) |
| 449 | 445 | { |
| r20746 | r20747 | |
| 531 | 527 | ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2); |
| 532 | 528 | rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6); |
| 533 | 529 | |
| 534 | | if (!(state->m_v_count_tree & 0x80) && (state->m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0)) |
| 535 | | state->m_tree_on[tree_num] = 1; |
| 530 | if (!(m_v_count_tree & 0x80) && (m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0)) |
| 531 | m_tree_on[tree_num] = 1; |
| 536 | 532 | |
| 537 | | if (state->m_tree_on[tree_num]) |
| 533 | if (m_tree_on[tree_num]) |
| 538 | 534 | { |
| 539 | 535 | if (tile_h & 0x01) |
| 540 | 536 | col = TILE_ROM[rom_addr] & 0x0f; |
| r20746 | r20747 | |
| 571 | 567 | ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2); |
| 572 | 568 | rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6); |
| 573 | 569 | |
| 574 | | if (!(state->m_v_count_tree & 0x80) && (state->m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0)) |
| 575 | | state->m_tree_on[tree_num] = 1; |
| 570 | if (!(m_v_count_tree & 0x80) && (m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0)) |
| 571 | m_tree_on[tree_num] = 1; |
| 576 | 572 | |
| 577 | | if (state->m_tree_on[tree_num]) |
| 573 | if (m_tree_on[tree_num]) |
| 578 | 574 | { |
| 579 | 575 | if (tile_h & 0x01) |
| 580 | 576 | col = TILE_ROM[rom_addr] & 0x0f; |
| r20746 | r20747 | |
| 591 | 587 | |
| 592 | 588 | /* Tree on only stays high if a pixel that is not 0xf is encountered, |
| 593 | 589 | because any non 0xf pixel sets U56 high */ |
| 594 | | if (all_ff) state->m_tree_on[tree_num] = 0; |
| 590 | if (all_ff) m_tree_on[tree_num] = 0; |
| 595 | 591 | } |
| 596 | 592 | |
| 597 | 593 | /* |
| r20746 | r20747 | |
| 655 | 651 | m_tree0_bitmap.fill(0x00, rect); |
| 656 | 652 | m_tree1_bitmap.fill(0x00, rect); |
| 657 | 653 | |
| 658 | | draw_river(machine(), m_river_bitmap, sy); |
| 659 | | draw_obj0(machine(), m_obj0_bitmap, sy); |
| 660 | | draw_tree(machine(), m_tree0_bitmap, sy, 0); |
| 661 | | draw_tree(machine(), m_tree1_bitmap, sy, 1); |
| 654 | draw_river(m_river_bitmap, sy); |
| 655 | draw_obj0(m_obj0_bitmap, sy); |
| 656 | draw_tree(m_tree0_bitmap, sy, 0); |
| 657 | draw_tree(m_tree1_bitmap, sy, 1); |
| 662 | 658 | |
| 663 | 659 | /* Collision Detection */ |
| 664 | 660 | for (sx = 1; sx < 256; sx++) |
| r20746 | r20747 | |
| 725 | 721 | copybitmap_trans(bitmap, m_obj0_bitmap, 0, 0, 0, 0, cliprect, 0); |
| 726 | 722 | copybitmap_trans(bitmap, m_tree0_bitmap, 0, 0, 0, 0, cliprect, 0); |
| 727 | 723 | copybitmap_trans(bitmap, m_tree1_bitmap, 0, 0, 0, 0, cliprect, 0); |
| 728 | | draw_obj1(machine(), bitmap); |
| 724 | draw_obj1(bitmap); |
| 729 | 725 | |
| 730 | 726 | return 0; |
| 731 | 727 | } |
trunk/src/mame/video/cclimber.c
| r20746 | r20747 | |
| 11 | 11 | #include "includes/cclimber.h" |
| 12 | 12 | |
| 13 | 13 | |
| 14 | | #define CCLIMBER_FLIP_X (state->m_flip_screen[0] & 0x01) |
| 15 | | #define CCLIMBER_FLIP_Y (state->m_flip_screen[1] & 0x01) |
| 14 | #define CCLIMBER_FLIP_X (m_flip_screen[0] & 0x01) |
| 15 | #define CCLIMBER_FLIP_Y (m_flip_screen[1] & 0x01) |
| 16 | 16 | #define CCLIMBER_BG_PEN (0) |
| 17 | 17 | #define SWIMMER_SIDE_BG_PEN (0x120) |
| 18 | 18 | #define SWIMMER_BG_SPLIT (0x18 * 8) |
| r20746 | r20747 | |
| 300 | 300 | |
| 301 | 301 | ***************************************************************************/ |
| 302 | 302 | |
| 303 | | static void swimmer_set_background_pen(running_machine &machine) |
| 303 | void cclimber_state::swimmer_set_background_pen() |
| 304 | 304 | { |
| 305 | | cclimber_state *state = machine.driver_data<cclimber_state>(); |
| 306 | 305 | int bit0, bit1, bit2; |
| 307 | 306 | int r, g, b; |
| 308 | 307 | |
| 309 | 308 | /* red component */ |
| 310 | 309 | bit0 = 0; |
| 311 | | bit1 = (*state->m_swimmer_background_color >> 6) & 0x01; |
| 312 | | bit2 = (*state->m_swimmer_background_color >> 7) & 0x01; |
| 310 | bit1 = (*m_swimmer_background_color >> 6) & 0x01; |
| 311 | bit2 = (*m_swimmer_background_color >> 7) & 0x01; |
| 313 | 312 | r = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2; |
| 314 | 313 | |
| 315 | 314 | /* green component */ |
| 316 | | bit0 = (*state->m_swimmer_background_color >> 3) & 0x01; |
| 317 | | bit1 = (*state->m_swimmer_background_color >> 4) & 0x01; |
| 318 | | bit2 = (*state->m_swimmer_background_color >> 5) & 0x01; |
| 315 | bit0 = (*m_swimmer_background_color >> 3) & 0x01; |
| 316 | bit1 = (*m_swimmer_background_color >> 4) & 0x01; |
| 317 | bit2 = (*m_swimmer_background_color >> 5) & 0x01; |
| 319 | 318 | g = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2; |
| 320 | 319 | |
| 321 | 320 | /* blue component */ |
| 322 | | bit0 = (*state->m_swimmer_background_color >> 0) & 0x01; |
| 323 | | bit1 = (*state->m_swimmer_background_color >> 1) & 0x01; |
| 324 | | bit2 = (*state->m_swimmer_background_color >> 2) & 0x01; |
| 321 | bit0 = (*m_swimmer_background_color >> 0) & 0x01; |
| 322 | bit1 = (*m_swimmer_background_color >> 1) & 0x01; |
| 323 | bit2 = (*m_swimmer_background_color >> 2) & 0x01; |
| 325 | 324 | b = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2; |
| 326 | 325 | |
| 327 | | palette_set_color(machine, CCLIMBER_BG_PEN, MAKE_RGB(r, g, b)); |
| 326 | palette_set_color(machine(), CCLIMBER_BG_PEN, MAKE_RGB(r, g, b)); |
| 328 | 327 | } |
| 329 | 328 | |
| 330 | 329 | |
| r20746 | r20747 | |
| 480 | 479 | } |
| 481 | 480 | |
| 482 | 481 | |
| 483 | | static void draw_playfield(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 482 | void cclimber_state::draw_playfield(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 484 | 483 | { |
| 485 | | cclimber_state *state = machine.driver_data<cclimber_state>(); |
| 486 | 484 | int i; |
| 487 | 485 | |
| 488 | | state->m_pf_tilemap->mark_all_dirty(); |
| 489 | | state->m_pf_tilemap->set_flip((CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | |
| 486 | m_pf_tilemap->mark_all_dirty(); |
| 487 | m_pf_tilemap->set_flip((CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | |
| 490 | 488 | (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0)); |
| 491 | 489 | for (i = 0; i < 32; i++) |
| 492 | | state->m_pf_tilemap->set_scrolly(i, state->m_column_scroll[i]); |
| 490 | m_pf_tilemap->set_scrolly(i, m_column_scroll[i]); |
| 493 | 491 | |
| 494 | | state->m_pf_tilemap->draw(bitmap, cliprect, 0, 0); |
| 492 | m_pf_tilemap->draw(bitmap, cliprect, 0, 0); |
| 495 | 493 | } |
| 496 | 494 | |
| 497 | 495 | |
| 498 | | static void cclimber_draw_bigsprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 496 | void cclimber_state::cclimber_draw_bigsprite(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 499 | 497 | { |
| 500 | | cclimber_state *state = machine.driver_data<cclimber_state>(); |
| 501 | | UINT8 x = state->m_bigsprite_control[3] - 8; |
| 502 | | UINT8 y = state->m_bigsprite_control[2]; |
| 503 | | int bigsprite_flip_x = (state->m_bigsprite_control[1] & 0x10) >> 4; |
| 504 | | int bigsprite_flip_y = (state->m_bigsprite_control[1] & 0x20) >> 5; |
| 498 | UINT8 x = m_bigsprite_control[3] - 8; |
| 499 | UINT8 y = m_bigsprite_control[2]; |
| 500 | int bigsprite_flip_x = (m_bigsprite_control[1] & 0x10) >> 4; |
| 501 | int bigsprite_flip_y = (m_bigsprite_control[1] & 0x20) >> 5; |
| 505 | 502 | |
| 506 | 503 | if (bigsprite_flip_x) |
| 507 | 504 | x = 0x80 - x; |
| r20746 | r20747 | |
| 509 | 506 | if (bigsprite_flip_y) |
| 510 | 507 | y = 0x80 - y; |
| 511 | 508 | |
| 512 | | state->m_bs_tilemap->mark_all_dirty(); |
| 509 | m_bs_tilemap->mark_all_dirty(); |
| 513 | 510 | |
| 514 | | state->m_bs_tilemap->set_flip((bigsprite_flip_x ? TILEMAP_FLIPX : 0) | |
| 511 | m_bs_tilemap->set_flip((bigsprite_flip_x ? TILEMAP_FLIPX : 0) | |
| 515 | 512 | (CCLIMBER_FLIP_Y ^ bigsprite_flip_y ? TILEMAP_FLIPY : 0)); |
| 516 | 513 | |
| 517 | | state->m_bs_tilemap->set_scrollx(0, x); |
| 518 | | state->m_bs_tilemap->set_scrolly(0, y); |
| 514 | m_bs_tilemap->set_scrollx(0, x); |
| 515 | m_bs_tilemap->set_scrolly(0, y); |
| 519 | 516 | |
| 520 | | state->m_bs_tilemap->draw(bitmap, cliprect, 0, 0); |
| 517 | m_bs_tilemap->draw(bitmap, cliprect, 0, 0); |
| 521 | 518 | } |
| 522 | 519 | |
| 523 | 520 | |
| 524 | | static void toprollr_draw_bigsprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 521 | void cclimber_state::toprollr_draw_bigsprite(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 525 | 522 | { |
| 526 | | cclimber_state *state = machine.driver_data<cclimber_state>(); |
| 527 | | UINT8 x = state->m_bigsprite_control[3] - 8; |
| 528 | | UINT8 y = state->m_bigsprite_control[2]; |
| 523 | UINT8 x = m_bigsprite_control[3] - 8; |
| 524 | UINT8 y = m_bigsprite_control[2]; |
| 529 | 525 | |
| 530 | | state->m_bs_tilemap->mark_all_dirty(); |
| 526 | m_bs_tilemap->mark_all_dirty(); |
| 531 | 527 | |
| 532 | | state->m_bs_tilemap->set_flip(CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0); |
| 528 | m_bs_tilemap->set_flip(CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0); |
| 533 | 529 | |
| 534 | | state->m_bs_tilemap->set_scrollx(0, x); |
| 535 | | state->m_bs_tilemap->set_scrolly(0, y); |
| 530 | m_bs_tilemap->set_scrollx(0, x); |
| 531 | m_bs_tilemap->set_scrolly(0, y); |
| 536 | 532 | |
| 537 | | state->m_bs_tilemap->draw(bitmap, cliprect, 0, 0); |
| 533 | m_bs_tilemap->draw(bitmap, cliprect, 0, 0); |
| 538 | 534 | } |
| 539 | 535 | |
| 540 | 536 | |
| 541 | | static void cclimber_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx) |
| 537 | void cclimber_state::cclimber_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx) |
| 542 | 538 | { |
| 543 | | cclimber_state *state = gfx->machine().driver_data<cclimber_state>(); |
| 544 | 539 | int offs; |
| 545 | 540 | |
| 546 | 541 | /* draw the sprites -- note that it is important to draw them exactly in this |
| 547 | 542 | order, to have the correct priorities. */ |
| 548 | 543 | for (offs = 0x1c; offs >= 0; offs -= 4) |
| 549 | 544 | { |
| 550 | | int x = state->m_spriteram[offs + 3] + 1; |
| 545 | int x = m_spriteram[offs + 3] + 1; |
| 551 | 546 | /* x + 1 is evident in cclimber and ckong. It looks worse, |
| 552 | 547 | but it has been confirmed on several PCBs. */ |
| 553 | 548 | |
| 554 | | int y = 240 - state->m_spriteram[offs + 2]; |
| 549 | int y = 240 - m_spriteram[offs + 2]; |
| 555 | 550 | |
| 556 | | int code = ((state->m_spriteram[offs + 1] & 0x10) << 3) | |
| 557 | | ((state->m_spriteram[offs + 1] & 0x20) << 1) | |
| 558 | | ( state->m_spriteram[offs + 0] & 0x3f); |
| 551 | int code = ((m_spriteram[offs + 1] & 0x10) << 3) | |
| 552 | ((m_spriteram[offs + 1] & 0x20) << 1) | |
| 553 | ( m_spriteram[offs + 0] & 0x3f); |
| 559 | 554 | |
| 560 | | int color = state->m_spriteram[offs + 1] & 0x0f; |
| 555 | int color = m_spriteram[offs + 1] & 0x0f; |
| 561 | 556 | |
| 562 | | int flipx = state->m_spriteram[offs + 0] & 0x40; |
| 563 | | int flipy = state->m_spriteram[offs + 0] & 0x80; |
| 557 | int flipx = m_spriteram[offs + 0] & 0x40; |
| 558 | int flipy = m_spriteram[offs + 0] & 0x80; |
| 564 | 559 | |
| 565 | 560 | if (CCLIMBER_FLIP_X) |
| 566 | 561 | { |
| r20746 | r20747 | |
| 579 | 574 | } |
| 580 | 575 | |
| 581 | 576 | |
| 582 | | static void toprollr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx) |
| 577 | void cclimber_state::toprollr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx) |
| 583 | 578 | { |
| 584 | | cclimber_state *state = gfx->machine().driver_data<cclimber_state>(); |
| 585 | 579 | int offs; |
| 586 | 580 | |
| 587 | 581 | /* draw the sprites -- note that it is important to draw them exactly in this |
| 588 | 582 | order, to have the correct priorities. */ |
| 589 | 583 | for (offs = 0x1c; offs >= 0; offs -= 4) |
| 590 | 584 | { |
| 591 | | int x = state->m_spriteram[offs + 3]; |
| 592 | | int y = 240 - state->m_spriteram[offs + 2]; |
| 585 | int x = m_spriteram[offs + 3]; |
| 586 | int y = 240 - m_spriteram[offs + 2]; |
| 593 | 587 | |
| 594 | | int code = ((state->m_spriteram[offs + 1] & 0x10) << 3) | |
| 595 | | ((state->m_spriteram[offs + 1] & 0x20) << 1) | |
| 596 | | ( state->m_spriteram[offs + 0] & 0x3f); |
| 588 | int code = ((m_spriteram[offs + 1] & 0x10) << 3) | |
| 589 | ((m_spriteram[offs + 1] & 0x20) << 1) | |
| 590 | ( m_spriteram[offs + 0] & 0x3f); |
| 597 | 591 | |
| 598 | | int color = state->m_spriteram[offs + 1] & 0x0f; |
| 592 | int color = m_spriteram[offs + 1] & 0x0f; |
| 599 | 593 | |
| 600 | | int flipx = state->m_spriteram[offs + 0] & 0x40; |
| 601 | | int flipy = state->m_spriteram[offs + 0] & 0x80; |
| 594 | int flipx = m_spriteram[offs + 0] & 0x40; |
| 595 | int flipy = m_spriteram[offs + 0] & 0x80; |
| 602 | 596 | |
| 603 | 597 | if (CCLIMBER_FLIP_X) |
| 604 | 598 | { |
| r20746 | r20747 | |
| 617 | 611 | } |
| 618 | 612 | |
| 619 | 613 | |
| 620 | | static void swimmer_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx) |
| 614 | void cclimber_state::swimmer_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx) |
| 621 | 615 | { |
| 622 | | cclimber_state *state = gfx->machine().driver_data<cclimber_state>(); |
| 623 | 616 | int offs; |
| 624 | 617 | |
| 625 | 618 | /* draw the sprites -- note that it is important to draw them exactly in this |
| 626 | 619 | order, to have the correct priorities. */ |
| 627 | 620 | for (offs = 0x1c; offs >= 0; offs -= 4) |
| 628 | 621 | { |
| 629 | | int x = state->m_spriteram[offs + 3]; |
| 630 | | int y = 240 - state->m_spriteram[offs + 2]; |
| 622 | int x = m_spriteram[offs + 3]; |
| 623 | int y = 240 - m_spriteram[offs + 2]; |
| 631 | 624 | |
| 632 | | int code = ((state->m_spriteram[offs + 1] & 0x10) << 2) | |
| 633 | | (state->m_spriteram[offs + 0] & 0x3f); |
| 625 | int code = ((m_spriteram[offs + 1] & 0x10) << 2) | |
| 626 | (m_spriteram[offs + 0] & 0x3f); |
| 634 | 627 | |
| 635 | | int color = ((*state->m_swimmer_palettebank & 0x01) << 4) | |
| 636 | | (state->m_spriteram[offs + 1] & 0x0f); |
| 628 | int color = ((*m_swimmer_palettebank & 0x01) << 4) | |
| 629 | (m_spriteram[offs + 1] & 0x0f); |
| 637 | 630 | |
| 638 | | int flipx = state->m_spriteram[offs + 0] & 0x40; |
| 639 | | int flipy = state->m_spriteram[offs + 0] & 0x80; |
| 631 | int flipx = m_spriteram[offs + 0] & 0x40; |
| 632 | int flipy = m_spriteram[offs + 0] & 0x80; |
| 640 | 633 | |
| 641 | 634 | if (CCLIMBER_FLIP_X) |
| 642 | 635 | { |
| r20746 | r20747 | |
| 658 | 651 | UINT32 cclimber_state::screen_update_cclimber(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 659 | 652 | { |
| 660 | 653 | bitmap.fill(CCLIMBER_BG_PEN, cliprect); |
| 661 | | draw_playfield(machine(), bitmap, cliprect); |
| 654 | draw_playfield(bitmap, cliprect); |
| 662 | 655 | |
| 663 | 656 | /* draw the "big sprite" under the regular sprites */ |
| 664 | 657 | if ((m_bigsprite_control[0] & 0x01)) |
| 665 | 658 | { |
| 666 | | cclimber_draw_bigsprite(machine(), bitmap, cliprect); |
| 659 | cclimber_draw_bigsprite(bitmap, cliprect); |
| 667 | 660 | cclimber_draw_sprites(bitmap, cliprect, machine().gfx[1]); |
| 668 | 661 | } |
| 669 | 662 | |
| r20746 | r20747 | |
| 671 | 664 | else |
| 672 | 665 | { |
| 673 | 666 | cclimber_draw_sprites(bitmap, cliprect, machine().gfx[1]); |
| 674 | | cclimber_draw_bigsprite(machine(), bitmap, cliprect); |
| 667 | cclimber_draw_bigsprite(bitmap, cliprect); |
| 675 | 668 | } |
| 676 | 669 | |
| 677 | 670 | return 0; |
| r20746 | r20747 | |
| 680 | 673 | |
| 681 | 674 | UINT32 cclimber_state::screen_update_yamato(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 682 | 675 | { |
| 683 | | cclimber_state *state = machine().driver_data<cclimber_state>(); |
| 684 | 676 | int i; |
| 685 | 677 | UINT8 *sky_rom = memregion("user1")->base() + 0x1200; |
| 686 | 678 | |
| r20746 | r20747 | |
| 693 | 685 | bitmap.pix16(j, (i - 8) & 0xff) = pen; |
| 694 | 686 | } |
| 695 | 687 | |
| 696 | | draw_playfield(machine(), bitmap, cliprect); |
| 688 | draw_playfield(bitmap, cliprect); |
| 697 | 689 | |
| 698 | 690 | /* draw the "big sprite" under the regular sprites */ |
| 699 | 691 | if ((m_bigsprite_control[0] & 0x01)) |
| 700 | 692 | { |
| 701 | | cclimber_draw_bigsprite(machine(), bitmap, cliprect); |
| 693 | cclimber_draw_bigsprite(bitmap, cliprect); |
| 702 | 694 | toprollr_draw_sprites(bitmap, cliprect, machine().gfx[1]); |
| 703 | 695 | } |
| 704 | 696 | |
| r20746 | r20747 | |
| 706 | 698 | else |
| 707 | 699 | { |
| 708 | 700 | toprollr_draw_sprites(bitmap, cliprect, machine().gfx[1]); |
| 709 | | cclimber_draw_bigsprite(machine(), bitmap, cliprect); |
| 701 | cclimber_draw_bigsprite(bitmap, cliprect); |
| 710 | 702 | } |
| 711 | 703 | |
| 712 | 704 | return 0; |
| r20746 | r20747 | |
| 715 | 707 | |
| 716 | 708 | UINT32 cclimber_state::screen_update_swimmer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 717 | 709 | { |
| 718 | | cclimber_state *state = machine().driver_data<cclimber_state>(); |
| 719 | | swimmer_set_background_pen(machine()); |
| 710 | swimmer_set_background_pen(); |
| 720 | 711 | |
| 721 | 712 | if (*m_swimmer_side_background_enabled & 0x01) |
| 722 | 713 | { |
| r20746 | r20747 | |
| 746 | 737 | else |
| 747 | 738 | bitmap.fill(CCLIMBER_BG_PEN, cliprect); |
| 748 | 739 | |
| 749 | | draw_playfield(machine(), bitmap, cliprect); |
| 740 | draw_playfield(bitmap, cliprect); |
| 750 | 741 | |
| 751 | 742 | /* draw the "big sprite" under the regular sprites */ |
| 752 | 743 | if ((m_bigsprite_control[0] & 0x01)) |
| 753 | 744 | { |
| 754 | | cclimber_draw_bigsprite(machine(), bitmap, cliprect); |
| 745 | cclimber_draw_bigsprite(bitmap, cliprect); |
| 755 | 746 | swimmer_draw_sprites(bitmap, cliprect, machine().gfx[1]); |
| 756 | 747 | } |
| 757 | 748 | |
| r20746 | r20747 | |
| 759 | 750 | else |
| 760 | 751 | { |
| 761 | 752 | swimmer_draw_sprites(bitmap, cliprect, machine().gfx[1]); |
| 762 | | cclimber_draw_bigsprite(machine(), bitmap, cliprect); |
| 753 | cclimber_draw_bigsprite(bitmap, cliprect); |
| 763 | 754 | } |
| 764 | 755 | |
| 765 | 756 | return 0; |
| r20746 | r20747 | |
| 768 | 759 | |
| 769 | 760 | UINT32 cclimber_state::screen_update_toprollr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 770 | 761 | { |
| 771 | | cclimber_state *state = machine().driver_data<cclimber_state>(); |
| 772 | 762 | rectangle scroll_area_clip = cliprect; |
| 773 | 763 | scroll_area_clip.min_x = 4*8; |
| 774 | 764 | scroll_area_clip.max_x = 29*8-1; |
| r20746 | r20747 | |
| 785 | 775 | if ((m_bigsprite_control[1] & 0x20)) |
| 786 | 776 | { |
| 787 | 777 | toprollr_draw_sprites(bitmap, scroll_area_clip, machine().gfx[1]); |
| 788 | | toprollr_draw_bigsprite(machine(), bitmap, scroll_area_clip); |
| 778 | toprollr_draw_bigsprite(bitmap, scroll_area_clip); |
| 789 | 779 | } |
| 790 | 780 | |
| 791 | 781 | /* draw the "big sprite" under the regular sprites */ |
| 792 | 782 | else |
| 793 | 783 | { |
| 794 | | toprollr_draw_bigsprite(machine(), bitmap, scroll_area_clip); |
| 784 | toprollr_draw_bigsprite(bitmap, scroll_area_clip); |
| 795 | 785 | toprollr_draw_sprites(bitmap, scroll_area_clip, machine().gfx[1]); |
| 796 | 786 | } |
| 797 | 787 | |
trunk/src/mame/video/cischeat.c
| r20746 | r20747 | |
| 111 | 111 | |
| 112 | 112 | ***************************************************************************/ |
| 113 | 113 | |
| 114 | | static void prepare_shadows(cischeat_state *state) |
| 114 | void cischeat_state::prepare_shadows(cischeat_state *state) |
| 115 | 115 | { |
| 116 | 116 | int i; |
| 117 | 117 | for (i = 0;i < 16;i++) |
| 118 | | state->m_drawmode_table[i] = DRAWMODE_SOURCE; |
| 118 | m_drawmode_table[i] = DRAWMODE_SOURCE; |
| 119 | 119 | |
| 120 | | state->m_drawmode_table[ 0] = DRAWMODE_SHADOW; |
| 121 | | state->m_drawmode_table[15] = DRAWMODE_NONE; |
| 120 | m_drawmode_table[ 0] = DRAWMODE_SHADOW; |
| 121 | m_drawmode_table[15] = DRAWMODE_NONE; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /************************************************************************** |
| r20746 | r20747 | |
| 129 | 129 | #define TILES_PER_PAGE_Y (0x20) |
| 130 | 130 | #define TILES_PER_PAGE (TILES_PER_PAGE_X * TILES_PER_PAGE_Y) |
| 131 | 131 | |
| 132 | | INLINE void scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which) |
| 132 | inline void cischeat_state::scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which) |
| 133 | 133 | { |
| 134 | | cischeat_state *state = space.machine().driver_data<cischeat_state>(); |
| 135 | | COMBINE_DATA(&state->m_scrollram[which][offset]); |
| 136 | | if (offset < 0x40000/2 && state->m_tmap[which]) |
| 134 | COMBINE_DATA(&m_scrollram[which][offset]); |
| 135 | if (offset < 0x40000/2 && m_tmap[which]) |
| 137 | 136 | { |
| 138 | | if (state->m_scroll_flag[which] & 0x10) /* tiles are 8x8 */ |
| 137 | if (m_scroll_flag[which] & 0x10) /* tiles are 8x8 */ |
| 139 | 138 | { |
| 140 | | state->m_tmap[which]->mark_tile_dirty(offset); |
| 139 | m_tmap[which]->mark_tile_dirty(offset); |
| 141 | 140 | } |
| 142 | 141 | else |
| 143 | 142 | { |
| 144 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 0); |
| 145 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 1); |
| 146 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 2); |
| 147 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 3); |
| 143 | m_tmap[which]->mark_tile_dirty(offset*4 + 0); |
| 144 | m_tmap[which]->mark_tile_dirty(offset*4 + 1); |
| 145 | m_tmap[which]->mark_tile_dirty(offset*4 + 2); |
| 146 | m_tmap[which]->mark_tile_dirty(offset*4 + 3); |
| 148 | 147 | } |
| 149 | 148 | } |
| 150 | 149 | } |
| r20746 | r20747 | |
| 181 | 180 | SET_TILE_INFO_MEMBER(tmap, (code & 0xfff) * 4 + (tile_index & 3), code >> (16 - m_bits_per_color_code), 0); |
| 182 | 181 | } |
| 183 | 182 | |
| 184 | | static void create_tilemaps(running_machine &machine) |
| 183 | void cischeat_state::create_tilemaps() |
| 185 | 184 | { |
| 186 | | cischeat_state *state = machine.driver_data<cischeat_state>(); |
| 187 | 185 | int layer, i; |
| 188 | 186 | |
| 189 | 187 | for (layer = 0; layer < 3; layer++) |
| 190 | 188 | { |
| 191 | 189 | /* 16x16 tilemaps */ |
| 192 | | state->m_tilemap[layer][0][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state), |
| 190 | m_tilemap[layer][0][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this), |
| 193 | 191 | 8,8, TILES_PER_PAGE_X * 16, TILES_PER_PAGE_Y * 2); |
| 194 | | state->m_tilemap[layer][0][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state), |
| 192 | m_tilemap[layer][0][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this), |
| 195 | 193 | 8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 4); |
| 196 | | state->m_tilemap[layer][0][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state), |
| 194 | m_tilemap[layer][0][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this), |
| 197 | 195 | 8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 8); |
| 198 | | state->m_tilemap[layer][0][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state), |
| 196 | m_tilemap[layer][0][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this), |
| 199 | 197 | 8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 16); |
| 200 | 198 | |
| 201 | 199 | /* 8x8 tilemaps */ |
| 202 | | state->m_tilemap[layer][1][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state), |
| 200 | m_tilemap[layer][1][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this), |
| 203 | 201 | 8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 1); |
| 204 | | state->m_tilemap[layer][1][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state), |
| 202 | m_tilemap[layer][1][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this), |
| 205 | 203 | 8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2); |
| 206 | | state->m_tilemap[layer][1][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state), |
| 204 | m_tilemap[layer][1][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this), |
| 207 | 205 | 8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2); |
| 208 | | state->m_tilemap[layer][1][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state), |
| 206 | m_tilemap[layer][1][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this), |
| 209 | 207 | 8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 4); |
| 210 | 208 | |
| 211 | 209 | /* set user data and transparency */ |
| 212 | 210 | for (i = 0; i < 8; i++) |
| 213 | 211 | { |
| 214 | | state->m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer); |
| 215 | | state->m_tilemap[layer][i/4][i%4]->set_transparent_pen(15); |
| 212 | m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer); |
| 213 | m_tilemap[layer][i/4][i%4]->set_transparent_pen(15); |
| 216 | 214 | } |
| 217 | 215 | } |
| 218 | 216 | } |
| r20746 | r20747 | |
| 234 | 232 | |
| 235 | 233 | m_spriteram = &m_ram[0x8000/2]; |
| 236 | 234 | |
| 237 | | create_tilemaps(machine()); |
| 235 | create_tilemaps(); |
| 238 | 236 | m_tmap[0] = m_tilemap[0][0][0]; |
| 239 | 237 | m_tmap[1] = m_tilemap[1][0][0]; |
| 240 | 238 | m_tmap[2] = m_tilemap[2][0][0]; |
| r20746 | r20747 | |
| 700 | 698 | /* Draw the road in the given bitmap. The priority1 and priority2 parameters |
| 701 | 699 | specify the range of lines to draw */ |
| 702 | 700 | |
| 703 | | static void cischeat_draw_road(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency) |
| 701 | void cischeat_state::cischeat_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency) |
| 704 | 702 | { |
| 705 | | cischeat_state *state = machine.driver_data<cischeat_state>(); |
| 706 | 703 | int curr_code,sx,sy; |
| 707 | 704 | int min_priority, max_priority; |
| 708 | 705 | |
| 709 | 706 | rectangle rect = cliprect; |
| 710 | | gfx_element *gfx = machine.gfx[(road_num & 1)?5:4]; |
| 707 | gfx_element *gfx = machine().gfx[(road_num & 1)?5:4]; |
| 711 | 708 | |
| 712 | | UINT16 *roadram = state->m_roadram[road_num & 1]; |
| 709 | UINT16 *roadram = m_roadram[road_num & 1]; |
| 713 | 710 | |
| 714 | 711 | int min_y = rect.min_y; |
| 715 | 712 | int max_y = rect.max_y; |
| r20746 | r20747 | |
| 790 | 787 | /* Draw the road in the given bitmap. The priority1 and priority2 parameters |
| 791 | 788 | specify the range of lines to draw */ |
| 792 | 789 | |
| 793 | | static void f1gpstar_draw_road(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency) |
| 790 | void cischeat_state::f1gpstar_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency) |
| 794 | 791 | { |
| 795 | | cischeat_state *state = machine.driver_data<cischeat_state>(); |
| 796 | 792 | int sx,sy; |
| 797 | 793 | int xstart; |
| 798 | 794 | int min_priority, max_priority; |
| 799 | 795 | |
| 800 | 796 | rectangle rect = cliprect; |
| 801 | | gfx_element *gfx = machine.gfx[(road_num & 1)?5:4]; |
| 797 | gfx_element *gfx = machine().gfx[(road_num & 1)?5:4]; |
| 802 | 798 | |
| 803 | | UINT16 *roadram = state->m_roadram[road_num & 1]; |
| 799 | UINT16 *roadram = m_roadram[road_num & 1]; |
| 804 | 800 | |
| 805 | 801 | int min_y = rect.min_y; |
| 806 | 802 | int max_y = rect.max_y; |
| r20746 | r20747 | |
| 906 | 902 | sprites whose priority nibble is between 0 and 15 and whose |
| 907 | 903 | colour code's high bit is set. */ |
| 908 | 904 | |
| 909 | | static void cischeat_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2) |
| 905 | void cischeat_state::cischeat_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2) |
| 910 | 906 | { |
| 911 | | cischeat_state *state = machine.driver_data<cischeat_state>(); |
| 912 | 907 | int x, sx, flipx, xzoom, xscale, xdim, xnum, xstart, xend, xinc; |
| 913 | 908 | int y, sy, flipy, yzoom, yscale, ydim, ynum, ystart, yend, yinc; |
| 914 | 909 | int code, attr, color, size, shadow; |
| 915 | 910 | |
| 916 | 911 | int min_priority, max_priority, high_sprites; |
| 917 | 912 | |
| 918 | | UINT16 *source = state->m_spriteram; |
| 913 | UINT16 *source = m_spriteram; |
| 919 | 914 | const UINT16 *finish = source + 0x1000/2; |
| 920 | 915 | |
| 921 | 916 | |
| r20746 | r20747 | |
| 952 | 947 | |
| 953 | 948 | /* dimension of a tile after zoom */ |
| 954 | 949 | #ifdef MAME_DEBUG |
| 955 | | if ( machine.input().code_pressed(KEYCODE_Z) && machine.input().code_pressed(KEYCODE_M) ) |
| 950 | if ( machine().input().code_pressed(KEYCODE_Z) && machine().input().code_pressed(KEYCODE_M) ) |
| 956 | 951 | { |
| 957 | 952 | xdim = 16 << 16; |
| 958 | 953 | ydim = 16 << 16; |
| r20746 | r20747 | |
| 983 | 978 | continue; |
| 984 | 979 | |
| 985 | 980 | #ifdef MAME_DEBUG |
| 986 | | if ( (state->m_debugsprites) && ( ((attr & 0x0300)>>8) != (state->m_debugsprites-1) ) ) { continue; }; |
| 981 | if ( (m_debugsprites) && ( ((attr & 0x0300)>>8) != (m_debugsprites-1) ) ) { continue; }; |
| 987 | 982 | #endif |
| 988 | 983 | |
| 989 | 984 | xscale = xdim / 16; |
| r20746 | r20747 | |
| 1002 | 997 | if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } |
| 1003 | 998 | else { ystart = 0; yend = ynum; yinc = +1; } |
| 1004 | 999 | |
| 1005 | | state->m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; |
| 1000 | m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; |
| 1006 | 1001 | |
| 1007 | 1002 | for (y = ystart; y != yend; y += yinc) |
| 1008 | 1003 | { |
| 1009 | 1004 | for (x = xstart; x != xend; x += xinc) |
| 1010 | 1005 | { |
| 1011 | | drawgfxzoom_transtable(bitmap,cliprect,machine.gfx[3], |
| 1006 | drawgfxzoom_transtable(bitmap,cliprect,machine().gfx[3], |
| 1012 | 1007 | code++, |
| 1013 | 1008 | color, |
| 1014 | 1009 | flipx,flipy, |
| 1015 | 1010 | (sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000, |
| 1016 | | xscale, yscale, state->m_drawmode_table, machine.shadow_table); |
| 1011 | xscale, yscale, m_drawmode_table, machine().shadow_table); |
| 1017 | 1012 | } |
| 1018 | 1013 | } |
| 1019 | 1014 | #ifdef MAME_DEBUG |
| 1020 | 1015 | #if 0 |
| 1021 | | if (machine.input().code_pressed(KEYCODE_X)) |
| 1016 | if (machine().input().code_pressed(KEYCODE_X)) |
| 1022 | 1017 | { /* Display some info on each sprite */ |
| 1023 | 1018 | sprintf(buf, "%04x",attr); |
| 1024 | 1019 | ui_draw_text(buf, sx>>16, sy>>16); |
| r20746 | r20747 | |
| 1062 | 1057 | |
| 1063 | 1058 | ***************************************************************************/ |
| 1064 | 1059 | |
| 1065 | | static void bigrun_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2) |
| 1060 | void cischeat_state::bigrun_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2) |
| 1066 | 1061 | { |
| 1067 | | cischeat_state *state = machine.driver_data<cischeat_state>(); |
| 1068 | 1062 | int x, sx, flipx, xzoom, xscale, xdim, xnum, xstart, xend, xinc; |
| 1069 | 1063 | int y, sy, flipy, yzoom, yscale, ydim, ynum, ystart, yend, yinc; |
| 1070 | 1064 | int code, attr, color, size, shadow; |
| 1071 | 1065 | |
| 1072 | 1066 | int min_priority, max_priority, high_sprites; |
| 1073 | 1067 | |
| 1074 | | UINT16 *source = state->m_spriteram; |
| 1068 | UINT16 *source = m_spriteram; |
| 1075 | 1069 | const UINT16 *finish = source + 0x1000/2; |
| 1076 | 1070 | |
| 1077 | 1071 | /* Move the priority values in place */ |
| r20746 | r20747 | |
| 1109 | 1103 | |
| 1110 | 1104 | /* dimension of a tile after zoom */ |
| 1111 | 1105 | #ifdef MAME_DEBUG |
| 1112 | | if ( machine.input().code_pressed(KEYCODE_Z) && machine.input().code_pressed(KEYCODE_M) ) |
| 1106 | if ( machine().input().code_pressed(KEYCODE_Z) && machine().input().code_pressed(KEYCODE_M) ) |
| 1113 | 1107 | { |
| 1114 | 1108 | xdim = 16 << 16; |
| 1115 | 1109 | ydim = 16 << 16; |
| r20746 | r20747 | |
| 1138 | 1132 | continue; |
| 1139 | 1133 | |
| 1140 | 1134 | #ifdef MAME_DEBUG |
| 1141 | | if ( (state->m_debugsprites) && ( ((attr & 0x0300)>>8) != (state->m_debugsprites-1) ) ) { continue; }; |
| 1135 | if ( (m_debugsprites) && ( ((attr & 0x0300)>>8) != (m_debugsprites-1) ) ) { continue; }; |
| 1142 | 1136 | #endif |
| 1143 | 1137 | |
| 1144 | 1138 | xscale = xdim / 16; |
| r20746 | r20747 | |
| 1157 | 1151 | if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } |
| 1158 | 1152 | else { ystart = 0; yend = ynum; yinc = +1; } |
| 1159 | 1153 | |
| 1160 | | state->m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; |
| 1154 | m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; |
| 1161 | 1155 | |
| 1162 | 1156 | for (y = ystart; y != yend; y += yinc) |
| 1163 | 1157 | { |
| 1164 | 1158 | for (x = xstart; x != xend; x += xinc) |
| 1165 | 1159 | { |
| 1166 | | drawgfxzoom_transtable(bitmap,cliprect,machine.gfx[3], |
| 1160 | drawgfxzoom_transtable(bitmap,cliprect,machine().gfx[3], |
| 1167 | 1161 | code++, |
| 1168 | 1162 | color, |
| 1169 | 1163 | flipx,flipy, |
| 1170 | 1164 | (sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000, |
| 1171 | | xscale, yscale, state->m_drawmode_table, machine.shadow_table); |
| 1165 | xscale, yscale, m_drawmode_table, machine().shadow_table); |
| 1172 | 1166 | } |
| 1173 | 1167 | } |
| 1174 | 1168 | #ifdef MAME_DEBUG |
| 1175 | 1169 | #if 0 |
| 1176 | | if (machine.input().code_pressed(KEYCODE_X)) |
| 1170 | if (machine().input().code_pressed(KEYCODE_X)) |
| 1177 | 1171 | { /* Display some info on each sprite */ |
| 1178 | 1172 | sprintf(buf, "%04x",attr); |
| 1179 | 1173 | ui_draw_text(buf, sx>>16, sy>>16); |
| r20746 | r20747 | |
| 1253 | 1247 | |
| 1254 | 1248 | for (i = 7; i >= 4; i--) |
| 1255 | 1249 | { /* bitmap, road, min_priority, max_priority, transparency */ |
| 1256 | | if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,i,i,FALSE); |
| 1257 | | if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,i,i,TRUE); |
| 1250 | if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,i,i,FALSE); |
| 1251 | if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,i,i,TRUE); |
| 1258 | 1252 | } |
| 1259 | 1253 | |
| 1260 | 1254 | flag = 0; |
| r20746 | r20747 | |
| 1263 | 1257 | |
| 1264 | 1258 | for (i = 3; i >= 0; i--) |
| 1265 | 1259 | { /* bitmap, road, min_priority, max_priority, transparency */ |
| 1266 | | if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,i,i,TRUE); |
| 1267 | | if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,i,i,TRUE); |
| 1260 | if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,i,i,TRUE); |
| 1261 | if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,i,i,TRUE); |
| 1268 | 1262 | } |
| 1269 | 1263 | |
| 1270 | | if (m_active_layers & 0x08) bigrun_draw_sprites(machine(),bitmap,cliprect,15,0); |
| 1264 | if (m_active_layers & 0x08) bigrun_draw_sprites(bitmap,cliprect,15,0); |
| 1271 | 1265 | |
| 1272 | 1266 | cischeat_tmap_DRAW(2) |
| 1273 | 1267 | |
| r20746 | r20747 | |
| 1305 | 1299 | bitmap.fill(0, cliprect); |
| 1306 | 1300 | |
| 1307 | 1301 | /* bitmap, road, priority, transparency */ |
| 1308 | | if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,7,5,FALSE); |
| 1309 | | if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,7,5,TRUE); |
| 1302 | if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,7,5,FALSE); |
| 1303 | if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,7,5,TRUE); |
| 1310 | 1304 | |
| 1311 | 1305 | flag = 0; |
| 1312 | 1306 | cischeat_tmap_DRAW(0) |
| 1313 | 1307 | // else bitmap.fill(0, cliprect); |
| 1314 | 1308 | cischeat_tmap_DRAW(1) |
| 1315 | 1309 | |
| 1316 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,15,3); |
| 1317 | | if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,4,1,TRUE); |
| 1318 | | if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,4,1,TRUE); |
| 1319 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,2,2); |
| 1320 | | if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,0,0,TRUE); |
| 1321 | | if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,0,0,TRUE); |
| 1322 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,1,0); |
| 1310 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,15,3); |
| 1311 | if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,4,1,TRUE); |
| 1312 | if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,4,1,TRUE); |
| 1313 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,2,2); |
| 1314 | if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,0,0,TRUE); |
| 1315 | if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,0,0,TRUE); |
| 1316 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,1,0); |
| 1323 | 1317 | cischeat_tmap_DRAW(2) |
| 1324 | 1318 | |
| 1325 | 1319 | /* for the map screen */ |
| 1326 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,0+16,0+16); |
| 1320 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,0+16,0+16); |
| 1327 | 1321 | |
| 1328 | 1322 | |
| 1329 | 1323 | m_active_layers = active_layers1; |
| r20746 | r20747 | |
| 1363 | 1357 | /* 1: clouds 5, grad 7, road 0 2: clouds 5, grad 7, road 0, tunnel roof 0 */ |
| 1364 | 1358 | |
| 1365 | 1359 | /* road 1!! 0!! */ /* bitmap, road, min_priority, max_priority, transparency */ |
| 1366 | | if (m_active_layers & 0x20) f1gpstar_draw_road(machine(),bitmap,cliprect,1,6,7,TRUE); |
| 1367 | | if (m_active_layers & 0x10) f1gpstar_draw_road(machine(),bitmap,cliprect,0,6,7,TRUE); |
| 1360 | if (m_active_layers & 0x20) f1gpstar_draw_road(bitmap,cliprect,1,6,7,TRUE); |
| 1361 | if (m_active_layers & 0x10) f1gpstar_draw_road(bitmap,cliprect,0,6,7,TRUE); |
| 1368 | 1362 | |
| 1369 | 1363 | flag = 0; |
| 1370 | 1364 | cischeat_tmap_DRAW(0) |
| r20746 | r20747 | |
| 1372 | 1366 | cischeat_tmap_DRAW(1) |
| 1373 | 1367 | |
| 1374 | 1368 | /* road 1!! 0!! */ /* bitmap, road, min_priority, max_priority, transparency */ |
| 1375 | | if (m_active_layers & 0x20) f1gpstar_draw_road(machine(),bitmap,cliprect,1,1,5,TRUE); |
| 1376 | | if (m_active_layers & 0x10) f1gpstar_draw_road(machine(),bitmap,cliprect,0,1,5,TRUE); |
| 1369 | if (m_active_layers & 0x20) f1gpstar_draw_road(bitmap,cliprect,1,1,5,TRUE); |
| 1370 | if (m_active_layers & 0x10) f1gpstar_draw_road(bitmap,cliprect,0,1,5,TRUE); |
| 1377 | 1371 | |
| 1378 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,15,2); |
| 1372 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,15,2); |
| 1379 | 1373 | |
| 1380 | 1374 | /* road 1!! 0!! */ /* bitmap, road, min_priority, max_priority, transparency */ |
| 1381 | | if (m_active_layers & 0x20) f1gpstar_draw_road(machine(),bitmap,cliprect,1,0,0,TRUE); |
| 1382 | | if (m_active_layers & 0x10) f1gpstar_draw_road(machine(),bitmap,cliprect,0,0,0,TRUE); |
| 1375 | if (m_active_layers & 0x20) f1gpstar_draw_road(bitmap,cliprect,1,0,0,TRUE); |
| 1376 | if (m_active_layers & 0x10) f1gpstar_draw_road(bitmap,cliprect,0,0,0,TRUE); |
| 1383 | 1377 | |
| 1384 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,1,1); |
| 1378 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,1,1); |
| 1385 | 1379 | cischeat_tmap_DRAW(2) |
| 1386 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,0,0); |
| 1380 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,0,0); |
| 1387 | 1381 | |
| 1388 | 1382 | |
| 1389 | 1383 | m_active_layers = active_layers1; |
| r20746 | r20747 | |
| 1439 | 1433 | flag = 0; |
| 1440 | 1434 | cischeat_tmap_DRAW(0) |
| 1441 | 1435 | // no layer 1 |
| 1442 | | if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,0,15); |
| 1436 | if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,0,15); |
| 1443 | 1437 | cischeat_tmap_DRAW(2) |
| 1444 | 1438 | |
| 1445 | 1439 | m_active_layers = active_layers1; |
trunk/src/mame/video/circus.c
| r20746 | r20747 | |
| 39 | 39 | m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(circus_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | | static void draw_line( bitmap_ind16 &bitmap, const rectangle &cliprect, int x1, int y1, int x2, int y2, int dotted ) |
| 42 | void circus_state::draw_line( bitmap_ind16 &bitmap, const rectangle &cliprect, int x1, int y1, int x2, int y2, int dotted ) |
| 43 | 43 | { |
| 44 | 44 | /* Draws horizontal and Vertical lines only! */ |
| 45 | 45 | int count, skip; |
| r20746 | r20747 | |
| 58 | 58 | bitmap.pix16(y1, count) = 1; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | | static void draw_sprite_collision( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 61 | void circus_state::draw_sprite_collision( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 62 | 62 | { |
| 63 | | circus_state *state = machine.driver_data<circus_state>(); |
| 64 | | gfx_element *sprite_gfx = machine.gfx[1]; |
| 65 | | const UINT8 *sprite_data = sprite_gfx->get_data(state->m_clown_z); |
| 63 | gfx_element *sprite_gfx = machine().gfx[1]; |
| 64 | const UINT8 *sprite_data = sprite_gfx->get_data(m_clown_z); |
| 66 | 65 | int sx, sy, dx, dy; |
| 67 | 66 | int pixel, collision = 0; |
| 68 | 67 | |
| 69 | 68 | // draw sprite and check collision on a pixel basis |
| 70 | 69 | for (sy = 0; sy < 16; sy++) |
| 71 | 70 | { |
| 72 | | dy = state->m_clown_x + sy-1; |
| 71 | dy = m_clown_x + sy-1; |
| 73 | 72 | if (dy>=0 && dy<bitmap.height()) |
| 74 | 73 | { |
| 75 | 74 | for (sx = 0; sx < 16; sx++) |
| 76 | 75 | { |
| 77 | | dx = state->m_clown_y + sx; |
| 76 | dx = m_clown_y + sx; |
| 78 | 77 | if (dx>=0 && dx<bitmap.width()) |
| 79 | 78 | { |
| 80 | 79 | pixel = sprite_data[sy * sprite_gfx->rowbytes() + sx]; |
| 81 | 80 | if (pixel) |
| 82 | 81 | { |
| 83 | 82 | collision |= bitmap.pix16(dy, dx); |
| 84 | | bitmap.pix16(dy, dx) = machine.pens[pixel]; |
| 83 | bitmap.pix16(dy, dx) = machine().pens[pixel]; |
| 85 | 84 | } |
| 86 | 85 | } |
| 87 | 86 | } |
| r20746 | r20747 | |
| 89 | 88 | } |
| 90 | 89 | |
| 91 | 90 | if (collision) |
| 92 | | state->m_maincpu->set_input_line(0, ASSERT_LINE); |
| 91 | m_maincpu->set_input_line(0, ASSERT_LINE); |
| 93 | 92 | } |
| 94 | 93 | |
| 95 | | static void circus_draw_fg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 94 | void circus_state::circus_draw_fg( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 96 | 95 | { |
| 97 | 96 | /* The sync generator hardware is used to */ |
| 98 | 97 | /* draw the border and diving boards */ |
| r20746 | r20747 | |
| 111 | 110 | UINT32 circus_state::screen_update_circus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 112 | 111 | { |
| 113 | 112 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 114 | | circus_draw_fg(machine(), bitmap, cliprect); |
| 115 | | draw_sprite_collision(machine(), bitmap, cliprect); |
| 113 | circus_draw_fg(bitmap, cliprect); |
| 114 | draw_sprite_collision(bitmap, cliprect); |
| 116 | 115 | return 0; |
| 117 | 116 | } |
| 118 | 117 | |
| 119 | | static void robotbwl_draw_box( bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y ) |
| 118 | void circus_state::robotbwl_draw_box( bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y ) |
| 120 | 119 | { |
| 121 | 120 | /* Box */ |
| 122 | 121 | int ex = x + 24; |
| r20746 | r20747 | |
| 134 | 133 | draw_line(bitmap, cliprect, x + 16, y, x + 16, ey, 0); |
| 135 | 134 | } |
| 136 | 135 | |
| 137 | | static void robotbwl_draw_scoreboard( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 136 | void circus_state::robotbwl_draw_scoreboard( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 138 | 137 | { |
| 139 | 138 | int offs; |
| 140 | 139 | |
| r20746 | r20747 | |
| 159 | 158 | draw_line(bitmap, cliprect, 39 + 152, 137, 47 + 152, 137, 0); |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | | static void robotbwl_draw_bowling_alley( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 161 | void circus_state::robotbwl_draw_bowling_alley( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 163 | 162 | { |
| 164 | 163 | draw_line(bitmap, cliprect, 103, 17, 103, 205, 0); |
| 165 | 164 | draw_line(bitmap, cliprect, 111, 17, 111, 203, 1); |
| r20746 | r20747 | |
| 167 | 166 | draw_line(bitmap, cliprect, 144, 17, 144, 203, 1); |
| 168 | 167 | } |
| 169 | 168 | |
| 170 | | static void robotbwl_draw_ball( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 169 | void circus_state::robotbwl_draw_ball( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 171 | 170 | { |
| 172 | | circus_state *state = machine.driver_data<circus_state>(); |
| 173 | 171 | drawgfx_transpen(bitmap,/* Y is horizontal position */ |
| 174 | | cliprect,machine.gfx[1], |
| 175 | | state->m_clown_z, |
| 172 | cliprect,machine().gfx[1], |
| 173 | m_clown_z, |
| 176 | 174 | 0, |
| 177 | 175 | 0,0, |
| 178 | | state->m_clown_y + 8, state->m_clown_x + 8, 0); |
| 176 | m_clown_y + 8, m_clown_x + 8, 0); |
| 179 | 177 | } |
| 180 | 178 | |
| 181 | 179 | UINT32 circus_state::screen_update_robotbwl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r20746 | r20747 | |
| 183 | 181 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 184 | 182 | robotbwl_draw_scoreboard(bitmap, cliprect); |
| 185 | 183 | robotbwl_draw_bowling_alley(bitmap, cliprect); |
| 186 | | robotbwl_draw_ball(machine(), bitmap, cliprect); |
| 184 | robotbwl_draw_ball(bitmap, cliprect); |
| 187 | 185 | return 0; |
| 188 | 186 | } |
| 189 | 187 | |
| 190 | | static void crash_draw_car( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 188 | void circus_state::crash_draw_car( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 191 | 189 | { |
| 192 | | circus_state *state = machine.driver_data<circus_state>(); |
| 193 | 190 | drawgfx_transpen(bitmap,/* Y is horizontal position */ |
| 194 | | cliprect,machine.gfx[1], |
| 195 | | state->m_clown_z, |
| 191 | cliprect,machine().gfx[1], |
| 192 | m_clown_z, |
| 196 | 193 | 0, |
| 197 | 194 | 0,0, |
| 198 | | state->m_clown_y, state->m_clown_x - 1, 0); |
| 195 | m_clown_y, m_clown_x - 1, 0); |
| 199 | 196 | } |
| 200 | 197 | |
| 201 | 198 | UINT32 circus_state::screen_update_crash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 202 | 199 | { |
| 203 | 200 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 204 | | crash_draw_car(machine(), bitmap, cliprect); |
| 201 | crash_draw_car(bitmap, cliprect); |
| 205 | 202 | return 0; |
| 206 | 203 | } |
| 207 | 204 | |
| 208 | 205 | UINT32 circus_state::screen_update_ripcord(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 209 | 206 | { |
| 210 | 207 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 211 | | draw_sprite_collision(machine(), bitmap, cliprect); |
| 208 | draw_sprite_collision(bitmap, cliprect); |
| 212 | 209 | return 0; |
| 213 | 210 | } |
trunk/src/mame/drivers/cps3.c
| r20746 | r20747 | |
| 408 | 408 | #define CPS3_TRANSPARENCY_PEN_INDEX 2 |
| 409 | 409 | #define CPS3_TRANSPARENCY_PEN_INDEX_BLEND 3 |
| 410 | 410 | |
| 411 | | static void copy_from_nvram(running_machine &machine); |
| 412 | | |
| 413 | | INLINE void cps3_drawgfxzoom(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 411 | inline void cps3_state::cps3_drawgfxzoom(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 414 | 412 | unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy, |
| 415 | 413 | int transparency,int transparent_color, |
| 416 | 414 | int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask) |
| 417 | 415 | { |
| 418 | | cps3_state *state = gfx->machine().driver_data<cps3_state>(); |
| 419 | 416 | rectangle myclip; |
| 420 | 417 | |
| 421 | 418 | // UINT8 al; |
| r20746 | r20747 | |
| 449 | 446 | { |
| 450 | 447 | // const pen_t *pal = &gfx->colortable[gfx->granularity() * (color % gfx->colors())]; |
| 451 | 448 | UINT32 palbase = (gfx->granularity() * color) & 0x1ffff; |
| 452 | | const pen_t *pal = &state->m_mame_colours[palbase]; |
| 449 | const pen_t *pal = &m_mame_colours[palbase]; |
| 453 | 450 | const UINT8 *source_base = gfx->get_data(code % gfx->elements()); |
| 454 | 451 | |
| 455 | 452 | int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16; |
| r20746 | r20747 | |
| 625 | 622 | /* Encryption */ |
| 626 | 623 | |
| 627 | 624 | |
| 628 | | static UINT16 rotate_left(UINT16 value, int n) |
| 625 | UINT16 cps3_state::rotate_left(UINT16 value, int n) |
| 629 | 626 | { |
| 630 | 627 | int aux = value>>(16-n); |
| 631 | 628 | return ((value<<n)|aux)%0x10000; |
| 632 | 629 | } |
| 633 | 630 | |
| 634 | | static UINT16 rotxor(UINT16 val, UINT16 xorval) |
| 631 | UINT16 cps3_state::rotxor(UINT16 val, UINT16 xorval) |
| 635 | 632 | { |
| 636 | 633 | UINT16 res; |
| 637 | 634 | |
| r20746 | r20747 | |
| 642 | 639 | return res; |
| 643 | 640 | } |
| 644 | 641 | |
| 645 | | static UINT32 cps3_mask(UINT32 address, UINT32 key1, UINT32 key2) |
| 642 | UINT32 cps3_state::cps3_mask(UINT32 address, UINT32 key1, UINT32 key2) |
| 646 | 643 | { |
| 647 | 644 | UINT16 val; |
| 648 | 645 | |
| r20746 | r20747 | |
| 661 | 658 | return val | (val << 16); |
| 662 | 659 | } |
| 663 | 660 | |
| 664 | | static void cps3_decrypt_bios(running_machine &machine) |
| 661 | void cps3_state::cps3_decrypt_bios() |
| 665 | 662 | { |
| 666 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 667 | 663 | int i; |
| 668 | | UINT32 *coderegion = (UINT32*)state->memregion("user1")->base(); |
| 664 | UINT32 *coderegion = (UINT32*)memregion("user1")->base(); |
| 669 | 665 | |
| 670 | | state->m_decrypted_bios = (UINT32*)state->memregion("user1")->base(); |
| 666 | m_decrypted_bios = (UINT32*)memregion("user1")->base(); |
| 671 | 667 | |
| 672 | 668 | for (i=0;i<0x80000;i+=4) |
| 673 | 669 | { |
| 674 | 670 | UINT32 dword = coderegion[i/4]; |
| 675 | | UINT32 xormask = cps3_mask(i, state->m_key1, state->m_key2); |
| 676 | | state->m_decrypted_bios[i/4] = dword ^ xormask; |
| 671 | UINT32 xormask = cps3_mask(i, m_key1, m_key2); |
| 672 | m_decrypted_bios[i/4] = dword ^ xormask; |
| 677 | 673 | } |
| 678 | 674 | #if 0 |
| 679 | 675 | /* Dump to file */ |
| 680 | 676 | { |
| 681 | 677 | FILE *fp; |
| 682 | | const char *gamename = machine.system().name; |
| 678 | const char *gamename = machine().system().name; |
| 683 | 679 | char filename[256]; |
| 684 | 680 | sprintf(filename, "%s_bios.dump", gamename); |
| 685 | 681 | |
| 686 | 682 | fp=fopen(filename, "w+b"); |
| 687 | 683 | if (fp) |
| 688 | 684 | { |
| 689 | | fwrite(state->m_decrypted_bios, 0x080000, 1, fp); |
| 685 | fwrite(m_decrypted_bios, 0x080000, 1, fp); |
| 690 | 686 | fclose(fp); |
| 691 | 687 | } |
| 692 | 688 | } |
| r20746 | r20747 | |
| 694 | 690 | } |
| 695 | 691 | |
| 696 | 692 | |
| 697 | | static void init_common(running_machine &machine, UINT32 key1, UINT32 key2, int altEncryption) |
| 693 | void cps3_state::init_common(UINT32 key1, UINT32 key2, int altEncryption) |
| 698 | 694 | { |
| 699 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 700 | 695 | |
| 701 | | state->m_key1 = key1; |
| 702 | | state->m_key2 = key2; |
| 703 | | state->m_altEncryption = altEncryption; |
| 696 | m_key1 = key1; |
| 697 | m_key2 = key2; |
| 698 | m_altEncryption = altEncryption; |
| 704 | 699 | |
| 705 | 700 | // cache pointers to regions |
| 706 | | state->m_user4region = state->memregion("user4")->base(); |
| 707 | | state->m_user5region = state->memregion("user5")->base(); |
| 701 | m_user4region = memregion("user4")->base(); |
| 702 | m_user5region = memregion("user5")->base(); |
| 708 | 703 | |
| 709 | | if (!state->m_user4region) state->m_user4region = auto_alloc_array(machine, UINT8, USER4REGION_LENGTH); |
| 710 | | if (!state->m_user5region) state->m_user5region = auto_alloc_array(machine, UINT8, USER5REGION_LENGTH); |
| 704 | if (!m_user4region) m_user4region = auto_alloc_array(machine(), UINT8, USER4REGION_LENGTH); |
| 705 | if (!m_user5region) m_user5region = auto_alloc_array(machine(), UINT8, USER5REGION_LENGTH); |
| 711 | 706 | |
| 712 | 707 | // set strict verify |
| 713 | | sh2drc_set_options(machine.device("maincpu"), SH2DRC_STRICT_VERIFY); |
| 708 | sh2drc_set_options(machine().device("maincpu"), SH2DRC_STRICT_VERIFY); |
| 714 | 709 | |
| 715 | | cps3_decrypt_bios(machine); |
| 716 | | state->m_decrypted_gamerom = auto_alloc_array(machine, UINT32, 0x1000000/4); |
| 710 | cps3_decrypt_bios(); |
| 711 | m_decrypted_gamerom = auto_alloc_array(machine(), UINT32, 0x1000000/4); |
| 717 | 712 | |
| 718 | 713 | /* just some NOPs for the game to execute if it crashes and starts executing unmapped addresses |
| 719 | 714 | - this prevents MAME from crashing */ |
| 720 | | state->m_nops = auto_alloc(machine, UINT32); |
| 721 | | state->m_nops[0] = 0x00090009; |
| 715 | m_nops = auto_alloc(machine(), UINT32); |
| 716 | m_nops[0] = 0x00090009; |
| 722 | 717 | |
| 723 | 718 | |
| 724 | | state->m_0xc0000000_ram_decrypted = auto_alloc_array(machine, UINT32, 0x400/4); |
| 719 | m_0xc0000000_ram_decrypted = auto_alloc_array(machine(), UINT32, 0x400/4); |
| 725 | 720 | |
| 726 | | address_space &main = machine.device<sh2_device>("maincpu")->space(AS_PROGRAM); |
| 727 | | main.set_direct_update_handler(direct_update_delegate(FUNC(cps3_state::cps3_direct_handler), state)); |
| 721 | address_space &main = machine().device<sh2_device>("maincpu")->space(AS_PROGRAM); |
| 722 | main.set_direct_update_handler(direct_update_delegate(FUNC(cps3_state::cps3_direct_handler), this)); |
| 728 | 723 | |
| 729 | 724 | // flash roms |
| 730 | 725 | astring tempstr; |
| 731 | 726 | for (int simmnum = 0; simmnum < 7; simmnum++) |
| 732 | 727 | for (int chipnum = 0; chipnum < 8; chipnum++) |
| 733 | | state->m_simm[simmnum][chipnum] = machine.device<fujitsu_29f016a_device>(tempstr.format("simm%d.%d", simmnum + 1, chipnum)); |
| 728 | m_simm[simmnum][chipnum] = machine().device<fujitsu_29f016a_device>(tempstr.format("simm%d.%d", simmnum + 1, chipnum)); |
| 734 | 729 | |
| 735 | | state->m_eeprom = auto_alloc_array(machine, UINT32, 0x400/4); |
| 736 | | machine.device<nvram_device>("eeprom")->set_base(state->m_eeprom, 0x400); |
| 730 | m_eeprom = auto_alloc_array(machine(), UINT32, 0x400/4); |
| 731 | machine().device<nvram_device>("eeprom")->set_base(m_eeprom, 0x400); |
| 737 | 732 | } |
| 738 | 733 | |
| 739 | | DRIVER_INIT_MEMBER(cps3_state,redearth) { init_common(machine(), 0x9e300ab1, 0xa175b82c, 0); } |
| 740 | | DRIVER_INIT_MEMBER(cps3_state,sfiii) { init_common(machine(), 0xb5fe053e, 0xfc03925a, 0); } |
| 741 | | DRIVER_INIT_MEMBER(cps3_state,sfiii2) { init_common(machine(), 0x00000000, 0x00000000, 1); } |
| 742 | | DRIVER_INIT_MEMBER(cps3_state,jojo) { init_common(machine(), 0x02203ee3, 0x01301972, 0); } |
| 743 | | DRIVER_INIT_MEMBER(cps3_state,sfiii3) { init_common(machine(), 0xa55432b4, 0x0c129981, 0); } |
| 744 | | DRIVER_INIT_MEMBER(cps3_state,jojoba) { init_common(machine(), 0x23323ee3, 0x03021972, 0); } |
| 734 | DRIVER_INIT_MEMBER(cps3_state,redearth) { init_common(0x9e300ab1, 0xa175b82c, 0); } |
| 735 | DRIVER_INIT_MEMBER(cps3_state,sfiii) { init_common(0xb5fe053e, 0xfc03925a, 0); } |
| 736 | DRIVER_INIT_MEMBER(cps3_state,sfiii2) { init_common(0x00000000, 0x00000000, 1); } |
| 737 | DRIVER_INIT_MEMBER(cps3_state,jojo) { init_common(0x02203ee3, 0x01301972, 0); } |
| 738 | DRIVER_INIT_MEMBER(cps3_state,sfiii3) { init_common(0xa55432b4, 0x0c129981, 0); } |
| 739 | DRIVER_INIT_MEMBER(cps3_state,jojoba) { init_common(0x23323ee3, 0x03021972, 0); } |
| 745 | 740 | |
| 746 | 741 | |
| 747 | 742 | |
| r20746 | r20747 | |
| 775 | 770 | }; |
| 776 | 771 | |
| 777 | 772 | |
| 778 | | static void cps3_set_mame_colours(running_machine &machine, int colournum, UINT16 data, UINT32 fadeval) |
| 773 | void cps3_state::cps3_set_mame_colours(int colournum, UINT16 data, UINT32 fadeval) |
| 779 | 774 | { |
| 780 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 781 | 775 | int r,g,b; |
| 782 | | UINT16* dst = (UINT16*)state->m_colourram.target(); |
| 776 | UINT16* dst = (UINT16*)m_colourram.target(); |
| 783 | 777 | |
| 784 | 778 | |
| 785 | 779 | r = (data >> 0) & 0x1f; |
| r20746 | r20747 | |
| 809 | 803 | |
| 810 | 804 | dst[colournum] = data; |
| 811 | 805 | |
| 812 | | state->m_mame_colours[colournum] = (r << (16+3)) | (g << (8+3)) | (b << (0+3)); |
| 806 | m_mame_colours[colournum] = (r << (16+3)) | (g << (8+3)) | (b << (0+3)); |
| 813 | 807 | |
| 814 | | if (colournum<0x10000) palette_set_color(machine,colournum,state->m_mame_colours[colournum]/* MAKE_RGB(r<<3,g<<3,b<<3)*/);//state->m_mame_colours[colournum]); |
| 808 | if (colournum<0x10000) palette_set_color(machine(),colournum,m_mame_colours[colournum]/* MAKE_RGB(r<<3,g<<3,b<<3)*/);//m_mame_colours[colournum]); |
| 815 | 809 | } |
| 816 | 810 | |
| 817 | 811 | |
| r20746 | r20747 | |
| 853 | 847 | |
| 854 | 848 | // the 0x400 bit in the tilemap regs is "draw it upside-down" (bios tilemap during flashing, otherwise capcom logo is flipped) |
| 855 | 849 | |
| 856 | | static void cps3_draw_tilemapsprite_line(running_machine &machine, int tmnum, int drawline, bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
| 850 | void cps3_state::cps3_draw_tilemapsprite_line(int tmnum, int drawline, bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
| 857 | 851 | { |
| 858 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 859 | | UINT32* tmapregs[4] = { state->m_tilemap20_regs_base, state->m_tilemap30_regs_base, state->m_tilemap40_regs_base, state->m_tilemap50_regs_base }; |
| 852 | UINT32* tmapregs[4] = { m_tilemap20_regs_base, m_tilemap30_regs_base, m_tilemap40_regs_base, m_tilemap50_regs_base }; |
| 860 | 853 | UINT32* regs; |
| 861 | 854 | int line; |
| 862 | 855 | int scrolly; |
| r20746 | r20747 | |
| 897 | 890 | // printf("linebase %08x\n", linebase); |
| 898 | 891 | |
| 899 | 892 | scrollx = (regs[0]&0xffff0000)>>16; |
| 900 | | scrollx+= (state->m_spriteram[linebase+((line+16-4)&0x3ff)]>>16)&0x3ff; |
| 893 | scrollx+= (m_spriteram[linebase+((line+16-4)&0x3ff)]>>16)&0x3ff; |
| 901 | 894 | |
| 902 | 895 | } |
| 903 | 896 | |
| r20746 | r20747 | |
| 917 | 910 | int bpp; |
| 918 | 911 | int xflip,yflip; |
| 919 | 912 | |
| 920 | | dat = state->m_spriteram[mapbase+((tileline&63)*64)+((x+scrollx/16)&63)]; |
| 913 | dat = m_spriteram[mapbase+((tileline&63)*64)+((x+scrollx/16)&63)]; |
| 921 | 914 | tileno = (dat & 0xffff0000)>>17; |
| 922 | 915 | colour = (dat & 0x000001ff)>>0; |
| 923 | 916 | bpp = (dat & 0x0000200)>>9; |
| 924 | 917 | yflip = (dat & 0x00000800)>>11; |
| 925 | 918 | xflip = (dat & 0x00001000)>>12; |
| 926 | 919 | |
| 927 | | if (!bpp) machine.gfx[1]->set_granularity(256); |
| 928 | | else machine.gfx[1]->set_granularity(64); |
| 920 | if (!bpp) machine().gfx[1]->set_granularity(256); |
| 921 | else machine().gfx[1]->set_granularity(64); |
| 929 | 922 | |
| 930 | | cps3_drawgfxzoom(bitmap,clip,machine.gfx[1],tileno,colour,xflip,yflip,(x*16)-scrollx%16,drawline-tilesubline,CPS3_TRANSPARENCY_PEN_INDEX,0, 0x10000, 0x10000, NULL, 0); |
| 923 | cps3_drawgfxzoom(bitmap,clip,machine().gfx[1],tileno,colour,xflip,yflip,(x*16)-scrollx%16,drawline-tilesubline,CPS3_TRANSPARENCY_PEN_INDEX,0, 0x10000, 0x10000, NULL, 0); |
| 931 | 924 | } |
| 932 | 925 | } |
| 933 | 926 | } |
| r20746 | r20747 | |
| 1080 | 1073 | { |
| 1081 | 1074 | for (uu=0;uu<1023;uu++) |
| 1082 | 1075 | { |
| 1083 | | cps3_draw_tilemapsprite_line(machine(), tilemapnum, uu, m_renderbuffer_bitmap, m_renderbuffer_clip ); |
| 1076 | cps3_draw_tilemapsprite_line(tilemapnum, uu, m_renderbuffer_bitmap, m_renderbuffer_clip ); |
| 1084 | 1077 | } |
| 1085 | 1078 | } |
| 1086 | 1079 | bg_drawn[tilemapnum] = 1; |
| r20746 | r20747 | |
| 1453 | 1446 | |
| 1454 | 1447 | |
| 1455 | 1448 | |
| 1456 | | static UINT32 cps3_flashmain_r(address_space &space, int which, UINT32 offset, UINT32 mem_mask) |
| 1449 | UINT32 cps3_state::cps3_flashmain_r(address_space &space, int which, UINT32 offset, UINT32 mem_mask) |
| 1457 | 1450 | { |
| 1458 | | cps3_state *state = space.machine().driver_data<cps3_state>(); |
| 1459 | 1451 | UINT32 result = 0; |
| 1460 | 1452 | |
| 1461 | | if (state->m_simm[which][0] == NULL || state->m_simm[which][1] == NULL || state->m_simm[which][2] == NULL || state->m_simm[which][3] == NULL) |
| 1453 | if (m_simm[which][0] == NULL || m_simm[which][1] == NULL || m_simm[which][2] == NULL || m_simm[which][3] == NULL) |
| 1462 | 1454 | return 0xffffffff; |
| 1463 | 1455 | |
| 1464 | 1456 | if (ACCESSING_BITS_24_31) // Flash 1 |
| 1465 | 1457 | { |
| 1466 | 1458 | // logerror("read flash chip %d addr %02x\n", base+0, offset*4 ); |
| 1467 | | result |= (state->m_simm[which][0]->read(offset)<<24); |
| 1459 | result |= (m_simm[which][0]->read(offset)<<24); |
| 1468 | 1460 | } |
| 1469 | 1461 | if (ACCESSING_BITS_16_23) // Flash 1 |
| 1470 | 1462 | { |
| 1471 | 1463 | // logerror("read flash chip %d addr %02x\n", base+1, offset*4 ); |
| 1472 | | result |= (state->m_simm[which][1]->read(offset)<<16); |
| 1464 | result |= (m_simm[which][1]->read(offset)<<16); |
| 1473 | 1465 | } |
| 1474 | 1466 | if (ACCESSING_BITS_8_15) // Flash 1 |
| 1475 | 1467 | { |
| 1476 | 1468 | // logerror("read flash chip %d addr %02x\n", base+2, offset*4 ); |
| 1477 | | result |= (state->m_simm[which][2]->read(offset)<<8); |
| 1469 | result |= (m_simm[which][2]->read(offset)<<8); |
| 1478 | 1470 | } |
| 1479 | 1471 | if (ACCESSING_BITS_0_7) // Flash 1 |
| 1480 | 1472 | { |
| 1481 | 1473 | // logerror("read flash chip %d addr %02x\n", base+3, offset*4 ); |
| 1482 | | result |= (state->m_simm[which][3]->read(offset)<<0); |
| 1474 | result |= (m_simm[which][3]->read(offset)<<0); |
| 1483 | 1475 | } |
| 1484 | 1476 | |
| 1485 | 1477 | // if (base==4) logerror("read flash chips addr %02x returning %08x\n", offset*4, result ); |
| r20746 | r20747 | |
| 1509 | 1501 | return retvalue; |
| 1510 | 1502 | } |
| 1511 | 1503 | |
| 1512 | | static void cps3_flashmain_w(running_machine &machine, int which, UINT32 offset, UINT32 data, UINT32 mem_mask) |
| 1504 | void cps3_state::cps3_flashmain_w(int which, UINT32 offset, UINT32 data, UINT32 mem_mask) |
| 1513 | 1505 | { |
| 1514 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 1515 | 1506 | int command; |
| 1516 | 1507 | |
| 1517 | | if (state->m_simm[which][0] == NULL || state->m_simm[which][1] == NULL || state->m_simm[which][2] == NULL || state->m_simm[which][3] == NULL) |
| 1508 | if (m_simm[which][0] == NULL || m_simm[which][1] == NULL || m_simm[which][2] == NULL || m_simm[which][3] == NULL) |
| 1518 | 1509 | return; |
| 1519 | 1510 | |
| 1520 | 1511 | if (ACCESSING_BITS_24_31) // Flash 1 |
| 1521 | 1512 | { |
| 1522 | 1513 | command = (data >> 24) & 0xff; |
| 1523 | | logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][0]->tag(), offset, command); |
| 1524 | | state->m_simm[which][0]->write(offset, command); |
| 1514 | logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][0]->tag(), offset, command); |
| 1515 | m_simm[which][0]->write(offset, command); |
| 1525 | 1516 | } |
| 1526 | 1517 | if (ACCESSING_BITS_16_23) // Flash 2 |
| 1527 | 1518 | { |
| 1528 | 1519 | command = (data >> 16) & 0xff; |
| 1529 | | logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][1]->tag(), offset, command); |
| 1530 | | state->m_simm[which][1]->write(offset, command); |
| 1520 | logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][1]->tag(), offset, command); |
| 1521 | m_simm[which][1]->write(offset, command); |
| 1531 | 1522 | } |
| 1532 | 1523 | if (ACCESSING_BITS_8_15) // Flash 2 |
| 1533 | 1524 | { |
| 1534 | 1525 | command = (data >> 8) & 0xff; |
| 1535 | | logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][2]->tag(), offset, command); |
| 1536 | | state->m_simm[which][2]->write(offset, command); |
| 1526 | logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][2]->tag(), offset, command); |
| 1527 | m_simm[which][2]->write(offset, command); |
| 1537 | 1528 | } |
| 1538 | 1529 | if (ACCESSING_BITS_0_7) // Flash 2 |
| 1539 | 1530 | { |
| 1540 | 1531 | command = (data >> 0) & 0xff; |
| 1541 | | logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][3]->tag(), offset, command); |
| 1542 | | state->m_simm[which][3]->write(offset, command); |
| 1532 | logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][3]->tag(), offset, command); |
| 1533 | m_simm[which][3]->write(offset, command); |
| 1543 | 1534 | } |
| 1544 | 1535 | |
| 1545 | 1536 | /* copy data into regions to execute from */ |
| 1546 | 1537 | { |
| 1547 | | UINT32* romdata = (UINT32*)state->m_user4region; |
| 1548 | | UINT32* romdata2 = (UINT32*)state->m_decrypted_gamerom; |
| 1538 | UINT32* romdata = (UINT32*)m_user4region; |
| 1539 | UINT32* romdata2 = (UINT32*)m_decrypted_gamerom; |
| 1549 | 1540 | int real_offset = 0; |
| 1550 | 1541 | UINT32 newdata; |
| 1551 | 1542 | |
| r20746 | r20747 | |
| 1558 | 1549 | real_offset += 0x800000; |
| 1559 | 1550 | } |
| 1560 | 1551 | |
| 1561 | | newdata = (state->m_simm[which][0]->read_raw(offset)<<24) | |
| 1562 | | (state->m_simm[which][1]->read_raw(offset)<<16) | |
| 1563 | | (state->m_simm[which][2]->read_raw(offset)<<8) | |
| 1564 | | (state->m_simm[which][3]->read_raw(offset)<<0); |
| 1552 | newdata = (m_simm[which][0]->read_raw(offset)<<24) | |
| 1553 | (m_simm[which][1]->read_raw(offset)<<16) | |
| 1554 | (m_simm[which][2]->read_raw(offset)<<8) | |
| 1555 | (m_simm[which][3]->read_raw(offset)<<0); |
| 1565 | 1556 | |
| 1566 | | //printf("%08x %08x %08x %08x %08x\n",offset, romdata2[offset], romdata[offset], newdata, newdata^cps3_mask(0x6000000+real_offset, state->m_key1, state->m_key2) ); |
| 1557 | //printf("%08x %08x %08x %08x %08x\n",offset, romdata2[offset], romdata[offset], newdata, newdata^cps3_mask(0x6000000+real_offset, m_key1, m_key2) ); |
| 1567 | 1558 | |
| 1568 | 1559 | romdata[offset] = newdata; |
| 1569 | | romdata2[offset] = newdata^cps3_mask(0x6000000+real_offset, state->m_key1, state->m_key2); |
| 1560 | romdata2[offset] = newdata^cps3_mask(0x6000000+real_offset, m_key1, m_key2); |
| 1570 | 1561 | } |
| 1571 | 1562 | } |
| 1572 | 1563 | |
| 1573 | 1564 | WRITE32_MEMBER(cps3_state::cps3_flash1_w) |
| 1574 | 1565 | { |
| 1575 | | cps3_flashmain_w(machine(),0,offset,data,mem_mask); |
| 1566 | cps3_flashmain_w(0,offset,data,mem_mask); |
| 1576 | 1567 | } |
| 1577 | 1568 | |
| 1578 | 1569 | WRITE32_MEMBER(cps3_state::cps3_flash2_w) |
| 1579 | 1570 | { |
| 1580 | | cps3_flashmain_w(machine(),1,offset,data,mem_mask); |
| 1571 | cps3_flashmain_w(1,offset,data,mem_mask); |
| 1581 | 1572 | } |
| 1582 | 1573 | |
| 1583 | 1574 | WRITE32_MEMBER(cps3_state::cram_gfxflash_bank_w) |
| r20746 | r20747 | |
| 1778 | 1769 | |
| 1779 | 1770 | //if (m_paldma_fade!=0) printf("%08x\n",m_paldma_fade); |
| 1780 | 1771 | |
| 1781 | | cps3_set_mame_colours(machine(), (m_paldma_dest+i)^1, coldata, m_paldma_fade); |
| 1772 | cps3_set_mame_colours((m_paldma_dest+i)^1, coldata, m_paldma_fade); |
| 1782 | 1773 | } |
| 1783 | 1774 | |
| 1784 | 1775 | |
| r20746 | r20747 | |
| 1797 | 1788 | |
| 1798 | 1789 | |
| 1799 | 1790 | |
| 1800 | | static UINT32 process_byte( running_machine &machine, UINT8 real_byte, UINT32 destination, int max_length ) |
| 1791 | UINT32 cps3_state::process_byte( UINT8 real_byte, UINT32 destination, int max_length ) |
| 1801 | 1792 | { |
| 1802 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 1803 | | UINT8* dest = (UINT8*)state->m_char_ram; |
| 1793 | UINT8* dest = (UINT8*)m_char_ram; |
| 1804 | 1794 | |
| 1805 | 1795 | //printf("process byte for destination %08x\n", destination); |
| 1806 | 1796 | |
| r20746 | r20747 | |
| 1811 | 1801 | int tranfercount = 0; |
| 1812 | 1802 | |
| 1813 | 1803 | //printf("Set RLE Mode\n"); |
| 1814 | | state->m_rle_length = (real_byte&0x3f)+1; |
| 1804 | m_rle_length = (real_byte&0x3f)+1; |
| 1815 | 1805 | |
| 1816 | | //printf("RLE Operation (length %08x\n", state->m_rle_length ); |
| 1806 | //printf("RLE Operation (length %08x\n", m_rle_length ); |
| 1817 | 1807 | |
| 1818 | | while (state->m_rle_length) |
| 1808 | while (m_rle_length) |
| 1819 | 1809 | { |
| 1820 | | dest[((destination+tranfercount)&0x7fffff)^3] = (state->m_last_normal_byte&0x3f); |
| 1821 | | machine.gfx[1]->mark_dirty(((destination+tranfercount)&0x7fffff)/0x100); |
| 1810 | dest[((destination+tranfercount)&0x7fffff)^3] = (m_last_normal_byte&0x3f); |
| 1811 | machine().gfx[1]->mark_dirty(((destination+tranfercount)&0x7fffff)/0x100); |
| 1822 | 1812 | //printf("RLE WRite Byte %08x, %02x\n", destination+tranfercount, real_byte); |
| 1823 | 1813 | |
| 1824 | 1814 | tranfercount++; |
| 1825 | | state->m_rle_length--; |
| 1815 | m_rle_length--; |
| 1826 | 1816 | max_length--; |
| 1827 | 1817 | |
| 1828 | 1818 | if ((destination+tranfercount) > 0x7fffff) return max_length; |
| r20746 | r20747 | |
| 1836 | 1826 | { |
| 1837 | 1827 | //printf("Write Normal Data\n"); |
| 1838 | 1828 | dest[(destination&0x7fffff)^3] = real_byte; |
| 1839 | | state->m_last_normal_byte = real_byte; |
| 1840 | | machine.gfx[1]->mark_dirty((destination&0x7fffff)/0x100); |
| 1829 | m_last_normal_byte = real_byte; |
| 1830 | machine().gfx[1]->mark_dirty((destination&0x7fffff)/0x100); |
| 1841 | 1831 | return 1; |
| 1842 | 1832 | } |
| 1843 | 1833 | } |
| 1844 | 1834 | |
| 1845 | | static void cps3_do_char_dma( running_machine &machine, UINT32 real_source, UINT32 real_destination, UINT32 real_length ) |
| 1835 | void cps3_state::cps3_do_char_dma( UINT32 real_source, UINT32 real_destination, UINT32 real_length ) |
| 1846 | 1836 | { |
| 1847 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 1848 | | UINT8* sourcedata = (UINT8*)state->m_user5region; |
| 1837 | UINT8* sourcedata = (UINT8*)m_user5region; |
| 1849 | 1838 | int length_remaining; |
| 1850 | 1839 | |
| 1851 | | state->m_last_normal_byte = 0; |
| 1852 | | state->m_rle_length = 0; |
| 1840 | m_last_normal_byte = 0; |
| 1841 | m_rle_length = 0; |
| 1853 | 1842 | length_remaining = real_length; |
| 1854 | 1843 | while (length_remaining) |
| 1855 | 1844 | { |
| r20746 | r20747 | |
| 1864 | 1853 | UINT32 length_processed; |
| 1865 | 1854 | current_byte &= 0x7f; |
| 1866 | 1855 | |
| 1867 | | real_byte = sourcedata[DMA_XOR((state->m_current_table_address+current_byte*2+0))]; |
| 1856 | real_byte = sourcedata[DMA_XOR((m_current_table_address+current_byte*2+0))]; |
| 1868 | 1857 | //if (real_byte&0x80) return; |
| 1869 | | length_processed = process_byte( machine, real_byte, real_destination, length_remaining ); |
| 1858 | length_processed = process_byte(real_byte, real_destination, length_remaining ); |
| 1870 | 1859 | length_remaining-=length_processed; // subtract the number of bytes the operation has taken |
| 1871 | 1860 | real_destination+=length_processed; // add it onto the destination |
| 1872 | 1861 | if (real_destination>0x7fffff) return; |
| 1873 | 1862 | if (length_remaining<=0) return; // if we've expired, exit |
| 1874 | 1863 | |
| 1875 | | real_byte = sourcedata[DMA_XOR((state->m_current_table_address+current_byte*2+1))]; |
| 1864 | real_byte = sourcedata[DMA_XOR((m_current_table_address+current_byte*2+1))]; |
| 1876 | 1865 | //if (real_byte&0x80) return; |
| 1877 | | length_processed = process_byte( machine, real_byte, real_destination, length_remaining ); |
| 1866 | length_processed = process_byte(real_byte, real_destination, length_remaining ); |
| 1878 | 1867 | length_remaining-=length_processed; // subtract the number of bytes the operation has taken |
| 1879 | 1868 | real_destination+=length_processed; // add it onto the destination |
| 1880 | 1869 | if (real_destination>0x7fffff) return; |
| r20746 | r20747 | |
| 1883 | 1872 | else |
| 1884 | 1873 | { |
| 1885 | 1874 | UINT32 length_processed; |
| 1886 | | length_processed = process_byte( machine, current_byte, real_destination, length_remaining ); |
| 1875 | length_processed = process_byte(current_byte, real_destination, length_remaining ); |
| 1887 | 1876 | length_remaining-=length_processed; // subtract the number of bytes the operation has taken |
| 1888 | 1877 | real_destination+=length_processed; // add it onto the destination |
| 1889 | 1878 | if (real_destination>0x7fffff) return; |
| r20746 | r20747 | |
| 1894 | 1883 | } |
| 1895 | 1884 | } |
| 1896 | 1885 | |
| 1897 | | static UINT32 ProcessByte8(running_machine &machine,UINT8 b,UINT32 dst_offset) |
| 1886 | UINT32 cps3_state::ProcessByte8(UINT8 b,UINT32 dst_offset) |
| 1898 | 1887 | { |
| 1899 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 1900 | | UINT8* destRAM = (UINT8*)state->m_char_ram; |
| 1888 | UINT8* destRAM = (UINT8*)m_char_ram; |
| 1901 | 1889 | int l=0; |
| 1902 | 1890 | |
| 1903 | | if(state->m_lastb==state->m_lastb2) //rle |
| 1891 | if(m_lastb==m_lastb2) //rle |
| 1904 | 1892 | { |
| 1905 | 1893 | int i; |
| 1906 | 1894 | int rle=(b+1)&0xff; |
| 1907 | 1895 | |
| 1908 | 1896 | for(i=0;i<rle;++i) |
| 1909 | 1897 | { |
| 1910 | | destRAM[(dst_offset&0x7fffff)^3] = state->m_lastb; |
| 1911 | | machine.gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100); |
| 1898 | destRAM[(dst_offset&0x7fffff)^3] = m_lastb; |
| 1899 | machine().gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100); |
| 1912 | 1900 | |
| 1913 | 1901 | dst_offset++; |
| 1914 | 1902 | ++l; |
| 1915 | 1903 | } |
| 1916 | | state->m_lastb2=0xffff; |
| 1904 | m_lastb2=0xffff; |
| 1917 | 1905 | |
| 1918 | 1906 | return l; |
| 1919 | 1907 | } |
| 1920 | 1908 | else |
| 1921 | 1909 | { |
| 1922 | | state->m_lastb2=state->m_lastb; |
| 1923 | | state->m_lastb=b; |
| 1910 | m_lastb2=m_lastb; |
| 1911 | m_lastb=b; |
| 1924 | 1912 | destRAM[(dst_offset&0x7fffff)^3] = b; |
| 1925 | | machine.gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100); |
| 1913 | machine().gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100); |
| 1926 | 1914 | return 1; |
| 1927 | 1915 | } |
| 1928 | 1916 | } |
| 1929 | 1917 | |
| 1930 | | static void cps3_do_alt_char_dma( running_machine &machine, UINT32 src, UINT32 real_dest, UINT32 real_length ) |
| 1918 | void cps3_state::cps3_do_alt_char_dma( UINT32 src, UINT32 real_dest, UINT32 real_length ) |
| 1931 | 1919 | { |
| 1932 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 1933 | | UINT8* px = (UINT8*)state->m_user5region; |
| 1920 | UINT8* px = (UINT8*)m_user5region; |
| 1934 | 1921 | UINT32 start = real_dest; |
| 1935 | 1922 | UINT32 ds = real_dest; |
| 1936 | 1923 | |
| 1937 | | state->m_lastb=0xfffe; |
| 1938 | | state->m_lastb2=0xffff; |
| 1924 | m_lastb=0xfffe; |
| 1925 | m_lastb2=0xffff; |
| 1939 | 1926 | |
| 1940 | 1927 | while(1) |
| 1941 | 1928 | { |
| r20746 | r20747 | |
| 1951 | 1938 | { |
| 1952 | 1939 | UINT8 real_byte; |
| 1953 | 1940 | p&=0x7f; |
| 1954 | | real_byte = px[DMA_XOR((state->m_current_table_address+p*2+0))]; |
| 1955 | | ds+=ProcessByte8(machine,real_byte,ds); |
| 1956 | | real_byte = px[DMA_XOR((state->m_current_table_address+p*2+1))]; |
| 1957 | | ds+=ProcessByte8(machine,real_byte,ds); |
| 1941 | real_byte = px[DMA_XOR((m_current_table_address+p*2+0))]; |
| 1942 | ds+=ProcessByte8(real_byte,ds); |
| 1943 | real_byte = px[DMA_XOR((m_current_table_address+p*2+1))]; |
| 1944 | ds+=ProcessByte8(real_byte,ds); |
| 1958 | 1945 | } |
| 1959 | 1946 | else |
| 1960 | 1947 | { |
| 1961 | | ds+=ProcessByte8(machine,p,ds); |
| 1948 | ds+=ProcessByte8(p,ds); |
| 1962 | 1949 | } |
| 1963 | 1950 | ++src; |
| 1964 | 1951 | ctrl<<=1; |
| r20746 | r20747 | |
| 1969 | 1956 | } |
| 1970 | 1957 | } |
| 1971 | 1958 | |
| 1972 | | static void cps3_process_character_dma(running_machine &machine, UINT32 address) |
| 1959 | void cps3_state::cps3_process_character_dma(UINT32 address) |
| 1973 | 1960 | { |
| 1974 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 1975 | 1961 | int i; |
| 1976 | 1962 | |
| 1977 | 1963 | //printf("charDMA start:\n"); |
| 1978 | 1964 | |
| 1979 | 1965 | for (i = 0; i < 0x1000; i += 3) |
| 1980 | 1966 | { |
| 1981 | | UINT32 dat1 = LITTLE_ENDIANIZE_INT32(state->m_char_ram[i + 0 + (address)]); |
| 1982 | | UINT32 dat2 = LITTLE_ENDIANIZE_INT32(state->m_char_ram[i + 1 + (address)]); |
| 1983 | | UINT32 dat3 = LITTLE_ENDIANIZE_INT32(state->m_char_ram[i + 2 + (address)]); |
| 1967 | UINT32 dat1 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 0 + (address)]); |
| 1968 | UINT32 dat2 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 1 + (address)]); |
| 1969 | UINT32 dat3 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 2 + (address)]); |
| 1984 | 1970 | UINT32 real_source = (dat3 << 1) - 0x400000; |
| 1985 | 1971 | UINT32 real_destination = dat2 << 3; |
| 1986 | 1972 | UINT32 real_length = (((dat1 & 0x001fffff) + 1) << 3); |
| r20746 | r20747 | |
| 1995 | 1981 | /* Sets a table used by the decompression routines */ |
| 1996 | 1982 | { |
| 1997 | 1983 | /* We should probably copy this, but a pointer to it is fine for our purposes as the data doesn't change */ |
| 1998 | | state->m_current_table_address = real_source; |
| 1984 | m_current_table_address = real_source; |
| 1999 | 1985 | } |
| 2000 | | machine.device("maincpu")->execute().set_input_line(10, ASSERT_LINE); |
| 1986 | machine().device("maincpu")->execute().set_input_line(10, ASSERT_LINE); |
| 2001 | 1987 | } |
| 2002 | 1988 | else if ((dat1 & 0x00e00000) == 0x00400000) |
| 2003 | 1989 | { |
| 2004 | 1990 | /* 6bpp DMA decompression |
| 2005 | 1991 | - this is used for the majority of sprites and backgrounds */ |
| 2006 | | cps3_do_char_dma( machine, real_source, real_destination, real_length ); |
| 2007 | | machine.device("maincpu")->execute().set_input_line(10, ASSERT_LINE); |
| 1992 | cps3_do_char_dma(real_source, real_destination, real_length ); |
| 1993 | machine().device("maincpu")->execute().set_input_line(10, ASSERT_LINE); |
| 2008 | 1994 | |
| 2009 | 1995 | } |
| 2010 | 1996 | else if ((dat1 & 0x00e00000) == 0x00600000) |
| 2011 | 1997 | { |
| 2012 | 1998 | /* 8bpp DMA decompression |
| 2013 | 1999 | - this is used on SFIII NG Sean's Stage ONLY */ |
| 2014 | | cps3_do_alt_char_dma( machine, real_source, real_destination, real_length); |
| 2015 | | machine.device("maincpu")->execute().set_input_line(10, ASSERT_LINE); |
| 2000 | cps3_do_alt_char_dma(real_source, real_destination, real_length); |
| 2001 | machine().device("maincpu")->execute().set_input_line(10, ASSERT_LINE); |
| 2016 | 2002 | } |
| 2017 | 2003 | else |
| 2018 | 2004 | { |
| r20746 | r20747 | |
| 2051 | 2037 | list_address = (m_chardma_source | ((m_chardma_other&0x003f0000))); |
| 2052 | 2038 | |
| 2053 | 2039 | //printf("chardma_w activated %08x %08x (address = cram %08x)\n", m_chardma_source, m_chardma_other, list_address*4 ); |
| 2054 | | cps3_process_character_dma(machine(), list_address); |
| 2040 | cps3_process_character_dma(list_address); |
| 2055 | 2041 | } |
| 2056 | 2042 | else |
| 2057 | 2043 | { |
| r20746 | r20747 | |
| 2096 | 2082 | |
| 2097 | 2083 | if (ACCESSING_BITS_24_31) |
| 2098 | 2084 | { |
| 2099 | | cps3_set_mame_colours(machine(), offset*2, (data & 0xffff0000) >> 16, 0); |
| 2085 | cps3_set_mame_colours(offset*2, (data & 0xffff0000) >> 16, 0); |
| 2100 | 2086 | } |
| 2101 | 2087 | |
| 2102 | 2088 | if (ACCESSING_BITS_0_7) |
| 2103 | 2089 | { |
| 2104 | | cps3_set_mame_colours(machine(), offset*2+1, (data & 0x0000ffff) >> 0, 0); |
| 2090 | cps3_set_mame_colours(offset*2+1, (data & 0x0000ffff) >> 0, 0); |
| 2105 | 2091 | } |
| 2106 | 2092 | } |
| 2107 | 2093 | |
| r20746 | r20747 | |
| 2268 | 2254 | m_current_table_address = -1; |
| 2269 | 2255 | |
| 2270 | 2256 | // copy data from flashroms back into user regions + decrypt into regions we execute/draw from. |
| 2271 | | copy_from_nvram(machine()); |
| 2257 | copy_from_nvram(); |
| 2272 | 2258 | } |
| 2273 | 2259 | |
| 2274 | 2260 | |
| 2275 | 2261 | |
| 2276 | 2262 | // make a copy in the regions we execute code / draw gfx from |
| 2277 | | static void copy_from_nvram(running_machine &machine) |
| 2263 | void cps3_state::copy_from_nvram() |
| 2278 | 2264 | { |
| 2279 | | cps3_state *state = machine.driver_data<cps3_state>(); |
| 2280 | | UINT32* romdata = (UINT32*)state->m_user4region; |
| 2281 | | UINT32* romdata2 = (UINT32*)state->m_decrypted_gamerom; |
| 2265 | UINT32* romdata = (UINT32*)m_user4region; |
| 2266 | UINT32* romdata2 = (UINT32*)m_decrypted_gamerom; |
| 2282 | 2267 | int i; |
| 2283 | 2268 | /* copy + decrypt program roms which have been loaded from flashroms/nvram */ |
| 2284 | 2269 | for (i=0;i<0x800000;i+=4) |
| 2285 | 2270 | { |
| 2286 | 2271 | UINT32 data; |
| 2287 | 2272 | |
| 2288 | | data = ((state->m_simm[0][0]->read_raw(i/4)<<24) | (state->m_simm[0][1]->read_raw(i/4)<<16) | (state->m_simm[0][2]->read_raw(i/4)<<8) | (state->m_simm[0][3]->read_raw(i/4)<<0)); |
| 2273 | data = ((m_simm[0][0]->read_raw(i/4)<<24) | (m_simm[0][1]->read_raw(i/4)<<16) | (m_simm[0][2]->read_raw(i/4)<<8) | (m_simm[0][3]->read_raw(i/4)<<0)); |
| 2289 | 2274 | |
| 2290 | | // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6000000, state->m_key1, state->m_key2)); |
| 2275 | // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6000000, m_key1, m_key2)); |
| 2291 | 2276 | romdata[i/4] = data; |
| 2292 | | romdata2[i/4] = data ^ cps3_mask(i+0x6000000, state->m_key1, state->m_key2); |
| 2277 | romdata2[i/4] = data ^ cps3_mask(i+0x6000000, m_key1, m_key2); |
| 2293 | 2278 | |
| 2294 | 2279 | } |
| 2295 | 2280 | |
| 2296 | 2281 | romdata += 0x800000/4; |
| 2297 | 2282 | romdata2 += 0x800000/4; |
| 2298 | 2283 | |
| 2299 | | if (state->m_simm[1][0] != NULL) |
| 2284 | if (m_simm[1][0] != NULL) |
| 2300 | 2285 | for (i=0;i<0x800000;i+=4) |
| 2301 | 2286 | { |
| 2302 | 2287 | UINT32 data; |
| 2303 | 2288 | |
| 2304 | | data = ((state->m_simm[1][0]->read_raw(i/4)<<24) | (state->m_simm[1][1]->read_raw(i/4)<<16) | (state->m_simm[1][2]->read_raw(i/4)<<8) | (state->m_simm[1][3]->read_raw(i/4)<<0)); |
| 2289 | data = ((m_simm[1][0]->read_raw(i/4)<<24) | (m_simm[1][1]->read_raw(i/4)<<16) | (m_simm[1][2]->read_raw(i/4)<<8) | (m_simm[1][3]->read_raw(i/4)<<0)); |
| 2305 | 2290 | |
| 2306 | | // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6800000, state->m_key1, state->m_key2) ); |
| 2291 | // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6800000, m_key1, m_key2) ); |
| 2307 | 2292 | romdata[i/4] = data; |
| 2308 | | romdata2[i/4] = data ^ cps3_mask(i+0x6800000, state->m_key1, state->m_key2); |
| 2293 | romdata2[i/4] = data ^ cps3_mask(i+0x6800000, m_key1, m_key2); |
| 2309 | 2294 | } |
| 2310 | 2295 | |
| 2311 | 2296 | /* copy gfx from loaded flashroms to user reigon 5, where it's used */ |
| r20746 | r20747 | |
| 2314 | 2299 | int flashnum = 0; |
| 2315 | 2300 | int countoffset = 0; |
| 2316 | 2301 | |
| 2317 | | romdata = (UINT32*)state->m_user5region; |
| 2302 | romdata = (UINT32*)m_user5region; |
| 2318 | 2303 | for (thebase = 0;thebase < len/2; thebase+=0x200000) |
| 2319 | 2304 | { |
| 2320 | 2305 | // printf("flashnums %d. %d\n",flashnum, flashnum+1); |
| 2321 | 2306 | |
| 2322 | | fujitsu_29f016a_device *flash0 = state->m_simm[2 + flashnum/8][flashnum % 8 + 0]; |
| 2323 | | fujitsu_29f016a_device *flash1 = state->m_simm[2 + flashnum/8][flashnum % 8 + 1]; |
| 2307 | fujitsu_29f016a_device *flash0 = m_simm[2 + flashnum/8][flashnum % 8 + 0]; |
| 2308 | fujitsu_29f016a_device *flash1 = m_simm[2 + flashnum/8][flashnum % 8 + 1]; |
| 2324 | 2309 | if (flash0 == NULL || flash1 == NULL) |
| 2325 | 2310 | continue; |
| 2326 | 2311 | if (flash0 != NULL && flash1 != NULL) |
| r20746 | r20747 | |
| 2346 | 2331 | /* |
| 2347 | 2332 | { |
| 2348 | 2333 | FILE *fp; |
| 2349 | | const char *gamename = machine.system().name; |
| 2334 | const char *gamename = machine().system().name; |
| 2350 | 2335 | char filename[256]; |
| 2351 | 2336 | sprintf(filename, "%s_bios.dump", gamename); |
| 2352 | 2337 | |
| r20746 | r20747 | |
| 2387 | 2372 | if (src<0x80000) |
| 2388 | 2373 | { |
| 2389 | 2374 | int offs = (src&0x07ffff)>>2; |
| 2390 | | data = data ^ cps3_mask(offs*4, state->m_key1, state->m_key2); |
| 2375 | data = data ^ state->cps3_mask(offs*4, state->m_key1, state->m_key2); |
| 2391 | 2376 | } |
| 2392 | 2377 | else if (src>=0x6000000 && src<0x6800000) |
| 2393 | 2378 | { |
| 2394 | 2379 | int offs = (src&0x07fffff)>>2; |
| 2395 | | if (!state->m_altEncryption) data = data ^ cps3_mask(0x6000000+offs*4, state->m_key1, state->m_key2); |
| 2380 | if (!state->m_altEncryption) data = data ^ state->cps3_mask(0x6000000+offs*4, state->m_key1, state->m_key2); |
| 2396 | 2381 | } |
| 2397 | 2382 | else if (src>=0x6800000 && src<0x7000000) |
| 2398 | 2383 | { |
| 2399 | 2384 | int offs = (src&0x07fffff)>>2; |
| 2400 | | if (!state->m_altEncryption) data = data ^ cps3_mask(0x6800000+offs*4, state->m_key1, state->m_key2); |
| 2385 | if (!state->m_altEncryption) data = data ^ state->cps3_mask(0x6800000+offs*4, state->m_key1, state->m_key2); |
| 2401 | 2386 | } |
| 2402 | 2387 | else |
| 2403 | 2388 | { |