trunk/src/mame/drivers/pirates.c
| r20973 | r20974 | |
| 335 | 335 | |
| 336 | 336 | /* Init */ |
| 337 | 337 | |
| 338 | | static void pirates_decrypt_68k(running_machine &machine) |
| 338 | void pirates_state::pirates_decrypt_68k() |
| 339 | 339 | { |
| 340 | 340 | int rom_size; |
| 341 | 341 | UINT16 *buf, *rom; |
| 342 | 342 | int i; |
| 343 | 343 | |
| 344 | | rom_size = machine.root_device().memregion("maincpu")->bytes(); |
| 344 | rom_size = machine().root_device().memregion("maincpu")->bytes(); |
| 345 | 345 | |
| 346 | | buf = auto_alloc_array(machine, UINT16, rom_size/2); |
| 346 | buf = auto_alloc_array(machine(), UINT16, rom_size/2); |
| 347 | 347 | |
| 348 | | rom = (UINT16 *)machine.root_device().memregion("maincpu")->base(); |
| 348 | rom = (UINT16 *)machine().root_device().memregion("maincpu")->base(); |
| 349 | 349 | memcpy (buf, rom, rom_size); |
| 350 | 350 | |
| 351 | 351 | for (i=0; i<rom_size/2; i++) |
| r20973 | r20974 | |
| 361 | 361 | |
| 362 | 362 | rom[i] = (vr<<8) | vl; |
| 363 | 363 | } |
| 364 | | auto_free (machine, buf); |
| 364 | auto_free (machine(), buf); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | | static void pirates_decrypt_p(running_machine &machine) |
| 367 | void pirates_state::pirates_decrypt_p() |
| 368 | 368 | { |
| 369 | 369 | int rom_size; |
| 370 | 370 | UINT8 *buf, *rom; |
| 371 | 371 | int i; |
| 372 | 372 | |
| 373 | | rom_size = machine.root_device().memregion("gfx1")->bytes(); |
| 373 | rom_size = machine().root_device().memregion("gfx1")->bytes(); |
| 374 | 374 | |
| 375 | | buf = auto_alloc_array(machine, UINT8, rom_size); |
| 375 | buf = auto_alloc_array(machine(), UINT8, rom_size); |
| 376 | 376 | |
| 377 | | rom = machine.root_device().memregion("gfx1")->base(); |
| 377 | rom = machine().root_device().memregion("gfx1")->base(); |
| 378 | 378 | memcpy (buf, rom, rom_size); |
| 379 | 379 | |
| 380 | 380 | for (i=0; i<rom_size/4; i++) |
| r20973 | r20974 | |
| 385 | 385 | rom[adr+2*(rom_size/4)] = BITSWAP8(buf[i+2*(rom_size/4)], 1,4,7,0,3,5,6,2); |
| 386 | 386 | rom[adr+3*(rom_size/4)] = BITSWAP8(buf[i+3*(rom_size/4)], 2,3,4,0,7,5,1,6); |
| 387 | 387 | } |
| 388 | | auto_free (machine, buf); |
| 388 | auto_free (machine(), buf); |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | | static void pirates_decrypt_s(running_machine &machine) |
| 391 | void pirates_state::pirates_decrypt_s() |
| 392 | 392 | { |
| 393 | 393 | int rom_size; |
| 394 | 394 | UINT8 *buf, *rom; |
| 395 | 395 | int i; |
| 396 | 396 | |
| 397 | | rom_size = machine.root_device().memregion("gfx2")->bytes(); |
| 397 | rom_size = machine().root_device().memregion("gfx2")->bytes(); |
| 398 | 398 | |
| 399 | | buf = auto_alloc_array(machine, UINT8, rom_size); |
| 399 | buf = auto_alloc_array(machine(), UINT8, rom_size); |
| 400 | 400 | |
| 401 | | rom = machine.root_device().memregion("gfx2")->base(); |
| 401 | rom = machine().root_device().memregion("gfx2")->base(); |
| 402 | 402 | memcpy (buf, rom, rom_size); |
| 403 | 403 | |
| 404 | 404 | for (i=0; i<rom_size/4; i++) |
| r20973 | r20974 | |
| 409 | 409 | rom[adr+2*(rom_size/4)] = BITSWAP8(buf[i+2*(rom_size/4)], 2,3,4,0,7,5,1,6); |
| 410 | 410 | rom[adr+3*(rom_size/4)] = BITSWAP8(buf[i+3*(rom_size/4)], 4,2,7,1,6,5,0,3); |
| 411 | 411 | } |
| 412 | | auto_free (machine, buf); |
| 412 | auto_free (machine(), buf); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | |
| 416 | | static void pirates_decrypt_oki(running_machine &machine) |
| 416 | void pirates_state::pirates_decrypt_oki() |
| 417 | 417 | { |
| 418 | 418 | int rom_size; |
| 419 | 419 | UINT8 *buf, *rom; |
| 420 | 420 | int i; |
| 421 | 421 | |
| 422 | | rom_size = machine.root_device().memregion("oki")->bytes(); |
| 422 | rom_size = machine().root_device().memregion("oki")->bytes(); |
| 423 | 423 | |
| 424 | | buf = auto_alloc_array(machine, UINT8, rom_size); |
| 424 | buf = auto_alloc_array(machine(), UINT8, rom_size); |
| 425 | 425 | |
| 426 | | rom = machine.root_device().memregion("oki")->base(); |
| 426 | rom = machine().root_device().memregion("oki")->base(); |
| 427 | 427 | memcpy (buf, rom, rom_size); |
| 428 | 428 | |
| 429 | 429 | for (i=0; i<rom_size; i++) |
| r20973 | r20974 | |
| 431 | 431 | int adr = BITSWAP24(i,23,22,21,20,19,10,16,13,8,4,7,11,14,17,12,6,2,0,5,18,15,3,1,9); |
| 432 | 432 | rom[adr] = BITSWAP8(buf[i], 2,3,4,0,7,5,1,6); |
| 433 | 433 | } |
| 434 | | auto_free (machine, buf); |
| 434 | auto_free (machine(), buf); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | |
| r20973 | r20974 | |
| 439 | 439 | { |
| 440 | 440 | UINT16 *rom = (UINT16 *)machine().root_device().memregion("maincpu")->base(); |
| 441 | 441 | |
| 442 | | pirates_decrypt_68k(machine()); |
| 443 | | pirates_decrypt_p(machine()); |
| 444 | | pirates_decrypt_s(machine()); |
| 445 | | pirates_decrypt_oki(machine()); |
| 442 | pirates_decrypt_68k(); |
| 443 | pirates_decrypt_p(); |
| 444 | pirates_decrypt_s(); |
| 445 | pirates_decrypt_oki(); |
| 446 | 446 | |
| 447 | 447 | /* patch out protection check */ |
| 448 | 448 | rom[0x62c0/2] = 0x6006; // beq -> bra |
| r20973 | r20974 | |
| 452 | 452 | |
| 453 | 453 | DRIVER_INIT_MEMBER(pirates_state,genix) |
| 454 | 454 | { |
| 455 | | pirates_decrypt_68k(machine()); |
| 456 | | pirates_decrypt_p(machine()); |
| 457 | | pirates_decrypt_s(machine()); |
| 458 | | pirates_decrypt_oki(machine()); |
| 455 | pirates_decrypt_68k(); |
| 456 | pirates_decrypt_p(); |
| 457 | pirates_decrypt_s(); |
| 458 | pirates_decrypt_oki(); |
| 459 | 459 | |
| 460 | 460 | /* If this value is increased then something has gone wrong and the protection failed */ |
| 461 | 461 | /* Write-protect it for now */ |
trunk/src/mame/machine/playch10.c
| r20973 | r20974 | |
| 4 | 4 | #include "machine/nvram.h" |
| 5 | 5 | #include "includes/playch10.h" |
| 6 | 6 | |
| 7 | | /* prototypes */ |
| 8 | | static void pc10_set_videorom_bank( running_machine &machine, int first, int count, int bank, int size ); |
| 9 | | static void set_videoram_bank( running_machine &machine, int first, int count, int bank, int size ); |
| 10 | | |
| 11 | | |
| 12 | 7 | /************************************* |
| 13 | 8 | * |
| 14 | 9 | * Init machine |
| r20973 | r20974 | |
| 55 | 50 | machine().device("ppu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2000, 0x3eff, read8_delegate(FUNC(playch10_state::pc10_nt_r),this),write8_delegate(FUNC(playch10_state::pc10_nt_w),this)); |
| 56 | 51 | |
| 57 | 52 | if (NULL != m_vram) |
| 58 | | set_videoram_bank(machine(), 0, 8, 0, 8); |
| 59 | | else pc10_set_videorom_bank(machine(), 0, 8, 0, 8); |
| 53 | set_videoram_bank(0, 8, 0, 8); |
| 54 | else pc10_set_videorom_bank(0, 8, 0, 8); |
| 60 | 55 | |
| 61 | 56 | nvram_device *nvram = machine().device<nvram_device>("nvram"); |
| 62 | 57 | if (nvram != NULL) |
| r20973 | r20974 | |
| 355 | 350 | * 64 1 * |
| 356 | 351 | \*****************/ |
| 357 | 352 | |
| 358 | | static void pc10_set_videorom_bank( running_machine &machine, int first, int count, int bank, int size ) |
| 353 | void playch10_state::pc10_set_videorom_bank( int first, int count, int bank, int size ) |
| 359 | 354 | { |
| 360 | | playch10_state *state = machine.driver_data<playch10_state>(); |
| 361 | 355 | int i, len; |
| 362 | 356 | /* first = first bank to map */ |
| 363 | 357 | /* count = number of 1K banks to map */ |
| r20973 | r20974 | |
| 368 | 362 | /* yeah, this is probably a horrible assumption to make.*/ |
| 369 | 363 | /* but the driver is 100% consistant */ |
| 370 | 364 | |
| 371 | | len = state->memregion("gfx2")->bytes(); |
| 365 | len = memregion("gfx2")->bytes(); |
| 372 | 366 | len /= 0x400; // convert to KB |
| 373 | 367 | len /= size; // convert to bank resolution |
| 374 | 368 | len--; // convert to mask |
| r20973 | r20974 | |
| 376 | 370 | |
| 377 | 371 | for (i = 0; i < count; i++) |
| 378 | 372 | { |
| 379 | | state->m_chr_page[i + first].writable = 0; |
| 380 | | state->m_chr_page[i + first].chr=state->m_vrom + (i * 0x400) + (bank * size * 0x400); |
| 373 | m_chr_page[i + first].writable = 0; |
| 374 | m_chr_page[i + first].chr=m_vrom + (i * 0x400) + (bank * size * 0x400); |
| 381 | 375 | } |
| 382 | 376 | } |
| 383 | 377 | |
| 384 | | static void set_videoram_bank( running_machine &machine, int first, int count, int bank, int size ) |
| 378 | void playch10_state::set_videoram_bank( int first, int count, int bank, int size ) |
| 385 | 379 | { |
| 386 | | playch10_state *state = machine.driver_data<playch10_state>(); |
| 387 | 380 | int i; |
| 388 | 381 | /* first = first bank to map */ |
| 389 | 382 | /* count = number of 1K banks to map */ |
| r20973 | r20974 | |
| 397 | 390 | |
| 398 | 391 | for (i = 0; i < count; i++) |
| 399 | 392 | { |
| 400 | | state->m_chr_page[i + first].writable = 1; |
| 401 | | state->m_chr_page[i + first].chr = state->m_vram + (((i * 0x400) + (bank * size * 0x400)) & 0x1fff); |
| 393 | m_chr_page[i + first].writable = 1; |
| 394 | m_chr_page[i + first].chr = m_vram + (((i * 0x400) + (bank * size * 0x400)) & 0x1fff); |
| 402 | 395 | } |
| 403 | 396 | } |
| 404 | 397 | |
| r20973 | r20974 | |
| 525 | 518 | |
| 526 | 519 | case 1: /* video rom banking - bank 0 - 4k or 8k */ |
| 527 | 520 | if (m_vram) |
| 528 | | set_videoram_bank(machine(), 0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4); |
| 521 | set_videoram_bank(0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4); |
| 529 | 522 | else |
| 530 | | pc10_set_videorom_bank(machine(), 0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4); |
| 523 | pc10_set_videorom_bank(0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4); |
| 531 | 524 | break; |
| 532 | 525 | |
| 533 | 526 | case 2: /* video rom banking - bank 1 - 4k only */ |
| 534 | 527 | if (vrom4k) |
| 535 | 528 | { |
| 536 | 529 | if (m_vram) |
| 537 | | set_videoram_bank(machine(), 0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4); |
| 530 | set_videoram_bank(0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4); |
| 538 | 531 | else |
| 539 | | pc10_set_videorom_bank(machine(), 4, 4, (m_mmc1_shiftreg & 0x1f), 4); |
| 532 | pc10_set_videorom_bank(4, 4, (m_mmc1_shiftreg & 0x1f), 4); |
| 540 | 533 | } |
| 541 | 534 | break; |
| 542 | 535 | |
| r20973 | r20974 | |
| 575 | 568 | |
| 576 | 569 | WRITE8_MEMBER(playch10_state::aboard_vrom_switch_w) |
| 577 | 570 | { |
| 578 | | pc10_set_videorom_bank(machine(), 0, 8, (data & 3), 8); |
| 571 | pc10_set_videorom_bank(0, 8, (data & 3), 8); |
| 579 | 572 | } |
| 580 | 573 | |
| 581 | 574 | DRIVER_INIT_MEMBER(playch10_state,pcaboard) |
| r20973 | r20974 | |
| 624 | 617 | /* set the mirroring here */ |
| 625 | 618 | m_mirroring = PPU_MIRROR_VERT; |
| 626 | 619 | /* special init */ |
| 627 | | set_videoram_bank(machine(), 0, 8, 0, 8); |
| 620 | set_videoram_bank(0, 8, 0, 8); |
| 628 | 621 | } |
| 629 | 622 | |
| 630 | 623 | /**********************************************************************************/ |
| r20973 | r20974 | |
| 632 | 625 | |
| 633 | 626 | WRITE8_MEMBER(playch10_state::cboard_vrom_switch_w) |
| 634 | 627 | { |
| 635 | | pc10_set_videorom_bank(machine(), 0, 8, ((data >> 1) & 1), 8); |
| 628 | pc10_set_videorom_bank(0, 8, ((data >> 1) & 1), 8); |
| 636 | 629 | } |
| 637 | 630 | |
| 638 | 631 | DRIVER_INIT_MEMBER(playch10_state,pccboard) |
| r20973 | r20974 | |
| 669 | 662 | /* allocate vram */ |
| 670 | 663 | m_vram = auto_alloc_array(machine(), UINT8, 0x2000); |
| 671 | 664 | /* special init */ |
| 672 | | set_videoram_bank(machine(), 0, 8, 0, 8); |
| 665 | set_videoram_bank(0, 8, 0, 8); |
| 673 | 666 | } |
| 674 | 667 | |
| 675 | 668 | /* D Board games with extra ram (Metroid) */ |
| r20973 | r20974 | |
| 685 | 678 | /* allocate vram */ |
| 686 | 679 | m_vram = auto_alloc_array(machine(), UINT8, 0x2000); |
| 687 | 680 | /* special init */ |
| 688 | | set_videoram_bank(machine(), 0, 8, 0, 8); |
| 681 | set_videoram_bank(0, 8, 0, 8); |
| 689 | 682 | } |
| 690 | 683 | |
| 691 | 684 | /**********************************************************************************/ |
| r20973 | r20974 | |
| 699 | 692 | if((offset & 0x1ff0) == 0x0fd0 && state->m_MMC2_bank_latch[0] != 0xfd) |
| 700 | 693 | { |
| 701 | 694 | state->m_MMC2_bank_latch[0] = 0xfd; |
| 702 | | pc10_set_videorom_bank(ppu->machine(), 0, 4, state->m_MMC2_bank[0], 4); |
| 695 | state->pc10_set_videorom_bank(0, 4, state->m_MMC2_bank[0], 4); |
| 703 | 696 | } |
| 704 | 697 | else if((offset & 0x1ff0) == 0x0fe0 && state->m_MMC2_bank_latch[0] != 0xfe) |
| 705 | 698 | { |
| 706 | 699 | state->m_MMC2_bank_latch[0] = 0xfe; |
| 707 | | pc10_set_videorom_bank(ppu->machine(), 0, 4, state->m_MMC2_bank[1], 4); |
| 700 | state->pc10_set_videorom_bank(0, 4, state->m_MMC2_bank[1], 4); |
| 708 | 701 | } |
| 709 | 702 | else if((offset & 0x1ff0) == 0x1fd0 && state->m_MMC2_bank_latch[1] != 0xfd) |
| 710 | 703 | { |
| 711 | 704 | state->m_MMC2_bank_latch[1] = 0xfd; |
| 712 | | pc10_set_videorom_bank(ppu->machine(), 4, 4, state->m_MMC2_bank[2], 4); |
| 705 | state->pc10_set_videorom_bank(4, 4, state->m_MMC2_bank[2], 4); |
| 713 | 706 | } |
| 714 | 707 | else if((offset & 0x1ff0) == 0x1fe0 && state->m_MMC2_bank_latch[1] != 0xfe) |
| 715 | 708 | { |
| 716 | 709 | state->m_MMC2_bank_latch[1] = 0xfe; |
| 717 | | pc10_set_videorom_bank(ppu->machine(), 4, 4, state->m_MMC2_bank[3], 4); |
| 710 | state->pc10_set_videorom_bank(4, 4, state->m_MMC2_bank[3], 4); |
| 718 | 711 | } |
| 719 | 712 | } |
| 720 | 713 | |
| r20973 | r20974 | |
| 734 | 727 | case 0x3000: /* gfx bank 0 - 4k */ |
| 735 | 728 | m_MMC2_bank[0] = data; |
| 736 | 729 | if (m_MMC2_bank_latch[0] == 0xfd) |
| 737 | | pc10_set_videorom_bank(machine(), 0, 4, data, 4); |
| 730 | pc10_set_videorom_bank(0, 4, data, 4); |
| 738 | 731 | break; |
| 739 | 732 | |
| 740 | 733 | case 0x4000: /* gfx bank 0 - 4k */ |
| 741 | 734 | m_MMC2_bank[1] = data; |
| 742 | 735 | if (m_MMC2_bank_latch[0] == 0xfe) |
| 743 | | pc10_set_videorom_bank(machine(), 0, 4, data, 4); |
| 736 | pc10_set_videorom_bank(0, 4, data, 4); |
| 744 | 737 | break; |
| 745 | 738 | |
| 746 | 739 | case 0x5000: /* gfx bank 1 - 4k */ |
| 747 | 740 | m_MMC2_bank[2] = data; |
| 748 | 741 | if (m_MMC2_bank_latch[1] == 0xfd) |
| 749 | | pc10_set_videorom_bank(machine(), 4, 4, data, 4); |
| 742 | pc10_set_videorom_bank(4, 4, data, 4); |
| 750 | 743 | break; |
| 751 | 744 | |
| 752 | 745 | case 0x6000: /* gfx bank 1 - 4k */ |
| 753 | 746 | m_MMC2_bank[3] = data; |
| 754 | 747 | if (m_MMC2_bank_latch[1] == 0xfe) |
| 755 | | pc10_set_videorom_bank(machine(), 4, 4, data, 4); |
| 748 | pc10_set_videorom_bank(4, 4, data, 4); |
| 756 | 749 | break; |
| 757 | 750 | |
| 758 | 751 | case 0x7000: /* mirroring */ |
| r20973 | r20974 | |
| 898 | 891 | case 1: /* char banking */ |
| 899 | 892 | data &= 0xfe; |
| 900 | 893 | page ^= (cmd << 1); |
| 901 | | pc10_set_videorom_bank(machine(), page, 2, data, 1); |
| 894 | pc10_set_videorom_bank(page, 2, data, 1); |
| 902 | 895 | break; |
| 903 | 896 | |
| 904 | 897 | case 2: /* char banking */ |
| r20973 | r20974 | |
| 906 | 899 | case 4: /* char banking */ |
| 907 | 900 | case 5: /* char banking */ |
| 908 | 901 | page ^= cmd + 2; |
| 909 | | pc10_set_videorom_bank(machine(), page, 1, data, 1); |
| 902 | pc10_set_videorom_bank(page, 1, data, 1); |
| 910 | 903 | break; |
| 911 | 904 | |
| 912 | 905 | case 6: /* program banking */ |
| r20973 | r20974 | |
| 1053 | 1046 | /* allocate vram */ |
| 1054 | 1047 | m_vram = auto_alloc_array(machine(), UINT8, 0x2000); |
| 1055 | 1048 | /* special init */ |
| 1056 | | set_videoram_bank(machine(), 0, 8, 0, 8); |
| 1049 | set_videoram_bank(0, 8, 0, 8); |
| 1057 | 1050 | } |
| 1058 | 1051 | |
| 1059 | 1052 | /**********************************************************************************/ |
| r20973 | r20974 | |
| 1076 | 1069 | page ^= (cmd << 1); |
| 1077 | 1070 | if (data & 0x40) |
| 1078 | 1071 | { |
| 1079 | | set_videoram_bank(machine(), page, 2, data, 1); |
| 1072 | set_videoram_bank(page, 2, data, 1); |
| 1080 | 1073 | } |
| 1081 | 1074 | else |
| 1082 | 1075 | { |
| 1083 | | pc10_set_videorom_bank(machine(), page, 2, data, 1); |
| 1076 | pc10_set_videorom_bank(page, 2, data, 1); |
| 1084 | 1077 | } |
| 1085 | 1078 | return; |
| 1086 | 1079 | |
| r20973 | r20974 | |
| 1091 | 1084 | page ^= cmd + 2; |
| 1092 | 1085 | if (data & 0x40) |
| 1093 | 1086 | { |
| 1094 | | set_videoram_bank(machine(), page, 1, data, 1); |
| 1087 | set_videoram_bank(page, 1, data, 1); |
| 1095 | 1088 | } |
| 1096 | 1089 | else |
| 1097 | 1090 | { |
| 1098 | | pc10_set_videorom_bank(machine(), page, 1, data, 1); |
| 1091 | pc10_set_videorom_bank(page, 1, data, 1); |
| 1099 | 1092 | } |
| 1100 | 1093 | return; |
| 1101 | 1094 | } |
| r20973 | r20974 | |
| 1153 | 1146 | /* allocate vram */ |
| 1154 | 1147 | m_vram = auto_alloc_array(machine(), UINT8, 0x2000); |
| 1155 | 1148 | /* special init */ |
| 1156 | | set_videoram_bank(machine(), 0, 8, 0, 8); |
| 1149 | set_videoram_bank(0, 8, 0, 8); |
| 1157 | 1150 | } |
trunk/src/mame/video/pacland.c
| r20973 | r20974 | |
| 55 | 55 | |
| 56 | 56 | ***************************************************************************/ |
| 57 | 57 | |
| 58 | | static void switch_palette(running_machine &machine) |
| 58 | void pacland_state::switch_palette() |
| 59 | 59 | { |
| 60 | | pacland_state *state = machine.driver_data<pacland_state>(); |
| 61 | 60 | int i; |
| 62 | | const UINT8 *color_prom = state->m_color_prom + 256 * state->m_palette_bank; |
| 61 | const UINT8 *color_prom = m_color_prom + 256 * m_palette_bank; |
| 63 | 62 | |
| 64 | 63 | for (i = 0;i < 256;i++) |
| 65 | 64 | { |
| r20973 | r20974 | |
| 84 | 83 | |
| 85 | 84 | color_prom++; |
| 86 | 85 | |
| 87 | | colortable_palette_set_color(machine.colortable,i,MAKE_RGB(r,g,b)); |
| 86 | colortable_palette_set_color(machine().colortable,i,MAKE_RGB(r,g,b)); |
| 88 | 87 | } |
| 89 | 88 | } |
| 90 | 89 | |
| r20973 | r20974 | |
| 113 | 112 | colortable_entry_set_value(machine().colortable, machine().gfx[2]->colorbase() + i, *color_prom++); |
| 114 | 113 | |
| 115 | 114 | m_palette_bank = 0; |
| 116 | | switch_palette(machine()); |
| 115 | switch_palette(); |
| 117 | 116 | |
| 118 | 117 | /* precalculate transparency masks for sprites */ |
| 119 | 118 | m_transmask[0] = auto_alloc_array(machine(), UINT32, 64); |
| r20973 | r20974 | |
| 259 | 258 | if (m_palette_bank != ((data & 0x18) >> 3)) |
| 260 | 259 | { |
| 261 | 260 | m_palette_bank = (data & 0x18) >> 3; |
| 262 | | switch_palette(machine()); |
| 261 | switch_palette(); |
| 263 | 262 | } |
| 264 | 263 | } |
| 265 | 264 | |
| r20973 | r20974 | |
| 272 | 271 | ***************************************************************************/ |
| 273 | 272 | |
| 274 | 273 | /* the sprite generator IC is the same as Mappy */ |
| 275 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int whichmask) |
| 274 | void pacland_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int whichmask) |
| 276 | 275 | { |
| 277 | | pacland_state *state = machine.driver_data<pacland_state>(); |
| 278 | | UINT8 *spriteram = state->m_spriteram + 0x780; |
| 276 | UINT8 *spriteram = m_spriteram + 0x780; |
| 279 | 277 | UINT8 *spriteram_2 = spriteram + 0x800; |
| 280 | 278 | UINT8 *spriteram_3 = spriteram_2 + 0x800; |
| 281 | 279 | int offs; |
| r20973 | r20974 | |
| 300 | 298 | sprite &= ~sizex; |
| 301 | 299 | sprite &= ~(sizey << 1); |
| 302 | 300 | |
| 303 | | if (state->flip_screen()) |
| 301 | if (flip_screen()) |
| 304 | 302 | { |
| 305 | 303 | flipx ^= 1; |
| 306 | 304 | flipy ^= 1; |
| r20973 | r20974 | |
| 314 | 312 | for (x = 0;x <= sizex;x++) |
| 315 | 313 | { |
| 316 | 314 | if (whichmask != 0) |
| 317 | | drawgfx_transmask(bitmap,cliprect,machine.gfx[2], |
| 315 | drawgfx_transmask(bitmap,cliprect,machine().gfx[2], |
| 318 | 316 | sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)], |
| 319 | 317 | color, |
| 320 | 318 | flipx,flipy, |
| 321 | | sx + 16*x,sy + 16*y,state->m_transmask[whichmask][color]); |
| 319 | sx + 16*x,sy + 16*y,m_transmask[whichmask][color]); |
| 322 | 320 | else |
| 323 | | pdrawgfx_transmask(bitmap,cliprect,machine.gfx[2], |
| 321 | pdrawgfx_transmask(bitmap,cliprect,machine().gfx[2], |
| 324 | 322 | sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)], |
| 325 | 323 | color, |
| 326 | 324 | flipx,flipy, |
| 327 | 325 | sx + 16*x,sy + 16*y, |
| 328 | | machine.priority_bitmap,0,state->m_transmask[whichmask][color]); |
| 326 | machine().priority_bitmap,0,m_transmask[whichmask][color]); |
| 329 | 327 | } |
| 330 | 328 | } |
| 331 | 329 | } |
| 332 | 330 | } |
| 333 | 331 | |
| 334 | 332 | |
| 335 | | static void draw_fg(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority ) |
| 333 | void pacland_state::draw_fg(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority ) |
| 336 | 334 | { |
| 337 | | pacland_state *state = machine.driver_data<pacland_state>(); |
| 338 | 335 | int y, x; |
| 339 | 336 | |
| 340 | 337 | /* draw tilemap transparently over it; this will leave invalid pens (0xffff) |
| 341 | 338 | anywhere where the fg_tilemap should be transparent; note that we assume |
| 342 | 339 | the fg_bitmap has been pre-erased to 0xffff */ |
| 343 | | state->m_fg_tilemap->draw(state->m_fg_bitmap, cliprect, priority, 0); |
| 340 | m_fg_tilemap->draw(m_fg_bitmap, cliprect, priority, 0); |
| 344 | 341 | |
| 345 | 342 | /* now copy the fg_bitmap to the destination wherever the sprite pixel allows */ |
| 346 | 343 | for (y = cliprect.min_y; y <= cliprect.max_y; y++) |
| 347 | 344 | { |
| 348 | | const UINT8 *pri = &machine.priority_bitmap.pix8(y); |
| 349 | | UINT16 *src = &state->m_fg_bitmap.pix16(y); |
| 345 | const UINT8 *pri = &machine().priority_bitmap.pix8(y); |
| 346 | UINT16 *src = &m_fg_bitmap.pix16(y); |
| 350 | 347 | UINT16 *dst = &bitmap.pix16(y); |
| 351 | 348 | |
| 352 | 349 | /* only copy if the priority bitmap is 0 (no high priority sprite) and the |
| r20973 | r20974 | |
| 377 | 374 | wherever there is a high-priority pixel; note that we draw to the bitmap |
| 378 | 375 | which is safe because the bg_tilemap draw will overwrite everything */ |
| 379 | 376 | machine().priority_bitmap.fill(0x00, cliprect); |
| 380 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 377 | draw_sprites(bitmap, cliprect, 0); |
| 381 | 378 | |
| 382 | 379 | /* draw background */ |
| 383 | 380 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 384 | 381 | |
| 385 | 382 | /* draw low priority fg tiles */ |
| 386 | | draw_fg(machine(), bitmap, cliprect, 0); |
| 383 | draw_fg(bitmap, cliprect, 0); |
| 387 | 384 | |
| 388 | 385 | /* draw sprites with regular transparency */ |
| 389 | | draw_sprites(machine(), bitmap, cliprect, 1); |
| 386 | draw_sprites(bitmap, cliprect, 1); |
| 390 | 387 | |
| 391 | 388 | /* draw high priority fg tiles */ |
| 392 | | draw_fg(machine(), bitmap, cliprect, 1); |
| 389 | draw_fg(bitmap, cliprect, 1); |
| 393 | 390 | |
| 394 | 391 | /* draw sprite pixels with colortable values >= 0xf0, which have priority over everything */ |
| 395 | | draw_sprites(machine(), bitmap, cliprect, 2); |
| 392 | draw_sprites(bitmap, cliprect, 2); |
| 396 | 393 | return 0; |
| 397 | 394 | } |
trunk/src/mame/video/paradise.c
| r20973 | r20974 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /* Note: Penky updates pixel palette bank register BEFORE actually writing to the paletteram. */ |
| 42 | | static void update_pix_palbank(running_machine &machine) |
| 42 | void paradise_state::update_pix_palbank() |
| 43 | 43 | { |
| 44 | | paradise_state *state = machine.driver_data<paradise_state>(); |
| 45 | 44 | int i; |
| 46 | 45 | |
| 47 | 46 | for (i = 0; i < 15; i++) |
| 48 | | palette_set_color_rgb(machine, 0x800 + i, state->m_paletteram[0x200 + state->m_pixbank + i + 0x800 * 0], state->m_paletteram[0x200 + state->m_pixbank + i + 0x800 * 1], |
| 49 | | state->m_paletteram[0x200 + state->m_pixbank + i + 0x800 * 2]); |
| 47 | palette_set_color_rgb(machine(), 0x800 + i, m_paletteram[0x200 + m_pixbank + i + 0x800 * 0], m_paletteram[0x200 + m_pixbank + i + 0x800 * 1], |
| 48 | m_paletteram[0x200 + m_pixbank + i + 0x800 * 2]); |
| 50 | 49 | } |
| 51 | 50 | |
| 52 | 51 | /* 800 bytes for red, followed by 800 bytes for green & 800 bytes for blue */ |
| r20973 | r20974 | |
| 57 | 56 | palette_set_color_rgb(machine(), offset, m_paletteram[offset + 0x800 * 0], m_paletteram[offset + 0x800 * 1], |
| 58 | 57 | m_paletteram[offset + 0x800 * 2]); |
| 59 | 58 | |
| 60 | | update_pix_palbank(machine()); |
| 59 | update_pix_palbank(); |
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | /*************************************************************************** |
| r20973 | r20974 | |
| 86 | 85 | |
| 87 | 86 | m_pixbank = bank2; |
| 88 | 87 | |
| 89 | | update_pix_palbank(machine()); |
| 88 | update_pix_palbank(); |
| 90 | 89 | |
| 91 | 90 | if (m_palbank != bank1) |
| 92 | 91 | { |
| r20973 | r20974 | |
| 180 | 179 | m_priority = data; |
| 181 | 180 | } |
| 182 | 181 | |
| 183 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 182 | void paradise_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 184 | 183 | { |
| 185 | | paradise_state *state = machine.driver_data<paradise_state>(); |
| 186 | | UINT8 *spriteram = state->m_spriteram; |
| 184 | UINT8 *spriteram = m_spriteram; |
| 187 | 185 | int i; |
| 188 | | for (i = 0; i < state->m_spriteram.bytes() ; i += state->m_sprite_inc) |
| 186 | for (i = 0; i < m_spriteram.bytes() ; i += m_sprite_inc) |
| 189 | 187 | { |
| 190 | 188 | int code = spriteram[i + 0]; |
| 191 | 189 | int x = spriteram[i + 1]; |
| r20973 | r20974 | |
| 195 | 193 | int flipx = 0; // ? |
| 196 | 194 | int flipy = 0; |
| 197 | 195 | |
| 198 | | if (state->flip_screen()) |
| 196 | if (flip_screen()) |
| 199 | 197 | { |
| 200 | 198 | x = 0xf0 - x; flipx = !flipx; |
| 201 | 199 | y = 0xf0 - y; flipy = !flipy; |
| 202 | 200 | } |
| 203 | 201 | |
| 204 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 202 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 205 | 203 | code + (attr << 8), |
| 206 | 204 | 0, |
| 207 | 205 | flipx, flipy, |
| 208 | 206 | x,y, 0xff ); |
| 209 | 207 | |
| 210 | 208 | /* wrap around x */ |
| 211 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 209 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 212 | 210 | code + (attr << 8), |
| 213 | 211 | 0, |
| 214 | 212 | flipx, flipy, |
| 215 | 213 | x - 256,y, 0xff ); |
| 216 | 214 | |
| 217 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 215 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 218 | 216 | code + (attr << 8), |
| 219 | 217 | 0, |
| 220 | 218 | flipx, flipy, |
| r20973 | r20974 | |
| 253 | 251 | |
| 254 | 252 | if (m_priority & 1) |
| 255 | 253 | if (layers_ctrl & 16) |
| 256 | | draw_sprites(screen.machine(), bitmap, cliprect); |
| 254 | draw_sprites(bitmap, cliprect); |
| 257 | 255 | |
| 258 | 256 | if (layers_ctrl & 1) m_tilemap_0->draw(bitmap, cliprect, 0, 0); |
| 259 | 257 | if (layers_ctrl & 2) m_tilemap_1->draw(bitmap, cliprect, 0, 0); |
| r20973 | r20974 | |
| 263 | 261 | { |
| 264 | 262 | if (!(m_priority & 1)) |
| 265 | 263 | if (layers_ctrl & 16) |
| 266 | | draw_sprites(screen.machine(), bitmap, cliprect); |
| 264 | draw_sprites(bitmap, cliprect); |
| 267 | 265 | if (layers_ctrl & 8) |
| 268 | 266 | m_tilemap_2->draw(bitmap, cliprect, 0, 0); |
| 269 | 267 | } |
| r20973 | r20974 | |
| 273 | 271 | m_tilemap_2->draw(bitmap, cliprect, 0, 0); |
| 274 | 272 | if (!(m_priority & 1)) |
| 275 | 273 | if (layers_ctrl & 16) |
| 276 | | draw_sprites(screen.machine(), bitmap, cliprect); |
| 274 | draw_sprites(bitmap, cliprect); |
| 277 | 275 | } |
| 278 | 276 | return 0; |
| 279 | 277 | } |
| r20973 | r20974 | |
| 287 | 285 | return 0; |
| 288 | 286 | |
| 289 | 287 | if (m_priority & 1) |
| 290 | | draw_sprites(machine(), bitmap, cliprect); |
| 288 | draw_sprites(bitmap, cliprect); |
| 291 | 289 | |
| 292 | 290 | m_tilemap_1->draw(bitmap, cliprect, 0,0); |
| 293 | 291 | |
| 294 | 292 | if (m_priority & 4) |
| 295 | 293 | { |
| 296 | 294 | if (!(m_priority & 1)) |
| 297 | | draw_sprites(machine(), bitmap, cliprect); |
| 295 | draw_sprites(bitmap, cliprect); |
| 298 | 296 | |
| 299 | 297 | m_tilemap_2->draw(bitmap, cliprect, 0, 0); |
| 300 | 298 | } |
| r20973 | r20974 | |
| 303 | 301 | m_tilemap_2->draw(bitmap, cliprect, 0, 0); |
| 304 | 302 | |
| 305 | 303 | if (!(m_priority & 1)) |
| 306 | | draw_sprites(machine(), bitmap,cliprect); |
| 304 | draw_sprites(bitmap,cliprect); |
| 307 | 305 | } |
| 308 | 306 | return 0; |
| 309 | 307 | } |
| r20973 | r20974 | |
| 315 | 313 | m_tilemap_0->draw(bitmap, cliprect, 0, 0); |
| 316 | 314 | m_tilemap_1->draw(bitmap, cliprect, 0, 0); |
| 317 | 315 | m_tilemap_2->draw(bitmap, cliprect, 0, 0); |
| 318 | | draw_sprites(machine(), bitmap, cliprect); |
| 316 | draw_sprites(bitmap, cliprect); |
| 319 | 317 | return 0; |
| 320 | 318 | } |
trunk/src/mame/video/punchout.c
| r20973 | r20974 | |
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
| 190 | | static void draw_big_sprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int palette) |
| 190 | void punchout_state::draw_big_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int palette) |
| 191 | 191 | { |
| 192 | | punchout_state *state = machine.driver_data<punchout_state>(); |
| 193 | 192 | int zoom; |
| 194 | 193 | |
| 195 | | zoom = state->m_spr1_ctrlram[0] + 256 * (state->m_spr1_ctrlram[1] & 0x0f); |
| 194 | zoom = m_spr1_ctrlram[0] + 256 * (m_spr1_ctrlram[1] & 0x0f); |
| 196 | 195 | if (zoom) |
| 197 | 196 | { |
| 198 | 197 | int sx,sy; |
| 199 | 198 | UINT32 startx,starty; |
| 200 | 199 | int incxx,incyy; |
| 201 | 200 | |
| 202 | | sx = 4096 - (state->m_spr1_ctrlram[2] + 256 * (state->m_spr1_ctrlram[3] & 0x0f)); |
| 201 | sx = 4096 - (m_spr1_ctrlram[2] + 256 * (m_spr1_ctrlram[3] & 0x0f)); |
| 203 | 202 | if (sx > 4096-4*127) sx -= 4096; |
| 204 | 203 | |
| 205 | | sy = -(state->m_spr1_ctrlram[4] + 256 * (state->m_spr1_ctrlram[5] & 1)); |
| 204 | sy = -(m_spr1_ctrlram[4] + 256 * (m_spr1_ctrlram[5] & 1)); |
| 206 | 205 | if (sy <= -256 + zoom/0x40) sy += 512; |
| 207 | 206 | sy += 12; |
| 208 | 207 | |
| r20973 | r20974 | |
| 214 | 213 | startx += 3740 * zoom; /* adjustment to match the screen shots */ |
| 215 | 214 | starty -= 178 * zoom; /* and make the hall of fame picture nice */ |
| 216 | 215 | |
| 217 | | if (state->m_spr1_ctrlram[6] & 1) /* flip x */ |
| 216 | if (m_spr1_ctrlram[6] & 1) /* flip x */ |
| 218 | 217 | { |
| 219 | 218 | startx = ((16 * 8) << 16) - startx - 1; |
| 220 | 219 | incxx = -incxx; |
| 221 | 220 | } |
| 222 | 221 | |
| 223 | | state->m_spr1_tilemap->set_palette_offset(0x100 * palette); |
| 222 | m_spr1_tilemap->set_palette_offset(0x100 * palette); |
| 224 | 223 | |
| 225 | | state->m_spr1_tilemap->draw_roz(bitmap, cliprect, |
| 224 | m_spr1_tilemap->draw_roz(bitmap, cliprect, |
| 226 | 225 | startx,starty + 0x200*(2) * zoom, |
| 227 | 226 | incxx,0,0,incyy, /* zoom, no rotation */ |
| 228 | 227 | 0, /* no wraparound */ |
| r20973 | r20974 | |
| 231 | 230 | } |
| 232 | 231 | |
| 233 | 232 | |
| 234 | | static void armwrest_draw_big_sprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int palette) |
| 233 | void punchout_state::armwrest_draw_big_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int palette) |
| 235 | 234 | { |
| 236 | | punchout_state *state = machine.driver_data<punchout_state>(); |
| 237 | 235 | int zoom; |
| 238 | 236 | |
| 239 | | zoom = state->m_spr1_ctrlram[0] + 256 * (state->m_spr1_ctrlram[1] & 0x0f); |
| 237 | zoom = m_spr1_ctrlram[0] + 256 * (m_spr1_ctrlram[1] & 0x0f); |
| 240 | 238 | if (zoom) |
| 241 | 239 | { |
| 242 | 240 | int sx,sy; |
| r20973 | r20974 | |
| 244 | 242 | int incxx,incyy; |
| 245 | 243 | tilemap_t *_tilemap; |
| 246 | 244 | |
| 247 | | sx = 4096 - (state->m_spr1_ctrlram[2] + 256 * (state->m_spr1_ctrlram[3] & 0x0f)); |
| 245 | sx = 4096 - (m_spr1_ctrlram[2] + 256 * (m_spr1_ctrlram[3] & 0x0f)); |
| 248 | 246 | if (sx > 2048) sx -= 4096; |
| 249 | 247 | |
| 250 | | sy = -(state->m_spr1_ctrlram[4] + 256 * (state->m_spr1_ctrlram[5] & 1)); |
| 248 | sy = -(m_spr1_ctrlram[4] + 256 * (m_spr1_ctrlram[5] & 1)); |
| 251 | 249 | if (sy <= -256 + zoom/0x40) sy += 512; |
| 252 | 250 | sy += 12; |
| 253 | 251 | |
| r20973 | r20974 | |
| 259 | 257 | startx += 3740 * zoom; /* adjustment to match the screen shots */ |
| 260 | 258 | starty -= 178 * zoom; /* and make the hall of fame picture nice */ |
| 261 | 259 | |
| 262 | | if (state->m_spr1_ctrlram[6] & 1) /* flip x */ |
| 260 | if (m_spr1_ctrlram[6] & 1) /* flip x */ |
| 263 | 261 | { |
| 264 | | _tilemap = state->m_spr1_tilemap_flipx; |
| 262 | _tilemap = m_spr1_tilemap_flipx; |
| 265 | 263 | startx = ((32 * 8) << 16) - startx - 1; |
| 266 | 264 | incxx = -incxx; |
| 267 | 265 | } |
| 268 | 266 | else |
| 269 | | _tilemap = state->m_spr1_tilemap; |
| 267 | _tilemap = m_spr1_tilemap; |
| 270 | 268 | |
| 271 | 269 | _tilemap->set_palette_offset(0x100 * palette); |
| 272 | 270 | |
| r20973 | r20974 | |
| 278 | 276 | } |
| 279 | 277 | } |
| 280 | 278 | |
| 281 | | static void drawbs2(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 279 | void punchout_state::drawbs2(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 282 | 280 | { |
| 283 | | punchout_state *state = machine.driver_data<punchout_state>(); |
| 284 | 281 | int sx,sy; |
| 285 | 282 | int incxx; |
| 286 | 283 | |
| 287 | | sx = 512 - (state->m_spr2_ctrlram[0] + 256 * (state->m_spr2_ctrlram[1] & 1)); |
| 284 | sx = 512 - (m_spr2_ctrlram[0] + 256 * (m_spr2_ctrlram[1] & 1)); |
| 288 | 285 | if (sx > 512-127) sx -= 512; |
| 289 | 286 | sx -= 55; /* adjustment to match the screen shots */ |
| 290 | 287 | |
| 291 | | sy = -state->m_spr2_ctrlram[2] + 256 * (state->m_spr2_ctrlram[3] & 1); |
| 288 | sy = -m_spr2_ctrlram[2] + 256 * (m_spr2_ctrlram[3] & 1); |
| 292 | 289 | sy += 3; /* adjustment to match the screen shots */ |
| 293 | 290 | |
| 294 | 291 | sx = -sx << 16; |
| 295 | 292 | sy = -sy << 16; |
| 296 | 293 | |
| 297 | | if (state->m_spr2_ctrlram[4] & 1) /* flip x */ |
| 294 | if (m_spr2_ctrlram[4] & 1) /* flip x */ |
| 298 | 295 | { |
| 299 | 296 | sx = ((16 * 8) << 16) - sx - 1; |
| 300 | 297 | incxx = -1; |
| r20973 | r20974 | |
| 303 | 300 | incxx = 1; |
| 304 | 301 | |
| 305 | 302 | // this tilemap doesn't actually zoom, but draw_roz is the only way to draw it without wraparound |
| 306 | | state->m_spr2_tilemap->draw_roz(bitmap, cliprect, |
| 303 | m_spr2_tilemap->draw_roz(bitmap, cliprect, |
| 307 | 304 | sx, sy, incxx << 16, 0, 0, 1 << 16, |
| 308 | 305 | 0, 0, 0); |
| 309 | 306 | } |
| 310 | 307 | |
| 311 | 308 | |
| 312 | 309 | |
| 313 | | static void punchout_copy_top_palette(running_machine &machine, int bank) |
| 310 | void punchout_state::punchout_copy_top_palette(int bank) |
| 314 | 311 | { |
| 315 | | punchout_state *state = machine.driver_data<punchout_state>(); |
| 316 | 312 | int i; |
| 317 | | const UINT8 *color_prom = state->memregion("proms")->base(); |
| 313 | const UINT8 *color_prom = memregion("proms")->base(); |
| 318 | 314 | |
| 319 | 315 | // top monitor palette |
| 320 | 316 | for (i = 0; i < 0x100; i++) |
| r20973 | r20974 | |
| 326 | 322 | g = 255 - pal4bit(color_prom[i + 0x200 + base]); |
| 327 | 323 | b = 255 - pal4bit(color_prom[i + 0x400 + base]); |
| 328 | 324 | |
| 329 | | palette_set_color(machine, i ^ state->m_palette_reverse_top, MAKE_RGB(r, g, b)); |
| 325 | palette_set_color(machine(), i ^ m_palette_reverse_top, MAKE_RGB(r, g, b)); |
| 330 | 326 | } |
| 331 | 327 | } |
| 332 | 328 | |
| 333 | | static void punchout_copy_bot_palette(running_machine &machine, int bank) |
| 329 | void punchout_state::punchout_copy_bot_palette(int bank) |
| 334 | 330 | { |
| 335 | | punchout_state *state = machine.driver_data<punchout_state>(); |
| 336 | 331 | int i; |
| 337 | | const UINT8 *color_prom = state->memregion("proms")->base() + 0x600; |
| 332 | const UINT8 *color_prom = memregion("proms")->base() + 0x600; |
| 338 | 333 | |
| 339 | 334 | // bottom monitor palette |
| 340 | 335 | for (i = 0; i < 0x100; i++) |
| r20973 | r20974 | |
| 346 | 341 | g = 255 - pal4bit(color_prom[i + 0x200 + base]); |
| 347 | 342 | b = 255 - pal4bit(color_prom[i + 0x400 + base]); |
| 348 | 343 | |
| 349 | | palette_set_color(machine, (i ^ state->m_palette_reverse_bot) + 0x100, MAKE_RGB(r, g, b)); |
| 344 | palette_set_color(machine(), (i ^ m_palette_reverse_bot) + 0x100, MAKE_RGB(r, g, b)); |
| 350 | 345 | } |
| 351 | 346 | } |
| 352 | 347 | |
| 353 | 348 | |
| 354 | 349 | UINT32 punchout_state::screen_update_punchout_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 355 | 350 | { |
| 356 | | punchout_copy_top_palette(machine(), BIT(*m_palettebank,1)); |
| 351 | punchout_copy_top_palette(BIT(*m_palettebank,1)); |
| 357 | 352 | |
| 358 | 353 | m_bg_top_tilemap->draw(bitmap, cliprect, 0, 0); |
| 359 | 354 | |
| 360 | 355 | if (m_spr1_ctrlram[7] & 1) /* display in top monitor */ |
| 361 | | draw_big_sprite(machine(), bitmap, cliprect, 0); |
| 356 | draw_big_sprite(bitmap, cliprect, 0); |
| 362 | 357 | |
| 363 | 358 | return 0; |
| 364 | 359 | } |
| r20973 | r20974 | |
| 367 | 362 | { |
| 368 | 363 | int offs; |
| 369 | 364 | |
| 370 | | punchout_copy_bot_palette(machine(), BIT(*m_palettebank,0)); |
| 365 | punchout_copy_bot_palette(BIT(*m_palettebank,0)); |
| 371 | 366 | |
| 372 | 367 | /* copy the character mapped graphics */ |
| 373 | 368 | for (offs = 0;offs < 32;offs++) |
| r20973 | r20974 | |
| 376 | 371 | m_bg_bot_tilemap->draw(bitmap, cliprect, 0, 0); |
| 377 | 372 | |
| 378 | 373 | if (m_spr1_ctrlram[7] & 2) /* display in bottom monitor */ |
| 379 | | draw_big_sprite(machine(), bitmap, cliprect, 1); |
| 380 | | drawbs2(machine(), bitmap, cliprect); |
| 374 | draw_big_sprite(bitmap, cliprect, 1); |
| 375 | drawbs2(bitmap, cliprect); |
| 381 | 376 | |
| 382 | 377 | return 0; |
| 383 | 378 | } |
| r20973 | r20974 | |
| 385 | 380 | |
| 386 | 381 | UINT32 punchout_state::screen_update_armwrest_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 387 | 382 | { |
| 388 | | punchout_copy_top_palette(machine(), BIT(*m_palettebank,1)); |
| 383 | punchout_copy_top_palette(BIT(*m_palettebank,1)); |
| 389 | 384 | |
| 390 | 385 | m_bg_top_tilemap->draw(bitmap, cliprect, 0, 0); |
| 391 | 386 | |
| 392 | 387 | if (m_spr1_ctrlram[7] & 1) /* display in top monitor */ |
| 393 | | armwrest_draw_big_sprite(machine(), bitmap, cliprect, 0); |
| 388 | armwrest_draw_big_sprite(bitmap, cliprect, 0); |
| 394 | 389 | |
| 395 | 390 | return 0; |
| 396 | 391 | } |
| 397 | 392 | |
| 398 | 393 | UINT32 punchout_state::screen_update_armwrest_bottom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 399 | 394 | { |
| 400 | | punchout_copy_bot_palette(machine(), BIT(*m_palettebank,0)); |
| 395 | punchout_copy_bot_palette(BIT(*m_palettebank,0)); |
| 401 | 396 | |
| 402 | 397 | m_bg_bot_tilemap->draw(bitmap, cliprect, 0, 0); |
| 403 | 398 | |
| 404 | 399 | if (m_spr1_ctrlram[7] & 2) /* display in bottom monitor */ |
| 405 | | armwrest_draw_big_sprite(machine(), bitmap, cliprect, 1); |
| 406 | | drawbs2(machine(), bitmap, cliprect); |
| 400 | armwrest_draw_big_sprite(bitmap, cliprect, 1); |
| 401 | drawbs2(bitmap, cliprect); |
| 407 | 402 | |
| 408 | 403 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 409 | 404 | |
trunk/src/mame/video/popeye.c
| r20973 | r20974 | |
| 49 | 49 | The bootleg is the same, but the outputs are not inverted. |
| 50 | 50 | |
| 51 | 51 | ***************************************************************************/ |
| 52 | | static void convert_color_prom(running_machine &machine,const UINT8 *color_prom) |
| 52 | void popeye_state::convert_color_prom(const UINT8 *color_prom) |
| 53 | 53 | { |
| 54 | | popeye_state *state = machine.driver_data<popeye_state>(); |
| 55 | 54 | int i; |
| 56 | 55 | |
| 57 | 56 | |
| r20973 | r20974 | |
| 65 | 64 | int bit0,bit1,bit2,r,g,b; |
| 66 | 65 | |
| 67 | 66 | /* red component */ |
| 68 | | bit0 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 0) & 0x01; |
| 69 | | bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 1) & 0x01; |
| 70 | | bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 2) & 0x01; |
| 67 | bit0 = ((color_prom[prom_offs] ^ m_invertmask) >> 0) & 0x01; |
| 68 | bit1 = ((color_prom[prom_offs] ^ m_invertmask) >> 1) & 0x01; |
| 69 | bit2 = ((color_prom[prom_offs] ^ m_invertmask) >> 2) & 0x01; |
| 71 | 70 | r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 72 | 71 | /* green component */ |
| 73 | | bit0 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 3) & 0x01; |
| 74 | | bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 4) & 0x01; |
| 75 | | bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 5) & 0x01; |
| 72 | bit0 = ((color_prom[prom_offs] ^ m_invertmask) >> 3) & 0x01; |
| 73 | bit1 = ((color_prom[prom_offs] ^ m_invertmask) >> 4) & 0x01; |
| 74 | bit2 = ((color_prom[prom_offs] ^ m_invertmask) >> 5) & 0x01; |
| 76 | 75 | g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 77 | 76 | /* blue component */ |
| 78 | 77 | bit0 = 0; |
| 79 | | bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 6) & 0x01; |
| 80 | | bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 7) & 0x01; |
| 78 | bit1 = ((color_prom[prom_offs] ^ m_invertmask) >> 6) & 0x01; |
| 79 | bit2 = ((color_prom[prom_offs] ^ m_invertmask) >> 7) & 0x01; |
| 81 | 80 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 82 | 81 | |
| 83 | | palette_set_color(machine,16 + (2 * i) + 1,MAKE_RGB(r,g,b)); |
| 82 | palette_set_color(machine(),16 + (2 * i) + 1,MAKE_RGB(r,g,b)); |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | color_prom += 32; |
| r20973 | r20974 | |
| 92 | 91 | |
| 93 | 92 | |
| 94 | 93 | /* red component */ |
| 95 | | bit0 = ((color_prom[0] ^ state->m_invertmask) >> 0) & 0x01; |
| 96 | | bit1 = ((color_prom[0] ^ state->m_invertmask) >> 1) & 0x01; |
| 97 | | bit2 = ((color_prom[0] ^ state->m_invertmask) >> 2) & 0x01; |
| 94 | bit0 = ((color_prom[0] ^ m_invertmask) >> 0) & 0x01; |
| 95 | bit1 = ((color_prom[0] ^ m_invertmask) >> 1) & 0x01; |
| 96 | bit2 = ((color_prom[0] ^ m_invertmask) >> 2) & 0x01; |
| 98 | 97 | r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 99 | 98 | /* green component */ |
| 100 | | bit0 = ((color_prom[0] ^ state->m_invertmask) >> 3) & 0x01; |
| 101 | | bit1 = ((color_prom[256] ^ state->m_invertmask) >> 0) & 0x01; |
| 102 | | bit2 = ((color_prom[256] ^ state->m_invertmask) >> 1) & 0x01; |
| 99 | bit0 = ((color_prom[0] ^ m_invertmask) >> 3) & 0x01; |
| 100 | bit1 = ((color_prom[256] ^ m_invertmask) >> 0) & 0x01; |
| 101 | bit2 = ((color_prom[256] ^ m_invertmask) >> 1) & 0x01; |
| 103 | 102 | g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 104 | 103 | /* blue component */ |
| 105 | 104 | bit0 = 0; |
| 106 | | bit1 = ((color_prom[256] ^ state->m_invertmask) >> 2) & 0x01; |
| 107 | | bit2 = ((color_prom[256] ^ state->m_invertmask) >> 3) & 0x01; |
| 105 | bit1 = ((color_prom[256] ^ m_invertmask) >> 2) & 0x01; |
| 106 | bit2 = ((color_prom[256] ^ m_invertmask) >> 3) & 0x01; |
| 108 | 107 | b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
| 109 | 108 | |
| 110 | | palette_set_color(machine,48+i,MAKE_RGB(r,g,b)); |
| 109 | palette_set_color(machine(),48+i,MAKE_RGB(r,g,b)); |
| 111 | 110 | |
| 112 | 111 | color_prom++; |
| 113 | 112 | } |
| r20973 | r20974 | |
| 118 | 117 | const UINT8 *color_prom = machine().root_device().memregion("proms")->base(); |
| 119 | 118 | m_invertmask = 0xff; |
| 120 | 119 | |
| 121 | | convert_color_prom(machine(),color_prom); |
| 120 | convert_color_prom(color_prom); |
| 122 | 121 | } |
| 123 | 122 | |
| 124 | 123 | PALETTE_INIT_MEMBER(popeye_state,popeyebl) |
| r20973 | r20974 | |
| 126 | 125 | const UINT8 *color_prom = machine().root_device().memregion("proms")->base(); |
| 127 | 126 | m_invertmask = 0x00; |
| 128 | 127 | |
| 129 | | convert_color_prom(machine(),color_prom); |
| 128 | convert_color_prom(color_prom); |
| 130 | 129 | } |
| 131 | 130 | |
| 132 | | static void set_background_palette(running_machine &machine,int bank) |
| 131 | void popeye_state::set_background_palette(int bank) |
| 133 | 132 | { |
| 134 | | popeye_state *state = machine.driver_data<popeye_state>(); |
| 135 | 133 | int i; |
| 136 | | UINT8 *color_prom = state->memregion("proms")->base() + 16 * bank; |
| 134 | UINT8 *color_prom = memregion("proms")->base() + 16 * bank; |
| 137 | 135 | |
| 138 | 136 | for (i = 0;i < 16;i++) |
| 139 | 137 | { |
| r20973 | r20974 | |
| 141 | 139 | int r,g,b; |
| 142 | 140 | |
| 143 | 141 | /* red component */ |
| 144 | | bit0 = ((*color_prom ^ state->m_invertmask) >> 0) & 0x01; |
| 145 | | bit1 = ((*color_prom ^ state->m_invertmask) >> 1) & 0x01; |
| 146 | | bit2 = ((*color_prom ^ state->m_invertmask) >> 2) & 0x01; |
| 142 | bit0 = ((*color_prom ^ m_invertmask) >> 0) & 0x01; |
| 143 | bit1 = ((*color_prom ^ m_invertmask) >> 1) & 0x01; |
| 144 | bit2 = ((*color_prom ^ m_invertmask) >> 2) & 0x01; |
| 147 | 145 | r = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2; |
| 148 | 146 | /* green component */ |
| 149 | | bit0 = ((*color_prom ^ state->m_invertmask) >> 3) & 0x01; |
| 150 | | bit1 = ((*color_prom ^ state->m_invertmask) >> 4) & 0x01; |
| 151 | | bit2 = ((*color_prom ^ state->m_invertmask) >> 5) & 0x01; |
| 147 | bit0 = ((*color_prom ^ m_invertmask) >> 3) & 0x01; |
| 148 | bit1 = ((*color_prom ^ m_invertmask) >> 4) & 0x01; |
| 149 | bit2 = ((*color_prom ^ m_invertmask) >> 5) & 0x01; |
| 152 | 150 | g = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2; |
| 153 | 151 | /* blue component */ |
| 154 | 152 | bit0 = 0; |
| 155 | | bit1 = ((*color_prom ^ state->m_invertmask) >> 6) & 0x01; |
| 156 | | bit2 = ((*color_prom ^ state->m_invertmask) >> 7) & 0x01; |
| 157 | | if (state->m_bitmap_type == TYPE_SKYSKIPR) |
| 153 | bit1 = ((*color_prom ^ m_invertmask) >> 6) & 0x01; |
| 154 | bit2 = ((*color_prom ^ m_invertmask) >> 7) & 0x01; |
| 155 | if (m_bitmap_type == TYPE_SKYSKIPR) |
| 158 | 156 | { |
| 159 | 157 | /* Sky Skipper has different weights */ |
| 160 | 158 | bit0 = bit1; |
| r20973 | r20974 | |
| 162 | 160 | } |
| 163 | 161 | b = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2; |
| 164 | 162 | |
| 165 | | palette_set_color(machine,i,MAKE_RGB(r,g,b)); |
| 163 | palette_set_color(machine(),i,MAKE_RGB(r,g,b)); |
| 166 | 164 | |
| 167 | 165 | color_prom++; |
| 168 | 166 | } |
| r20973 | r20974 | |
| 273 | 271 | state_save_register_global_pointer(machine(), m_bitmapram, popeye_bitmapram_size); |
| 274 | 272 | } |
| 275 | 273 | |
| 276 | | static void draw_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 274 | void popeye_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 277 | 275 | { |
| 278 | | popeye_state *state = machine.driver_data<popeye_state>(); |
| 279 | 276 | int offs; |
| 280 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 277 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 281 | 278 | |
| 282 | | if (state->m_lastflip != state->flip_screen()) |
| 279 | if (m_lastflip != flip_screen()) |
| 283 | 280 | { |
| 284 | 281 | for (offs = 0;offs < popeye_bitmapram_size;offs++) |
| 285 | | state->popeye_bitmap_w(space,offs,state->m_bitmapram[offs]); |
| 282 | popeye_bitmap_w(space,offs,m_bitmapram[offs]); |
| 286 | 283 | |
| 287 | | state->m_lastflip = state->flip_screen(); |
| 284 | m_lastflip = flip_screen(); |
| 288 | 285 | } |
| 289 | 286 | |
| 290 | | set_background_palette(machine, (*state->m_palettebank & 0x08) >> 3); |
| 287 | set_background_palette((*m_palettebank & 0x08) >> 3); |
| 291 | 288 | |
| 292 | | if (state->m_background_pos[1] == 0) /* no background */ |
| 289 | if (m_background_pos[1] == 0) /* no background */ |
| 293 | 290 | bitmap.fill(0, cliprect); |
| 294 | 291 | else |
| 295 | 292 | { |
| 296 | 293 | /* copy the background graphics */ |
| 297 | | int scrollx = 200 - state->m_background_pos[0] - 256*(state->m_background_pos[2]&1); /* ??? */ |
| 298 | | int scrolly = 2 * (256 - state->m_background_pos[1]); |
| 294 | int scrollx = 200 - m_background_pos[0] - 256*(m_background_pos[2]&1); /* ??? */ |
| 295 | int scrolly = 2 * (256 - m_background_pos[1]); |
| 299 | 296 | |
| 300 | | if (state->m_bitmap_type == TYPE_SKYSKIPR) |
| 297 | if (m_bitmap_type == TYPE_SKYSKIPR) |
| 301 | 298 | scrollx = 2*scrollx - 512; |
| 302 | 299 | |
| 303 | | if (state->flip_screen()) |
| 300 | if (flip_screen()) |
| 304 | 301 | { |
| 305 | | if (state->m_bitmap_type == TYPE_POPEYE) |
| 302 | if (m_bitmap_type == TYPE_POPEYE) |
| 306 | 303 | scrollx = -scrollx; |
| 307 | 304 | scrolly = -scrolly; |
| 308 | 305 | } |
| 309 | 306 | |
| 310 | | copyscrollbitmap(bitmap,*state->m_tmpbitmap2,1,&scrollx,1,&scrolly,cliprect); |
| 307 | copyscrollbitmap(bitmap,*m_tmpbitmap2,1,&scrollx,1,&scrolly,cliprect); |
| 311 | 308 | } |
| 312 | 309 | } |
| 313 | 310 | |
| 314 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 311 | void popeye_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 315 | 312 | { |
| 316 | | popeye_state *state = machine.driver_data<popeye_state>(); |
| 317 | | UINT8 *spriteram = state->m_spriteram; |
| 313 | UINT8 *spriteram = m_spriteram; |
| 318 | 314 | int offs; |
| 319 | 315 | |
| 320 | | for (offs = 0;offs < state->m_spriteram.bytes();offs += 4) |
| 316 | for (offs = 0;offs < m_spriteram.bytes();offs += 4) |
| 321 | 317 | { |
| 322 | 318 | int code,color,flipx,flipy,sx,sy; |
| 323 | 319 | |
| r20973 | r20974 | |
| 335 | 331 | |
| 336 | 332 | code = (spriteram[offs + 2] & 0x7f) + ((spriteram[offs + 3] & 0x10) << 3) |
| 337 | 333 | + ((spriteram[offs + 3] & 0x04) << 6); |
| 338 | | color = (spriteram[offs + 3] & 0x07) + 8*(*state->m_palettebank & 0x07); |
| 339 | | if (state->m_bitmap_type == TYPE_SKYSKIPR) |
| 334 | color = (spriteram[offs + 3] & 0x07) + 8*(*m_palettebank & 0x07); |
| 335 | if (m_bitmap_type == TYPE_SKYSKIPR) |
| 340 | 336 | { |
| 341 | 337 | /* Two of the PROM address pins are tied together and one is not connected... */ |
| 342 | 338 | color = (color & 0x0f) | ((color & 0x08) << 1); |
| r20973 | r20974 | |
| 348 | 344 | sx = 2*(spriteram[offs])-8; |
| 349 | 345 | sy = 2*(256-spriteram[offs + 1]); |
| 350 | 346 | |
| 351 | | if (state->flip_screen()) |
| 347 | if (flip_screen()) |
| 352 | 348 | { |
| 353 | 349 | flipx = !flipx; |
| 354 | 350 | flipy = !flipy; |
| r20973 | r20974 | |
| 357 | 353 | } |
| 358 | 354 | |
| 359 | 355 | if (spriteram[offs] != 0) |
| 360 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 356 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 361 | 357 | code ^ 0x1ff, |
| 362 | 358 | color, |
| 363 | 359 | flipx,flipy, |
| r20973 | r20974 | |
| 367 | 363 | |
| 368 | 364 | UINT32 popeye_state::screen_update_popeye(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 369 | 365 | { |
| 370 | | draw_background(machine(), bitmap, cliprect); |
| 371 | | draw_sprites(machine(), bitmap, cliprect); |
| 366 | draw_background(bitmap, cliprect); |
| 367 | draw_sprites(bitmap, cliprect); |
| 372 | 368 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 373 | 369 | return 0; |
| 374 | 370 | } |
trunk/src/mame/video/psikyo.c
| r20973 | r20974 | |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | | void psikyo_switch_banks( running_machine &machine, int tmap, int bank ) |
| 135 | void psikyo_state::psikyo_switch_banks( int tmap, int bank ) |
| 136 | 136 | { |
| 137 | | psikyo_state *state = machine.driver_data<psikyo_state>(); |
| 138 | 137 | |
| 139 | | if ((tmap == 0) && (bank != state->m_tilemap_0_bank)) |
| 138 | if ((tmap == 0) && (bank != m_tilemap_0_bank)) |
| 140 | 139 | { |
| 141 | | state->m_tilemap_0_bank = bank; |
| 142 | | state->m_tilemap_0_size0->mark_all_dirty(); |
| 143 | | state->m_tilemap_0_size1->mark_all_dirty(); |
| 144 | | state->m_tilemap_0_size2->mark_all_dirty(); |
| 145 | | state->m_tilemap_0_size3->mark_all_dirty(); |
| 140 | m_tilemap_0_bank = bank; |
| 141 | m_tilemap_0_size0->mark_all_dirty(); |
| 142 | m_tilemap_0_size1->mark_all_dirty(); |
| 143 | m_tilemap_0_size2->mark_all_dirty(); |
| 144 | m_tilemap_0_size3->mark_all_dirty(); |
| 146 | 145 | } |
| 147 | | else if ((tmap == 1) && (bank != state->m_tilemap_1_bank)) |
| 146 | else if ((tmap == 1) && (bank != m_tilemap_1_bank)) |
| 148 | 147 | { |
| 149 | | state->m_tilemap_1_bank = bank; |
| 150 | | state->m_tilemap_1_size0->mark_all_dirty(); |
| 151 | | state->m_tilemap_1_size1->mark_all_dirty(); |
| 152 | | state->m_tilemap_1_size2->mark_all_dirty(); |
| 153 | | state->m_tilemap_1_size3->mark_all_dirty(); |
| 148 | m_tilemap_1_bank = bank; |
| 149 | m_tilemap_1_size0->mark_all_dirty(); |
| 150 | m_tilemap_1_size1->mark_all_dirty(); |
| 151 | m_tilemap_1_size2->mark_all_dirty(); |
| 152 | m_tilemap_1_size3->mark_all_dirty(); |
| 154 | 153 | } |
| 155 | 154 | } |
| 156 | 155 | |
| r20973 | r20974 | |
| 205 | 204 | { |
| 206 | 205 | VIDEO_START_CALL_MEMBER( psikyo ); |
| 207 | 206 | |
| 208 | | psikyo_switch_banks(machine(), 0, 0); // sngkace / samuraia don't use banking |
| 209 | | psikyo_switch_banks(machine(), 1, 1); // They share "gfx2" to save memory on other boards |
| 207 | psikyo_switch_banks(0, 0); // sngkace / samuraia don't use banking |
| 208 | psikyo_switch_banks(1, 1); // They share "gfx2" to save memory on other boards |
| 210 | 209 | } |
| 211 | 210 | |
| 212 | 211 | |
| r20973 | r20974 | |
| 255 | 254 | |
| 256 | 255 | ***************************************************************************/ |
| 257 | 256 | |
| 258 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen ) |
| 257 | void psikyo_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen ) |
| 259 | 258 | { |
| 260 | | psikyo_state *state = machine.driver_data<psikyo_state>(); |
| 261 | 259 | |
| 262 | 260 | /* tile layers 0 & 1 have priorities 1 & 2 */ |
| 263 | 261 | static const int pri[] = { 0, 0xfc, 0xff, 0xff }; |
| 264 | 262 | int offs; |
| 265 | | UINT16 *spritelist = (UINT16 *)(state->m_spritebuf2 + 0x1800 / 4); |
| 266 | | UINT8 *TILES = machine.root_device().memregion("spritelut")->base(); // Sprites LUT |
| 267 | | int TILES_LEN = machine.root_device().memregion("spritelut")->bytes(); |
| 263 | UINT16 *spritelist = (UINT16 *)(m_spritebuf2 + 0x1800 / 4); |
| 264 | UINT8 *TILES = machine().root_device().memregion("spritelut")->base(); // Sprites LUT |
| 265 | int TILES_LEN = machine().root_device().memregion("spritelut")->bytes(); |
| 268 | 266 | |
| 269 | | int width = machine.primary_screen->width(); |
| 270 | | int height = machine.primary_screen->height(); |
| 267 | int width = machine().primary_screen->width(); |
| 268 | int height = machine().primary_screen->height(); |
| 271 | 269 | |
| 272 | 270 | /* Exit if sprites are disabled */ |
| 273 | 271 | if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1) return; |
| r20973 | r20974 | |
| 295 | 293 | sprite = spritelist[BYTE_XOR_BE(offs)]; |
| 296 | 294 | |
| 297 | 295 | sprite %= 0x300; |
| 298 | | source = &state->m_spritebuf2[sprite * 8 / 4]; |
| 296 | source = &m_spritebuf2[sprite * 8 / 4]; |
| 299 | 297 | |
| 300 | 298 | /* Draw this sprite */ |
| 301 | 299 | |
| r20973 | r20974 | |
| 326 | 324 | zoomx = 32 - zoomx; |
| 327 | 325 | zoomy = 32 - zoomy; |
| 328 | 326 | |
| 329 | | if (state->flip_screen()) |
| 327 | if (flip_screen()) |
| 330 | 328 | { |
| 331 | 329 | x = width - x - (nx * zoomx) / 2; |
| 332 | 330 | y = height - y - (ny * zoomy) / 2; |
| r20973 | r20974 | |
| 347 | 345 | int addr = (code * 2) & (TILES_LEN - 1); |
| 348 | 346 | |
| 349 | 347 | if (zoomx == 32 && zoomy == 32) |
| 350 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 348 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 351 | 349 | TILES[addr+1] * 256 + TILES[addr], |
| 352 | 350 | attr >> 8, |
| 353 | 351 | flipx, flipy, |
| 354 | 352 | x + dx * 16, y + dy * 16, |
| 355 | | machine.priority_bitmap, |
| 353 | machine().priority_bitmap, |
| 356 | 354 | pri[(attr & 0xc0) >> 6],trans_pen); |
| 357 | 355 | else |
| 358 | | pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0], |
| 356 | pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0], |
| 359 | 357 | TILES[addr+1] * 256 + TILES[addr], |
| 360 | 358 | attr >> 8, |
| 361 | 359 | flipx, flipy, |
| 362 | 360 | x + (dx * zoomx) / 2, y + (dy * zoomy) / 2, |
| 363 | 361 | zoomx << 11,zoomy << 11, |
| 364 | | machine.priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen); |
| 362 | machine().priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen); |
| 365 | 363 | |
| 366 | 364 | code++; |
| 367 | 365 | } |
| r20973 | r20974 | |
| 374 | 372 | // until I work out why it makes a partial copy of the sprite list, and how best to apply it |
| 375 | 373 | // sprite placement of the explosion graphic seems incorrect compared to the original sets? (no / different zoom support?) |
| 376 | 374 | // it might be a problem with the actual bootleg |
| 377 | | static void draw_sprites_bootleg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen ) |
| 375 | void psikyo_state::draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen ) |
| 378 | 376 | { |
| 379 | | psikyo_state *state = machine.driver_data<psikyo_state>(); |
| 380 | 377 | |
| 381 | 378 | /* tile layers 0 & 1 have priorities 1 & 2 */ |
| 382 | 379 | static const int pri[] = { 0, 0xfc, 0xff, 0xff }; |
| 383 | 380 | int offs; |
| 384 | | UINT16 *spritelist = (UINT16 *)(state->m_spritebuf2 + 0x1800 / 4); |
| 385 | | UINT8 *TILES = machine.root_device().memregion("spritelut")->base(); // Sprites LUT |
| 386 | | int TILES_LEN = machine.root_device().memregion("spritelut")->bytes(); |
| 381 | UINT16 *spritelist = (UINT16 *)(m_spritebuf2 + 0x1800 / 4); |
| 382 | UINT8 *TILES = machine().root_device().memregion("spritelut")->base(); // Sprites LUT |
| 383 | int TILES_LEN = machine().root_device().memregion("spritelut")->bytes(); |
| 387 | 384 | |
| 388 | | int width = machine.primary_screen->width(); |
| 389 | | int height = machine.primary_screen->height(); |
| 385 | int width = machine().primary_screen->width(); |
| 386 | int height = machine().primary_screen->height(); |
| 390 | 387 | |
| 391 | 388 | /* Exit if sprites are disabled */ |
| 392 | 389 | if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1) |
| r20973 | r20974 | |
| 415 | 412 | sprite = spritelist[BYTE_XOR_BE(offs)]; |
| 416 | 413 | |
| 417 | 414 | sprite %= 0x300; |
| 418 | | source = &state->m_spritebuf2[sprite * 8 / 4]; |
| 415 | source = &m_spritebuf2[sprite * 8 / 4]; |
| 419 | 416 | |
| 420 | 417 | /* Draw this sprite */ |
| 421 | 418 | |
| r20973 | r20974 | |
| 447 | 444 | zoomy = 32 - zoomy; |
| 448 | 445 | |
| 449 | 446 | |
| 450 | | if (state->flip_screen()) |
| 447 | if (flip_screen()) |
| 451 | 448 | { |
| 452 | 449 | x = width - x - (nx * zoomx) / 2; |
| 453 | 450 | y = height - y - (ny * zoomy) / 2; |
| r20973 | r20974 | |
| 468 | 465 | int addr = (code * 2) & (TILES_LEN-1); |
| 469 | 466 | |
| 470 | 467 | if (zoomx == 32 && zoomy == 32) |
| 471 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 468 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 472 | 469 | TILES[addr+1] * 256 + TILES[addr], |
| 473 | 470 | attr >> 8, |
| 474 | 471 | flipx, flipy, |
| 475 | 472 | x + dx * 16, y + dy * 16, |
| 476 | | machine.priority_bitmap, |
| 473 | machine().priority_bitmap, |
| 477 | 474 | pri[(attr & 0xc0) >> 6],trans_pen); |
| 478 | 475 | else |
| 479 | | pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0], |
| 476 | pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0], |
| 480 | 477 | TILES[addr+1] * 256 + TILES[addr], |
| 481 | 478 | attr >> 8, |
| 482 | 479 | flipx, flipy, |
| 483 | 480 | x + (dx * zoomx) / 2, y + (dy * zoomy) / 2, |
| 484 | 481 | zoomx << 11,zoomy << 11, |
| 485 | | machine.priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen); |
| 482 | machine().priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen); |
| 486 | 483 | |
| 487 | 484 | code++; |
| 488 | 485 | } |
| r20973 | r20974 | |
| 500 | 497 | |
| 501 | 498 | ***************************************************************************/ |
| 502 | 499 | |
| 503 | | static int tilemap_width( int size ) |
| 500 | int psikyo_state::tilemap_width( int size ) |
| 504 | 501 | { |
| 505 | 502 | if (size == 0) |
| 506 | 503 | return 0x80 * 16; |
| r20973 | r20974 | |
| 561 | 558 | /* For gfx banking for s1945jn/gunbird/btlkroad */ |
| 562 | 559 | if (m_ka302c_banking) |
| 563 | 560 | { |
| 564 | | psikyo_switch_banks(machine(), 0, (layer0_ctrl & 0x400) >> 10); |
| 565 | | psikyo_switch_banks(machine(), 1, (layer1_ctrl & 0x400) >> 10); |
| 561 | psikyo_switch_banks(0, (layer0_ctrl & 0x400) >> 10); |
| 562 | psikyo_switch_banks(1, (layer1_ctrl & 0x400) >> 10); |
| 566 | 563 | } |
| 567 | 564 | |
| 568 | 565 | switch ((layer0_ctrl & 0x00c0) >> 6) |
| r20973 | r20974 | |
| 672 | 669 | tmptilemap1->draw(bitmap, cliprect, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2); |
| 673 | 670 | |
| 674 | 671 | if (layers_ctrl & 4) |
| 675 | | draw_sprites(machine(), bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15)); |
| 672 | draw_sprites(bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15)); |
| 676 | 673 | |
| 677 | 674 | return 0; |
| 678 | 675 | } |
| r20973 | r20974 | |
| 734 | 731 | /* For gfx banking for s1945jn/gunbird/btlkroad */ |
| 735 | 732 | if (m_ka302c_banking) |
| 736 | 733 | { |
| 737 | | psikyo_switch_banks(machine(), 0, (layer0_ctrl & 0x400) >> 10); |
| 738 | | psikyo_switch_banks(machine(), 1, (layer1_ctrl & 0x400) >> 10); |
| 734 | psikyo_switch_banks(0, (layer0_ctrl & 0x400) >> 10); |
| 735 | psikyo_switch_banks(1, (layer1_ctrl & 0x400) >> 10); |
| 739 | 736 | } |
| 740 | 737 | |
| 741 | 738 | switch ((layer0_ctrl & 0x00c0) >> 6) |
| r20973 | r20974 | |
| 845 | 842 | tmptilemap1->draw(bitmap, cliprect, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2); |
| 846 | 843 | |
| 847 | 844 | if (layers_ctrl & 4) |
| 848 | | draw_sprites_bootleg(machine(), bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15)); |
| 845 | draw_sprites_bootleg(bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15)); |
| 849 | 846 | |
| 850 | 847 | return 0; |
| 851 | 848 | } |
trunk/src/mame/video/playmark.c
| r20973 | r20974 | |
| 385 | 385 | |
| 386 | 386 | ***************************************************************************/ |
| 387 | 387 | |
| 388 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift ) |
| 388 | void playmark_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift ) |
| 389 | 389 | { |
| 390 | | playmark_state *state = machine.driver_data<playmark_state>(); |
| 391 | | int offs, start_offset = state->m_spriteram.bytes() / 2 - 4; |
| 392 | | int height = machine.gfx[0]->height(); |
| 393 | | int colordiv = machine.gfx[0]->granularity() / 16; |
| 394 | | UINT16 *spriteram = state->m_spriteram; |
| 390 | int offs, start_offset = m_spriteram.bytes() / 2 - 4; |
| 391 | int height = machine().gfx[0]->height(); |
| 392 | int colordiv = machine().gfx[0]->granularity() / 16; |
| 393 | UINT16 *spriteram = m_spriteram; |
| 395 | 394 | |
| 396 | 395 | // find the "end of list" to draw the sprites in reverse order |
| 397 | | for (offs = 4; offs < state->m_spriteram.bytes() / 2; offs += 4) |
| 396 | for (offs = 4; offs < m_spriteram.bytes() / 2; offs += 4) |
| 398 | 397 | { |
| 399 | 398 | if (spriteram[offs + 3 - 4] == 0x2000) /* end of list marker */ |
| 400 | 399 | { |
| r20973 | r20974 | |
| 419 | 418 | if(!pri && (color & 0x0c) == 0x0c) |
| 420 | 419 | pri = 2; |
| 421 | 420 | |
| 422 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 421 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 423 | 422 | code, |
| 424 | 423 | color, |
| 425 | 424 | flipx,0, |
| 426 | | sx + state->m_xoffset,sy + state->m_yoffset, |
| 427 | | machine.priority_bitmap,state->m_pri_masks[pri],0); |
| 425 | sx + m_xoffset,sy + m_yoffset, |
| 426 | machine().priority_bitmap,m_pri_masks[pri],0); |
| 428 | 427 | } |
| 429 | 428 | } |
| 430 | 429 | |
| 431 | 430 | |
| 432 | | static void bigtwinb_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift ) |
| 431 | void playmark_state::bigtwinb_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift ) |
| 433 | 432 | { |
| 434 | | playmark_state *state = machine.driver_data<playmark_state>(); |
| 435 | | int offs, start_offset = state->m_spriteram.bytes() / 2 - 4; |
| 436 | | int height = machine.gfx[0]->height(); |
| 437 | | UINT16 *spriteram = state->m_spriteram; |
| 433 | int offs, start_offset = m_spriteram.bytes() / 2 - 4; |
| 434 | int height = machine().gfx[0]->height(); |
| 435 | UINT16 *spriteram = m_spriteram; |
| 438 | 436 | |
| 439 | 437 | // find the "end of list" to draw the sprites in reverse order |
| 440 | | for (offs = 4; offs < state->m_spriteram.bytes() / 2; offs += 4) |
| 438 | for (offs = 4; offs < m_spriteram.bytes() / 2; offs += 4) |
| 441 | 439 | { |
| 442 | 440 | if (spriteram[offs + 3 - 4] == 0x2000) /* end of list marker */ |
| 443 | 441 | { |
| r20973 | r20974 | |
| 458 | 456 | code = spriteram[offs + 2] >> codeshift; |
| 459 | 457 | color = ((spriteram[offs + 1] & 0xf000) >> 12); |
| 460 | 458 | |
| 461 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 459 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 462 | 460 | code, |
| 463 | 461 | color, |
| 464 | 462 | flipx,0, |
| 465 | | sx + state->m_xoffset,sy + state->m_yoffset, 0); |
| 463 | sx + m_xoffset,sy + m_yoffset, 0); |
| 466 | 464 | } |
| 467 | 465 | } |
| 468 | 466 | |
| 469 | | static void draw_bitmap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 467 | void playmark_state::draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 470 | 468 | { |
| 471 | | playmark_state *state = machine.driver_data<playmark_state>(); |
| 472 | 469 | int x, y, count; |
| 473 | 470 | int color; |
| 474 | 471 | UINT8 *pri; |
| r20973 | r20974 | |
| 478 | 475 | { |
| 479 | 476 | for (x = 0; x < 512; x++) |
| 480 | 477 | { |
| 481 | | color = state->m_bgvideoram[count] & 0xff; |
| 478 | color = m_bgvideoram[count] & 0xff; |
| 482 | 479 | |
| 483 | 480 | if (color) |
| 484 | 481 | { |
| 485 | | if (state->m_bg_full_size) |
| 482 | if (m_bg_full_size) |
| 486 | 483 | { |
| 487 | | bitmap.pix16((y + state->m_bgscrolly) & 0x1ff, (x + state->m_bgscrollx) & 0x1ff) = 0x100 + color; |
| 484 | bitmap.pix16((y + m_bgscrolly) & 0x1ff, (x + m_bgscrollx) & 0x1ff) = 0x100 + color; |
| 488 | 485 | |
| 489 | | pri = &machine.priority_bitmap.pix8((y + state->m_bgscrolly) & 0x1ff); |
| 490 | | pri[(x + state->m_bgscrollx) & 0x1ff] |= 2; |
| 486 | pri = &machine().priority_bitmap.pix8((y + m_bgscrolly) & 0x1ff); |
| 487 | pri[(x + m_bgscrollx) & 0x1ff] |= 2; |
| 491 | 488 | } |
| 492 | 489 | else |
| 493 | 490 | { |
| 494 | 491 | /* 50% size */ |
| 495 | 492 | if(!(x % 2) && !(y % 2)) |
| 496 | 493 | { |
| 497 | | bitmap.pix16((y / 2 + state->m_bgscrolly) & 0x1ff, (x / 2 + state->m_bgscrollx) & 0x1ff) = 0x100 + color; |
| 494 | bitmap.pix16((y / 2 + m_bgscrolly) & 0x1ff, (x / 2 + m_bgscrollx) & 0x1ff) = 0x100 + color; |
| 498 | 495 | |
| 499 | | pri = &machine.priority_bitmap.pix8((y / 2 + state->m_bgscrolly) & 0x1ff); |
| 500 | | pri[(x / 2 + state->m_bgscrollx) & 0x1ff] |= 2; |
| 496 | pri = &machine().priority_bitmap.pix8((y / 2 + m_bgscrolly) & 0x1ff); |
| 497 | pri[(x / 2 + m_bgscrollx) & 0x1ff] |= 2; |
| 501 | 498 | } |
| 502 | 499 | } |
| 503 | 500 | } |
| r20973 | r20974 | |
| 513 | 510 | |
| 514 | 511 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 515 | 512 | if (m_bg_enable) |
| 516 | | draw_bitmap(machine(), bitmap, cliprect); |
| 517 | | draw_sprites(machine(), bitmap, cliprect, 4); |
| 513 | draw_bitmap(bitmap, cliprect); |
| 514 | draw_sprites(bitmap, cliprect, 4); |
| 518 | 515 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 519 | 516 | return 0; |
| 520 | 517 | } |
| r20973 | r20974 | |
| 527 | 524 | { |
| 528 | 525 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 529 | 526 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 530 | | bigtwinb_draw_sprites(machine(), bitmap, cliprect, 4); |
| 527 | bigtwinb_draw_sprites(bitmap, cliprect, 4); |
| 531 | 528 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 532 | 529 | } |
| 533 | 530 | else |
| r20973 | r20974 | |
| 541 | 538 | |
| 542 | 539 | m_fg_tilemap->draw(bitmap, cliprect, 0, 1); |
| 543 | 540 | if (m_bg_enable) |
| 544 | | draw_bitmap(machine(), bitmap, cliprect); |
| 541 | draw_bitmap(bitmap, cliprect); |
| 545 | 542 | m_tx_tilemap->draw(bitmap, cliprect, 0, 4); |
| 546 | | draw_sprites(machine(), bitmap, cliprect, 2); |
| 543 | draw_sprites(bitmap, cliprect, 2); |
| 547 | 544 | return 0; |
| 548 | 545 | } |
| 549 | 546 | |
| r20973 | r20974 | |
| 567 | 564 | |
| 568 | 565 | m_bg_tilemap->draw(bitmap, cliprect, 0, 1); |
| 569 | 566 | m_fg_tilemap->draw(bitmap, cliprect, 0, 2); |
| 570 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 567 | draw_sprites(bitmap, cliprect, 0); |
| 571 | 568 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 572 | 569 | return 0; |
| 573 | 570 | } |
| r20973 | r20974 | |
| 581 | 578 | { |
| 582 | 579 | m_bg_tilemap->draw(bitmap, cliprect, 0, 1); |
| 583 | 580 | m_fg_tilemap->draw(bitmap, cliprect, 0, 2); |
| 584 | | draw_sprites(machine(), bitmap, cliprect, 2); |
| 581 | draw_sprites(bitmap, cliprect, 2); |
| 585 | 582 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 586 | 583 | } |
| 587 | 584 | else |
trunk/src/mame/video/psychic5.c
| r20973 | r20974 | |
| 23 | 23 | Palette color |
| 24 | 24 | ***************************************************************************/ |
| 25 | 25 | |
| 26 | | static void psychic5_change_palette(running_machine &machine, int color, int offset) |
| 26 | void psychic5_state::psychic5_change_palette(int color, int offset) |
| 27 | 27 | { |
| 28 | | psychic5_state *state = machine.driver_data<psychic5_state>(); |
| 29 | | UINT8 lo = state->m_ps5_palette_ram[offset & ~1]; |
| 30 | | UINT8 hi = state->m_ps5_palette_ram[offset | 1]; |
| 28 | UINT8 lo = m_ps5_palette_ram[offset & ~1]; |
| 29 | UINT8 hi = m_ps5_palette_ram[offset | 1]; |
| 31 | 30 | jal_blend_set(color, hi & 0x0f); |
| 32 | | palette_set_color_rgb(machine, color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4)); |
| 31 | palette_set_color_rgb(machine(), color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4)); |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | | static void psychic5_change_bg_palette(running_machine &machine, int color, int lo_offs, int hi_offs) |
| 34 | void psychic5_state::psychic5_change_bg_palette(int color, int lo_offs, int hi_offs) |
| 36 | 35 | { |
| 37 | | psychic5_state *state = machine.driver_data<psychic5_state>(); |
| 38 | 36 | UINT8 r,g,b,lo,hi,ir,ig,ib,ix; |
| 39 | 37 | rgb_t irgb; |
| 40 | 38 | |
| 41 | 39 | /* red,green,blue intensities */ |
| 42 | | ir = pal4bit(state->m_palette_intensity >> 12); |
| 43 | | ig = pal4bit(state->m_palette_intensity >> 8); |
| 44 | | ib = pal4bit(state->m_palette_intensity >> 4); |
| 45 | | ix = state->m_palette_intensity & 0x0f; |
| 40 | ir = pal4bit(m_palette_intensity >> 12); |
| 41 | ig = pal4bit(m_palette_intensity >> 8); |
| 42 | ib = pal4bit(m_palette_intensity >> 4); |
| 43 | ix = m_palette_intensity & 0x0f; |
| 46 | 44 | |
| 47 | 45 | irgb = MAKE_RGB(ir,ig,ib); |
| 48 | 46 | |
| 49 | | lo = state->m_ps5_palette_ram[lo_offs]; |
| 50 | | hi = state->m_ps5_palette_ram[hi_offs]; |
| 47 | lo = m_ps5_palette_ram[lo_offs]; |
| 48 | hi = m_ps5_palette_ram[hi_offs]; |
| 51 | 49 | |
| 52 | 50 | /* red,green,blue component */ |
| 53 | 51 | r = pal4bit(lo >> 4); |
| r20973 | r20974 | |
| 55 | 53 | b = pal4bit(hi >> 4); |
| 56 | 54 | |
| 57 | 55 | /* Grey background enable */ |
| 58 | | if (state->m_bg_status & 2) |
| 56 | if (m_bg_status & 2) |
| 59 | 57 | { |
| 60 | 58 | UINT8 val = (r + g + b) / 3; /* Grey */ |
| 61 | 59 | /* Just leave plain grey */ |
| 62 | | palette_set_color(machine,color,jal_blend_func(MAKE_RGB(val,val,val),irgb,ix)); |
| 60 | palette_set_color(machine(),color,jal_blend_func(MAKE_RGB(val,val,val),irgb,ix)); |
| 63 | 61 | } |
| 64 | 62 | else |
| 65 | 63 | { |
| 66 | 64 | /* Seems fishy, but the title screen would be black otherwise... */ |
| 67 | | if (!(state->m_title_screen & 1)) |
| 65 | if (!(m_title_screen & 1)) |
| 68 | 66 | { |
| 69 | 67 | /* Leave the world as-is */ |
| 70 | | palette_set_color(machine,color,jal_blend_func(MAKE_RGB(r,g,b),irgb,ix)); |
| 68 | palette_set_color(machine(),color,jal_blend_func(MAKE_RGB(r,g,b),irgb,ix)); |
| 71 | 69 | } |
| 72 | 70 | } |
| 73 | 71 | } |
| 74 | 72 | |
| 75 | | static void set_background_palette_intensity(running_machine &machine) |
| 73 | void psychic5_state::set_background_palette_intensity() |
| 76 | 74 | { |
| 77 | | psychic5_state *state = machine.driver_data<psychic5_state>(); |
| 78 | 75 | int i; |
| 79 | | state->m_palette_intensity = state->m_ps5_palette_ram[BG_PAL_INTENSITY_BU] | |
| 80 | | (state->m_ps5_palette_ram[BG_PAL_INTENSITY_RG]<<8); |
| 76 | m_palette_intensity = m_ps5_palette_ram[BG_PAL_INTENSITY_BU] | |
| 77 | (m_ps5_palette_ram[BG_PAL_INTENSITY_RG]<<8); |
| 81 | 78 | |
| 82 | 79 | /* for all of the background palette */ |
| 83 | 80 | for (i = 0; i < 0x100; i++) |
| 84 | | psychic5_change_bg_palette(machine,state->m_bg_palette_base+i,state->m_bg_palette_ram_base+i*2,state->m_bg_palette_ram_base+i*2+1); |
| 81 | psychic5_change_bg_palette(m_bg_palette_base+i,m_bg_palette_ram_base+i*2,m_bg_palette_ram_base+i*2+1); |
| 85 | 82 | } |
| 86 | 83 | |
| 87 | 84 | |
| r20973 | r20974 | |
| 147 | 144 | m_bg_status = m_ps5_io_ram[BG_SCREEN_MODE]; |
| 148 | 145 | } |
| 149 | 146 | else if (offset >= 0x400 && offset <= 0x5ff) /* Sprite color */ |
| 150 | | psychic5_change_palette(machine(),((offset >> 1) & 0xff)+0x000,offset-0x400); |
| 147 | psychic5_change_palette(((offset >> 1) & 0xff)+0x000,offset-0x400); |
| 151 | 148 | else if (offset >= 0x800 && offset <= 0x9ff) /* BG color */ |
| 152 | | psychic5_change_palette(machine(),((offset >> 1) & 0xff)+0x100,offset-0x400); |
| 149 | psychic5_change_palette(((offset >> 1) & 0xff)+0x100,offset-0x400); |
| 153 | 150 | else if (offset >= 0xa00 && offset <= 0xbff) /* Text color */ |
| 154 | | psychic5_change_palette(machine(),((offset >> 1) & 0xff)+0x200,offset-0x400); |
| 151 | psychic5_change_palette(((offset >> 1) & 0xff)+0x200,offset-0x400); |
| 155 | 152 | else if (offset >= 0x1000) |
| 156 | 153 | m_fg_tilemap->mark_tile_dirty((offset-0x1000) >> 1); |
| 157 | 154 | } |
| r20973 | r20974 | |
| 184 | 181 | else if (offset >= 0x0800 && offset <= 0x0fff) |
| 185 | 182 | m_fg_tilemap->mark_tile_dirty((offset & 0x7ff) >> 1); |
| 186 | 183 | else if (offset >= 0x1000 && offset <= 0x15ff) |
| 187 | | psychic5_change_palette(machine(), (offset >> 1) & 0x3ff, offset-0x1000); |
| 184 | psychic5_change_palette((offset >> 1) & 0x3ff, offset-0x1000); |
| 188 | 185 | } |
| 189 | 186 | } |
| 190 | 187 | |
| r20973 | r20974 | |
| 296 | 293 | Screen refresh |
| 297 | 294 | ***************************************************************************/ |
| 298 | 295 | |
| 299 | | #define DRAW_SPRITE(code, sx, sy) jal_blend_drawgfx(bitmap, cliprect, machine.gfx[0], code, color, flipx, flipy, sx, sy, 15); |
| 296 | #define DRAW_SPRITE(code, sx, sy) jal_blend_drawgfx(bitmap, cliprect, machine().gfx[0], code, color, flipx, flipy, sx, sy, 15); |
| 300 | 297 | |
| 301 | | static void draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 298 | void psychic5_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 302 | 299 | { |
| 303 | | psychic5_state *state = machine.driver_data<psychic5_state>(); |
| 304 | | UINT8 *spriteram = state->m_spriteram; |
| 300 | UINT8 *spriteram = m_spriteram; |
| 305 | 301 | int offs; |
| 306 | 302 | |
| 307 | 303 | /* Draw the sprites */ |
| 308 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16) |
| 304 | for (offs = 0; offs < m_spriteram.bytes(); offs += 16) |
| 309 | 305 | { |
| 310 | 306 | int attr = spriteram[offs + 13]; |
| 311 | 307 | int code = spriteram[offs + 14] | ((attr & 0xc0) << 2); |
| r20973 | r20974 | |
| 319 | 315 | if (attr & 0x01) sx -= 256; |
| 320 | 316 | if (attr & 0x04) sy -= 256; |
| 321 | 317 | |
| 322 | | if (state->flip_screen()) |
| 318 | if (flip_screen()) |
| 323 | 319 | { |
| 324 | 320 | sx = 224 - sx; |
| 325 | 321 | sy = 224 - sy; |
| r20973 | r20974 | |
| 344 | 340 | } |
| 345 | 341 | else |
| 346 | 342 | { |
| 347 | | if (state->flip_screen()) |
| 343 | if (flip_screen()) |
| 348 | 344 | DRAW_SPRITE(code, sx + 16, sy + 16) |
| 349 | 345 | else |
| 350 | 346 | DRAW_SPRITE(code, sx, sy) |
| r20973 | r20974 | |
| 352 | 348 | } |
| 353 | 349 | } |
| 354 | 350 | |
| 355 | | static void draw_background(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 351 | void psychic5_state::draw_background(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 356 | 352 | { |
| 357 | | psychic5_state *state = machine.driver_data<psychic5_state>(); |
| 358 | | UINT8 *spriteram = state->m_spriteram; |
| 353 | UINT8 *spriteram = m_spriteram; |
| 359 | 354 | |
| 360 | 355 | rectangle clip = cliprect; |
| 361 | 356 | |
| 362 | | set_background_palette_intensity(machine); |
| 357 | set_background_palette_intensity(); |
| 363 | 358 | |
| 364 | | if (!(state->m_title_screen & 1)) |
| 359 | if (!(m_title_screen & 1)) |
| 365 | 360 | { |
| 366 | | state->m_bg_clip_mode = 0; |
| 367 | | state->m_sx1 = state->m_sy1 = state->m_sy2 = 0; |
| 361 | m_bg_clip_mode = 0; |
| 362 | m_sx1 = m_sy1 = m_sy2 = 0; |
| 368 | 363 | } |
| 369 | 364 | else |
| 370 | 365 | { |
| 371 | | int sy1_old = state->m_sy1; |
| 372 | | int sx1_old = state->m_sx1; |
| 373 | | int sy2_old = state->m_sy2; |
| 366 | int sy1_old = m_sy1; |
| 367 | int sx1_old = m_sx1; |
| 368 | int sy2_old = m_sy2; |
| 374 | 369 | |
| 375 | | state->m_sy1 = spriteram[11]; /* sprite 0 */ |
| 376 | | state->m_sx1 = spriteram[12]; |
| 377 | | state->m_sy2 = spriteram[11+128]; /* sprite 8 */ |
| 370 | m_sy1 = spriteram[11]; /* sprite 0 */ |
| 371 | m_sx1 = spriteram[12]; |
| 372 | m_sy2 = spriteram[11+128]; /* sprite 8 */ |
| 378 | 373 | |
| 379 | | switch (state->m_bg_clip_mode) |
| 374 | switch (m_bg_clip_mode) |
| 380 | 375 | { |
| 381 | | case 0: case 4: if (sy1_old != state->m_sy1) state->m_bg_clip_mode++; break; |
| 382 | | case 2: case 6: if (sy2_old != state->m_sy2) state->m_bg_clip_mode++; break; |
| 376 | case 0: case 4: if (sy1_old != m_sy1) m_bg_clip_mode++; break; |
| 377 | case 2: case 6: if (sy2_old != m_sy2) m_bg_clip_mode++; break; |
| 383 | 378 | case 8: case 10: |
| 384 | | case 12: case 14: if (sx1_old != state->m_sx1) state->m_bg_clip_mode++; break; |
| 385 | | case 1: case 5: if (state->m_sy1 == 0xf0) state->m_bg_clip_mode++; break; |
| 386 | | case 3: case 7: if (state->m_sy2 == 0xf0) state->m_bg_clip_mode++; break; |
| 387 | | case 9: case 11: if (state->m_sx1 == 0xf0) state->m_bg_clip_mode++; break; |
| 388 | | case 13: case 15: if (sx1_old == 0xf0) state->m_bg_clip_mode++; |
| 389 | | case 16: if (state->m_sy1 != 0x00) state->m_bg_clip_mode = 0; break; |
| 379 | case 12: case 14: if (sx1_old != m_sx1) m_bg_clip_mode++; break; |
| 380 | case 1: case 5: if (m_sy1 == 0xf0) m_bg_clip_mode++; break; |
| 381 | case 3: case 7: if (m_sy2 == 0xf0) m_bg_clip_mode++; break; |
| 382 | case 9: case 11: if (m_sx1 == 0xf0) m_bg_clip_mode++; break; |
| 383 | case 13: case 15: if (sx1_old == 0xf0) m_bg_clip_mode++; |
| 384 | case 16: if (m_sy1 != 0x00) m_bg_clip_mode = 0; break; |
| 390 | 385 | } |
| 391 | 386 | |
| 392 | | switch (state->m_bg_clip_mode) |
| 387 | switch (m_bg_clip_mode) |
| 393 | 388 | { |
| 394 | 389 | case 0: case 4: case 8: case 12: case 16: |
| 395 | 390 | clip.set(0, 0, 0, 0); |
| 396 | 391 | break; |
| 397 | | case 1: clip.min_y = state->m_sy1; break; |
| 398 | | case 3: clip.max_y = state->m_sy2; break; |
| 399 | | case 5: clip.max_y = state->m_sy1; break; |
| 400 | | case 7: clip.min_y = state->m_sy2; break; |
| 401 | | case 9: case 15: clip.min_x = state->m_sx1; break; |
| 402 | | case 11: case 13: clip.max_x = state->m_sx1; break; |
| 392 | case 1: clip.min_y = m_sy1; break; |
| 393 | case 3: clip.max_y = m_sy2; break; |
| 394 | case 5: clip.max_y = m_sy1; break; |
| 395 | case 7: clip.min_y = m_sy2; break; |
| 396 | case 9: case 15: clip.min_x = m_sx1; break; |
| 397 | case 11: case 13: clip.max_x = m_sx1; break; |
| 403 | 398 | } |
| 404 | 399 | |
| 405 | | if (state->flip_screen()) |
| 400 | if (flip_screen()) |
| 406 | 401 | clip.set(255 - clip.max_x, 255 - clip.min_x, 255 - clip.max_y, 255 - clip.min_y); |
| 407 | 402 | } |
| 408 | 403 | |
| 409 | | state->m_bg_tilemap->draw(bitmap, clip, 0, 0); |
| 404 | m_bg_tilemap->draw(bitmap, clip, 0, 0); |
| 410 | 405 | } |
| 411 | 406 | |
| 412 | 407 | UINT32 psychic5_state::screen_update_psychic5(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 413 | 408 | { |
| 414 | 409 | bitmap.fill(get_black_pen(machine()), cliprect); |
| 415 | 410 | if (m_bg_status & 1) /* Backgound enable */ |
| 416 | | draw_background(machine(), bitmap, cliprect); |
| 411 | draw_background(bitmap, cliprect); |
| 417 | 412 | if (!(m_title_screen & 1)) |
| 418 | | draw_sprites(machine(), bitmap, cliprect); |
| 413 | draw_sprites(bitmap, cliprect); |
| 419 | 414 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 420 | 415 | return 0; |
| 421 | 416 | } |
| r20973 | r20974 | |
| 426 | 421 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 427 | 422 | else |
| 428 | 423 | bitmap.fill(machine().pens[0x0ff], cliprect); |
| 429 | | draw_sprites(machine(), bitmap, cliprect); |
| 424 | draw_sprites(bitmap, cliprect); |
| 430 | 425 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 431 | 426 | return 0; |
| 432 | 427 | } |
trunk/src/mame/video/psikyosh.c
| r20973 | r20974 | |
| 140 | 140 | draw_scanline32_alpha - take an RGB-encoded UINT32 |
| 141 | 141 | scanline and alpha-blend it into the destination bitmap |
| 142 | 142 | -------------------------------------------------*/ |
| 143 | | static void draw_scanline32_alpha(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, int alpha) |
| 143 | void psikyosh_state::draw_scanline32_alpha(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, int alpha) |
| 144 | 144 | { |
| 145 | 145 | DECLARE_NO_PRIORITY; |
| 146 | 146 | UINT32 transpen = BG_TRANSPEN; |
| r20973 | r20974 | |
| 152 | 152 | draw_scanline32_argb - take an ARGB-encoded UINT32 |
| 153 | 153 | scanline and alpha-blend it into the destination bitmap |
| 154 | 154 | -------------------------------------------------*/ |
| 155 | | static void draw_scanline32_argb(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr) |
| 155 | void psikyosh_state::draw_scanline32_argb(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr) |
| 156 | 156 | { |
| 157 | 157 | DECLARE_NO_PRIORITY; |
| 158 | 158 | UINT32 transpen = BG_TRANSPEN; |
| r20973 | r20974 | |
| 164 | 164 | draw_scanline32_tranpens - take an RGB-encoded UINT32 |
| 165 | 165 | scanline and copy it into the destination bitmap, testing for the special ARGB transpen |
| 166 | 166 | -------------------------------------------------*/ |
| 167 | | static void draw_scanline32_transpen(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr) |
| 167 | void psikyosh_state::draw_scanline32_transpen(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr) |
| 168 | 168 | { |
| 169 | 169 | DECLARE_NO_PRIORITY; |
| 170 | 170 | UINT32 transpen = BG_TRANSPEN; |
| r20973 | r20974 | |
| 261 | 261 | |
| 262 | 262 | /* 'Normal' layers, no line/columnscroll. No per-line effects. |
| 263 | 263 | Zooming isn't supported just because it's not used and it would be slow */ |
| 264 | | static void draw_bglayer( running_machine &machine, int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 264 | void psikyosh_state::draw_bglayer( int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 265 | 265 | { |
| 266 | | psikyosh_state *state = machine.driver_data<psikyosh_state>(); |
| 267 | 266 | gfx_element *gfx; |
| 268 | 267 | int offs = 0, sx, sy; |
| 269 | 268 | int scrollx, scrolly, regbank, tilebank, alpha, alphamap, zoom, pri, size, width; |
| 270 | 269 | |
| 271 | 270 | assert(!BG_LINE(layer)); |
| 272 | 271 | |
| 273 | | gfx = BG_DEPTH_8BPP(layer) ? machine.gfx[1] : machine.gfx[0]; |
| 272 | gfx = BG_DEPTH_8BPP(layer) ? machine().gfx[1] : machine().gfx[0]; |
| 274 | 273 | size = BG_LARGE(layer) ? 32 : 16; |
| 275 | 274 | width = 16 * size; |
| 276 | 275 | |
| 277 | 276 | regbank = BG_TYPE(layer); |
| 278 | 277 | |
| 279 | | scrollx = (state->m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000001ff) >> 0; |
| 280 | | scrolly = (state->m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x03ff0000) >> 16; |
| 278 | scrollx = (m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000001ff) >> 0; |
| 279 | scrolly = (m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x03ff0000) >> 16; |
| 281 | 280 | |
| 282 | | tilebank = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000000ff) >> 0; |
| 283 | | alpha = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00003f00) >> 8; |
| 284 | | alphamap = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00008000) >> 15; |
| 285 | | zoom = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00ff0000) >> 16; |
| 286 | | pri = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0xff000000) >> 24; |
| 281 | tilebank = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000000ff) >> 0; |
| 282 | alpha = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00003f00) >> 8; |
| 283 | alphamap = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00008000) >> 15; |
| 284 | zoom = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00ff0000) >> 16; |
| 285 | pri = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0xff000000) >> 24; |
| 287 | 286 | |
| 288 | 287 | if(pri != req_pri) return; |
| 289 | 288 | |
| r20973 | r20974 | |
| 304 | 303 | { |
| 305 | 304 | int tileno, colour; |
| 306 | 305 | |
| 307 | | tileno = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ |
| 308 | | colour = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; |
| 306 | tileno = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ |
| 307 | colour = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; |
| 309 | 308 | |
| 310 | 309 | drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */ |
| 311 | 310 | |
| r20973 | r20974 | |
| 324 | 323 | |
| 325 | 324 | |
| 326 | 325 | /* populate bg_bitmap for the given bank if it's not already */ |
| 327 | | static void cache_bitmap(int scanline, psikyosh_state *state, gfx_element *gfx, int size, int tilebank, int alpha, int *last_bank) |
| 326 | void psikyosh_state::cache_bitmap(int scanline, gfx_element *gfx, int size, int tilebank, int alpha, int *last_bank) |
| 328 | 327 | { |
| 329 | 328 | // test if the tile row is the cached one or not |
| 330 | 329 | int sy = scanline / 16; |
| r20973 | r20974 | |
| 335 | 334 | { |
| 336 | 335 | rectangle cliprect; |
| 337 | 336 | |
| 338 | | cliprect.set(0, state->m_bg_bitmap.width() - 1, sy * 16, cliprect.min_y + 16 - 1); |
| 337 | cliprect.set(0, m_bg_bitmap.width() - 1, sy * 16, cliprect.min_y + 16 - 1); |
| 339 | 338 | |
| 340 | | state->m_bg_bitmap.fill(BG_TRANSPEN, cliprect); |
| 339 | m_bg_bitmap.fill(BG_TRANSPEN, cliprect); |
| 341 | 340 | int width = size * 16; |
| 342 | 341 | |
| 343 | 342 | int offs = size * sy; |
| r20973 | r20974 | |
| 347 | 346 | { |
| 348 | 347 | int tileno, colour; |
| 349 | 348 | |
| 350 | | tileno = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ |
| 351 | | colour = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; |
| 349 | tileno = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ |
| 350 | colour = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; |
| 352 | 351 | int need_alpha = alpha < 0 ? -1 : 0xff; // store per-pen alpha in bitmap, otherwise don't since we'll need it per-line |
| 353 | 352 | |
| 354 | 353 | if(tileno) { // valid tile, but blank in all games? |
| 355 | | drawgfx_alphastore(state->m_bg_bitmap, state->m_bg_bitmap.cliprect(), gfx, tileno, colour, 0, 0, (16 * sx) & 0x1ff, ((16 * sy) & (width - 1)), need_alpha); |
| 354 | drawgfx_alphastore(m_bg_bitmap, m_bg_bitmap.cliprect(), gfx, tileno, colour, 0, 0, (16 * sx) & 0x1ff, ((16 * sy) & (width - 1)), need_alpha); |
| 356 | 355 | } |
| 357 | 356 | |
| 358 | 357 | offs++; |
| r20973 | r20974 | |
| 366 | 365 | Bitmap is first rendered to an ARGB image, taking into account the per-pen alpha (if used). |
| 367 | 366 | From there we extract data as we compose the image, one scanline at a time, blending the ARGB pixels |
| 368 | 367 | into the RGB32 bitmap (with either the alpha information from the ARGB, or per-line alpha */ |
| 369 | | static void draw_bglayerscroll( running_machine &machine, int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 368 | void psikyosh_state::draw_bglayerscroll( int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 370 | 369 | { |
| 371 | | psikyosh_state *state = machine.driver_data<psikyosh_state>(); |
| 372 | 370 | assert(BG_LINE(layer)); |
| 373 | 371 | |
| 374 | | gfx_element *gfx = BG_DEPTH_8BPP(layer) ? machine.gfx[1] : machine.gfx[0]; |
| 372 | gfx_element *gfx = BG_DEPTH_8BPP(layer) ? machine().gfx[1] : machine().gfx[0]; |
| 375 | 373 | int size = BG_LARGE(layer) ? 32 : 16; |
| 376 | 374 | int width = size * 16; |
| 377 | 375 | |
| 378 | 376 | int linebank = BG_TYPE(layer); |
| 379 | 377 | |
| 380 | 378 | /* cache rendered bitmap */ |
| 381 | | int last_bank[32]; // corresponds to bank of bitmap in state->m_bg_bitmap. bg_bitmap is split into 16/32-rows of one-tile high each |
| 379 | int last_bank[32]; // corresponds to bank of bitmap in m_bg_bitmap. bg_bitmap is split into 16/32-rows of one-tile high each |
| 382 | 380 | for(int ii = 0; ii < 32; ii++) last_bank[ii] = -1; |
| 383 | 381 | |
| 384 | 382 | int scr_width = cliprect.width(); |
| 385 | 383 | int scr_height = cliprect.height(); |
| 386 | | UINT32 *scroll_reg = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4]; |
| 387 | | UINT32 *pzab_reg = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; // pri, zoom, alpha, bank |
| 384 | UINT32 *scroll_reg = &m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4]; |
| 385 | UINT32 *pzab_reg = &m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; // pri, zoom, alpha, bank |
| 388 | 386 | |
| 389 | 387 | // now, for each scanline, check priority, |
| 390 | 388 | // extract the relevant scanline from the bitmap, after applying per-scanline vscroll, |
| r20973 | r20974 | |
| 414 | 412 | int tilemap_scanline = (scanline - scrolly + 0x400) % 0x200; |
| 415 | 413 | |
| 416 | 414 | // render reelvant tiles to temp bitmap, assume bank changes infrequently/never. render alpha as per-pen |
| 417 | | cache_bitmap(tilemap_scanline, state, gfx, size, tilebank, alpha, last_bank); |
| 415 | cache_bitmap(tilemap_scanline, gfx, size, tilebank, alpha, last_bank); |
| 418 | 416 | |
| 419 | 417 | /* zoomy and 'wibbly' effects - extract an entire row from tilemap */ |
| 420 | 418 | g_profiler.start(PROFILER_USER2); |
| 421 | 419 | UINT32 tilemap_line[32 * 16]; |
| 422 | 420 | UINT32 scr_line[64 * 8]; |
| 423 | | extract_scanline32(state->m_bg_bitmap, 0, tilemap_scanline, width, tilemap_line); |
| 421 | extract_scanline32(m_bg_bitmap, 0, tilemap_scanline, width, tilemap_line); |
| 424 | 422 | g_profiler.stop(); |
| 425 | 423 | |
| 426 | 424 | /* slow bit, needs optimising. apply scrollx and zoomx by assembling scanline from row */ |
| 427 | 425 | g_profiler.start(PROFILER_USER3); |
| 428 | 426 | if(zoom) { |
| 429 | | int step = state->m_bg_zoom[zoom]; |
| 427 | int step = m_bg_zoom[zoom]; |
| 430 | 428 | int jj = 0x400 << 10; // ensure +ve for mod |
| 431 | 429 | for(int ii = 0; ii < scr_width; ii++) { |
| 432 | 430 | scr_line[ii] = tilemap_line[((jj>>10) - scrollx) % width]; |
| r20973 | r20974 | |
| 461 | 459 | } |
| 462 | 460 | |
| 463 | 461 | /* 3 BG layers, with priority */ |
| 464 | | static void draw_background( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 462 | void psikyosh_state::draw_background( bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 465 | 463 | { |
| 466 | | psikyosh_state *state = machine.driver_data<psikyosh_state>(); |
| 467 | 464 | int i; |
| 468 | 465 | |
| 469 | 466 | #ifdef DEBUG_KEYS |
| r20973 | r20974 | |
| 471 | 468 | bool lay_debug = false; |
| 472 | 469 | for (i = 0; i <= 3; i++) |
| 473 | 470 | { |
| 474 | | if(machine.input().code_pressed(lay_keys[i])) { |
| 471 | if(machine().input().code_pressed(lay_keys[i])) { |
| 475 | 472 | lay_debug = true; |
| 476 | 473 | } |
| 477 | 474 | } |
| r20973 | r20974 | |
| 481 | 478 | for (i = 0; i <= 3; i++) |
| 482 | 479 | { |
| 483 | 480 | #ifdef DEBUG_KEYS |
| 484 | | if(lay_debug && !machine.input().code_pressed(lay_keys[i])) |
| 481 | if(lay_debug && !machine().input().code_pressed(lay_keys[i])) |
| 485 | 482 | continue; |
| 486 | 483 | #endif |
| 487 | 484 | |
| r20973 | r20974 | |
| 490 | 487 | |
| 491 | 488 | if(BG_LINE(i)) { |
| 492 | 489 | /* per-line alpha, scroll, zoom etc. check the priority for the first scanline */ |
| 493 | | draw_bglayerscroll(machine, i, bitmap, cliprect, req_pri); |
| 490 | draw_bglayerscroll(i, bitmap, cliprect, req_pri); |
| 494 | 491 | } |
| 495 | 492 | else { |
| 496 | 493 | /* not per-line alpha, scroll, zoom etc. */ |
| 497 | | draw_bglayer(machine, i, bitmap, cliprect, req_pri); |
| 494 | draw_bglayer(i, bitmap, cliprect, req_pri); |
| 498 | 495 | } |
| 499 | 496 | } |
| 500 | 497 | } |
| r20973 | r20974 | |
| 508 | 505 | /* sx and sy is top-left of entire sprite regardless of flip */ |
| 509 | 506 | /* Note that Level 5-4 of sbomberb boss is perfect! (Alpha blended zoomed) as well as S1945II logo */ |
| 510 | 507 | /* pixel is only plotted if z is >= priority_buffer[y][x] */ |
| 511 | | static void psikyosh_drawgfxzoom( running_machine &machine, |
| 512 | | bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 508 | void psikyosh_state:: psikyosh_drawgfxzoom( bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 513 | 509 | UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy, |
| 514 | 510 | int alpha, int zoomx, int zoomy, int wide, int high, UINT32 z) |
| 515 | 511 | { |
| 516 | | psikyosh_state *state = machine.driver_data<psikyosh_state>(); |
| 517 | | UINT8 *alphatable = state->m_alphatable; |
| 512 | UINT8 *alphatable = m_alphatable; |
| 518 | 513 | rectangle myclip; /* Clip to screen boundaries */ |
| 519 | 514 | int code_offset = 0; |
| 520 | 515 | int xtile, ytile, xpixel, ypixel; |
| r20973 | r20974 | |
| 602 | 597 | { |
| 603 | 598 | const UINT8 *source = code_base + (y_index) * gfx->rowbytes() + x_index_base; |
| 604 | 599 | UINT32 *dest = &dest_bmp.pix32(sy, sx); |
| 605 | | UINT16 *pri = &state->m_z_bitmap.pix16(sy, sx); |
| 600 | UINT16 *pri = &m_z_bitmap.pix16(sy, sx); |
| 606 | 601 | int src_modulo = yinc * gfx->rowbytes() - xinc * (ex - sx); |
| 607 | 602 | int dst_modulo = dest_bmp.rowpixels() - (ex - sx); |
| 608 | 603 | |
| r20973 | r20974 | |
| 661 | 656 | { |
| 662 | 657 | const UINT8 *source = code_base + y_index * gfx->rowbytes() + x_index_base; |
| 663 | 658 | UINT32 *dest = &dest_bmp.pix32(sy, sx); |
| 664 | | UINT16 *pri = &state->m_z_bitmap.pix16(sy, sx); |
| 659 | UINT16 *pri = &m_z_bitmap.pix16(sy, sx); |
| 665 | 660 | int src_modulo = yinc * gfx->rowbytes() - xinc * (ex - sx); |
| 666 | 661 | int dst_modulo = dest_bmp.rowpixels() - (ex - sx); |
| 667 | 662 | |
| r20973 | r20974 | |
| 721 | 716 | { |
| 722 | 717 | const UINT8 *source = code_base + y_index * gfx->rowbytes() + x_index_base; |
| 723 | 718 | UINT32 *dest = &dest_bmp.pix32(sy, sx); |
| 724 | | UINT16 *pri = &state->m_z_bitmap.pix16(sy, sx); |
| 719 | UINT16 *pri = &m_z_bitmap.pix16(sy, sx); |
| 725 | 720 | int src_modulo = yinc * gfx->rowbytes() - xinc * (ex - sx); |
| 726 | 721 | int dst_modulo = dest_bmp.rowpixels() - (ex - sx); |
| 727 | 722 | |
| r20973 | r20974 | |
| 798 | 793 | for (ypixel = 0; ypixel < gfx->height(); ypixel++) |
| 799 | 794 | { |
| 800 | 795 | const UINT8 *source = code_base + ypixel * gfx->rowbytes(); |
| 801 | | UINT8 *dest = &state->m_zoom_bitmap.pix8(ypixel + ytile*gfx->height()); |
| 796 | UINT8 *dest = &m_zoom_bitmap.pix8(ypixel + ytile*gfx->height()); |
| 802 | 797 | |
| 803 | 798 | for (xpixel = 0; xpixel < gfx->width(); xpixel++) |
| 804 | 799 | { |
| r20973 | r20974 | |
| 873 | 868 | { |
| 874 | 869 | for (y = sy; y < ey; y++) |
| 875 | 870 | { |
| 876 | | UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10); |
| 871 | UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10); |
| 877 | 872 | UINT32 *dest = &dest_bmp.pix32(y); |
| 878 | | UINT16 *pri = &state->m_z_bitmap.pix16(y); |
| 873 | UINT16 *pri = &m_z_bitmap.pix16(y); |
| 879 | 874 | |
| 880 | 875 | int x, x_index = x_index_base; |
| 881 | 876 | for (x = sx; x < ex; x++) |
| r20973 | r20974 | |
| 899 | 894 | { |
| 900 | 895 | for (y = sy; y < ey; y++) |
| 901 | 896 | { |
| 902 | | UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10); |
| 897 | UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10); |
| 903 | 898 | UINT32 *dest = &dest_bmp.pix32(y); |
| 904 | 899 | |
| 905 | 900 | int x, x_index = x_index_base; |
| r20973 | r20974 | |
| 923 | 918 | { |
| 924 | 919 | for (y = sy; y < ey; y++) |
| 925 | 920 | { |
| 926 | | UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10); |
| 921 | UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10); |
| 927 | 922 | UINT32 *dest = &dest_bmp.pix32(y); |
| 928 | | UINT16 *pri = &state->m_z_bitmap.pix16(y); |
| 923 | UINT16 *pri = &m_z_bitmap.pix16(y); |
| 929 | 924 | |
| 930 | 925 | int x, x_index = x_index_base; |
| 931 | 926 | for (x = sx; x < ex; x++) |
| r20973 | r20974 | |
| 949 | 944 | { |
| 950 | 945 | for (y = sy; y < ey; y++) |
| 951 | 946 | { |
| 952 | | UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10); |
| 947 | UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10); |
| 953 | 948 | UINT32 *dest = &dest_bmp.pix32(y); |
| 954 | 949 | |
| 955 | 950 | int x, x_index = x_index_base; |
| r20973 | r20974 | |
| 972 | 967 | { |
| 973 | 968 | for (y = sy; y < ey; y++) |
| 974 | 969 | { |
| 975 | | UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10); |
| 970 | UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10); |
| 976 | 971 | UINT32 *dest = &dest_bmp.pix32(y); |
| 977 | | UINT16 *pri = &state->m_z_bitmap.pix16(y); |
| 972 | UINT16 *pri = &m_z_bitmap.pix16(y); |
| 978 | 973 | |
| 979 | 974 | int x, x_index = x_index_base; |
| 980 | 975 | for (x = sx; x < ex; x++) |
| r20973 | r20974 | |
| 1002 | 997 | { |
| 1003 | 998 | for (y = sy; y < ey; y++) |
| 1004 | 999 | { |
| 1005 | | UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10); |
| 1000 | UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10); |
| 1006 | 1001 | UINT32 *dest = &dest_bmp.pix32(y); |
| 1007 | 1002 | |
| 1008 | 1003 | int x, x_index = x_index_base; |
| r20973 | r20974 | |
| 1031 | 1026 | } |
| 1032 | 1027 | |
| 1033 | 1028 | |
| 1034 | | static void draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri) |
| 1029 | void psikyosh_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri) |
| 1035 | 1030 | { |
| 1036 | 1031 | /*- Sprite Format 0x0000 - 0x37ff -** |
| 1037 | 1032 | |
| r20973 | r20974 | |
| 1070 | 1065 | #ifdef DEBUG_KEYS |
| 1071 | 1066 | for (int i = 0; i <= 3; i++) |
| 1072 | 1067 | { |
| 1073 | | if(machine.input().code_pressed(spr_keys[i])) { |
| 1068 | if(machine().input().code_pressed(spr_keys[i])) { |
| 1074 | 1069 | spr_debug = true; |
| 1075 | 1070 | } |
| 1076 | 1071 | } |
| 1077 | 1072 | #endif |
| 1078 | 1073 | |
| 1079 | 1074 | |
| 1080 | | psikyosh_state *state = machine.driver_data<psikyosh_state>(); |
| 1081 | 1075 | gfx_element *gfx; |
| 1082 | | UINT32 *src = state->m_spriteram->buffer(); /* Use buffered spriteram */ |
| 1076 | UINT32 *src = m_spriteram->buffer(); /* Use buffered spriteram */ |
| 1083 | 1077 | UINT16 *list = (UINT16 *)src + 0x3800 / 2; |
| 1084 | 1078 | UINT16 listlen = 0x800/2; |
| 1085 | | UINT16 *zoom_table = (UINT16 *)state->m_zoomram.target(); |
| 1086 | | UINT8 *alpha_table = (UINT8 *)&(state->m_vidregs[0]); |
| 1079 | UINT16 *zoom_table = (UINT16 *)m_zoomram.target(); |
| 1080 | UINT8 *alpha_table = (UINT8 *)&(m_vidregs[0]); |
| 1087 | 1081 | |
| 1088 | 1082 | UINT16 listcntr = 0; |
| 1089 | 1083 | while (listcntr < listlen) |
| r20973 | r20974 | |
| 1126 | 1120 | alphamap = (alpha_table[BYTE4_XOR_BE(alpha)] & 0x80)? 1:0; |
| 1127 | 1121 | alpha = alpha_table[BYTE4_XOR_BE(alpha)] & 0x3f; |
| 1128 | 1122 | |
| 1129 | | gfx = dpth ? machine.gfx[1] : machine.gfx[0]; |
| 1123 | gfx = dpth ? machine().gfx[1] : machine().gfx[0]; |
| 1130 | 1124 | |
| 1131 | 1125 | if (alphamap) /* alpha values are per-pen */ |
| 1132 | 1126 | alpha = -1; |
| 1133 | 1127 | else |
| 1134 | 1128 | alpha = pal6bit(0x3f - alpha); /* 0x3f-0x00 maps to 0x00-0xff */ |
| 1135 | 1129 | |
| 1136 | | if(!spr_debug || machine.input().code_pressed(spr_keys[spr_pri])) |
| 1130 | if(!spr_debug || machine().input().code_pressed(spr_keys[spr_pri])) |
| 1137 | 1131 | { |
| 1138 | 1132 | /* start drawing */ |
| 1139 | 1133 | if (zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)]) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */ |
| 1140 | 1134 | { |
| 1141 | | psikyosh_drawgfxzoom(machine, bitmap, cliprect, gfx, tnum, colr, flpx, flpy, xpos, ypos, alpha, |
| 1135 | psikyosh_drawgfxzoom(bitmap, cliprect, gfx, tnum, colr, flpx, flpy, xpos, ypos, alpha, |
| 1142 | 1136 | (UINT32)zoom_table[BYTE_XOR_BE(zoomx)], (UINT32)zoom_table[BYTE_XOR_BE(zoomy)], wide, high, listcntr); |
| 1143 | 1137 | } |
| 1144 | 1138 | /* end drawing */ |
| r20973 | r20974 | |
| 1151 | 1145 | } |
| 1152 | 1146 | |
| 1153 | 1147 | |
| 1154 | | static void psikyosh_prelineblend( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
| 1148 | void psikyosh_state::psikyosh_prelineblend( bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
| 1155 | 1149 | { |
| 1156 | 1150 | /* There are 224 values for pre-lineblending. Using one for every row currently */ |
| 1157 | 1151 | /* I suspect that it should be blended against black by the amount specified as |
| 1158 | 1152 | gnbarich sets the 0x000000ff to 0x7f in test mode whilst the others use 0x80. |
| 1159 | 1153 | tgm2 sets it to 0x00 on warning screen. Likely has no effect. */ |
| 1160 | | psikyosh_state *state = machine.driver_data<psikyosh_state>(); |
| 1161 | 1154 | UINT32 *dstline; |
| 1162 | | int bank = (state->m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (0x4000) except for daraku/soldivid */ |
| 1163 | | UINT32 *linefill = &state->m_bgram[(bank * 0x800) / 4 - 0x4000 / 4]; /* Per row */ |
| 1155 | int bank = (m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (0x4000) except for daraku/soldivid */ |
| 1156 | UINT32 *linefill = &m_bgram[(bank * 0x800) / 4 - 0x4000 / 4]; /* Per row */ |
| 1164 | 1157 | int x, y; |
| 1165 | 1158 | |
| 1166 | 1159 | assert(bitmap.bpp() == 32); |
| r20973 | r20974 | |
| 1177 | 1170 | } |
| 1178 | 1171 | |
| 1179 | 1172 | |
| 1180 | | static void psikyosh_postlineblend( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 1173 | void psikyosh_state::psikyosh_postlineblend( bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri ) |
| 1181 | 1174 | { |
| 1182 | 1175 | /* There are 224 values for post-lineblending. Using one for every row currently */ |
| 1183 | | psikyosh_state *state = machine.driver_data<psikyosh_state>(); |
| 1184 | 1176 | UINT32 *dstline; |
| 1185 | | int bank = (state->m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (i.e. 0x4000) except for daraku/soldivid */ |
| 1186 | | UINT32 *lineblend = &state->m_bgram[(bank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; /* Per row */ |
| 1177 | int bank = (m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (i.e. 0x4000) except for daraku/soldivid */ |
| 1178 | UINT32 *lineblend = &m_bgram[(bank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; /* Per row */ |
| 1187 | 1179 | int x, y; |
| 1188 | 1180 | |
| 1189 | 1181 | assert(bitmap.bpp() == 32); |
| 1190 | 1182 | |
| 1191 | | if ((state->m_vidregs[2] & 0xf) != req_pri) { |
| 1183 | if ((m_vidregs[2] & 0xf) != req_pri) { |
| 1192 | 1184 | return; |
| 1193 | 1185 | } |
| 1194 | 1186 | |
| r20973 | r20974 | |
| 1280 | 1272 | |
| 1281 | 1273 | m_z_bitmap.fill(0, cliprect); /* z-buffer */ |
| 1282 | 1274 | |
| 1283 | | psikyosh_prelineblend(machine(), bitmap, cliprect); // fills screen |
| 1275 | psikyosh_prelineblend(bitmap, cliprect); // fills screen |
| 1284 | 1276 | for (i = 0; i <= 7; i++) |
| 1285 | 1277 | { |
| 1286 | 1278 | if(!pri_debug || machine().input().code_pressed(pri_keys[i])) |
| 1287 | 1279 | { |
| 1288 | 1280 | if(sprites) { |
| 1289 | | draw_sprites(machine(), bitmap, cliprect, i); // When same priority bg's have higher pri |
| 1281 | draw_sprites(bitmap, cliprect, i); // When same priority bg's have higher pri |
| 1290 | 1282 | } |
| 1291 | 1283 | if(backgrounds) { |
| 1292 | | draw_background(machine(), bitmap, cliprect, i); |
| 1284 | draw_background(bitmap, cliprect, i); |
| 1293 | 1285 | } |
| 1294 | | psikyosh_postlineblend(machine(), bitmap, cliprect, i); // assume this has highest priority at same priority level |
| 1286 | psikyosh_postlineblend(bitmap, cliprect, i); // assume this has highest priority at same priority level |
| 1295 | 1287 | } |
| 1296 | 1288 | } |
| 1297 | 1289 | return 0; |
trunk/src/mame/video/pastelg.c
| r20973 | r20974 | |
| 10 | 10 | #include "includes/nb1413m3.h" |
| 11 | 11 | #include "includes/pastelg.h" |
| 12 | 12 | |
| 13 | | |
| 14 | | static void pastelg_vramflip(running_machine &machine); |
| 15 | | static void pastelg_gfxdraw(running_machine &machine); |
| 16 | | |
| 17 | | |
| 18 | 13 | /****************************************************************************** |
| 19 | 14 | |
| 20 | 15 | |
| r20973 | r20974 | |
| 57 | 52 | |
| 58 | 53 | |
| 59 | 54 | ******************************************************************************/ |
| 60 | | int pastelg_blitter_src_addr_r(address_space &space) |
| 55 | int pastelg_state::pastelg_blitter_src_addr_r(address_space &space) |
| 61 | 56 | { |
| 62 | | pastelg_state *state = space.machine().driver_data<pastelg_state>(); |
| 63 | | return state->m_blitter_src_addr; |
| 57 | return m_blitter_src_addr; |
| 64 | 58 | } |
| 65 | 59 | |
| 66 | 60 | WRITE8_MEMBER(pastelg_state::pastelg_blitter_w) |
| r20973 | r20974 | |
| 74 | 68 | case 4: m_blitter_sizex = data; break; |
| 75 | 69 | case 5: m_blitter_sizey = data; |
| 76 | 70 | /* writing here also starts the blit */ |
| 77 | | pastelg_gfxdraw(machine()); |
| 71 | pastelg_gfxdraw(); |
| 78 | 72 | break; |
| 79 | 73 | case 6: m_blitter_direction_x = (data & 0x01) ? 1 : 0; |
| 80 | 74 | m_blitter_direction_y = (data & 0x02) ? 1 : 0; |
| 81 | 75 | m_flipscreen = (data & 0x04) ? 0 : 1; |
| 82 | 76 | m_dispflag = (data & 0x08) ? 0 : 1; |
| 83 | | pastelg_vramflip(machine()); |
| 77 | pastelg_vramflip(); |
| 84 | 78 | break; |
| 85 | 79 | } |
| 86 | 80 | } |
| r20973 | r20974 | |
| 126 | 120 | |
| 127 | 121 | |
| 128 | 122 | ******************************************************************************/ |
| 129 | | static void pastelg_vramflip(running_machine &machine) |
| 123 | void pastelg_state::pastelg_vramflip() |
| 130 | 124 | { |
| 131 | | pastelg_state *state = machine.driver_data<pastelg_state>(); |
| 132 | 125 | int x, y; |
| 133 | 126 | UINT8 color1, color2; |
| 134 | | int width = machine.primary_screen->width(); |
| 135 | | int height = machine.primary_screen->height(); |
| 127 | int width = machine().primary_screen->width(); |
| 128 | int height = machine().primary_screen->height(); |
| 136 | 129 | |
| 137 | | if (state->m_flipscreen == state->m_flipscreen_old) return; |
| 130 | if (m_flipscreen == m_flipscreen_old) return; |
| 138 | 131 | |
| 139 | 132 | for (y = 0; y < height; y++) |
| 140 | 133 | { |
| 141 | 134 | for (x = 0; x < width; x++) |
| 142 | 135 | { |
| 143 | | color1 = state->m_videoram[(y * width) + x]; |
| 144 | | color2 = state->m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)]; |
| 145 | | state->m_videoram[(y * width) + x] = color2; |
| 146 | | state->m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)] = color1; |
| 136 | color1 = m_videoram[(y * width) + x]; |
| 137 | color2 = m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)]; |
| 138 | m_videoram[(y * width) + x] = color2; |
| 139 | m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)] = color1; |
| 147 | 140 | } |
| 148 | 141 | } |
| 149 | 142 | |
| 150 | | state->m_flipscreen_old = state->m_flipscreen; |
| 143 | m_flipscreen_old = m_flipscreen; |
| 151 | 144 | } |
| 152 | 145 | |
| 153 | 146 | TIMER_CALLBACK_MEMBER(pastelg_state::blitter_timer_callback) |
| r20973 | r20974 | |
| 155 | 148 | nb1413m3_busyflag = 1; |
| 156 | 149 | } |
| 157 | 150 | |
| 158 | | static void pastelg_gfxdraw(running_machine &machine) |
| 151 | void pastelg_state::pastelg_gfxdraw() |
| 159 | 152 | { |
| 160 | | pastelg_state *state = machine.driver_data<pastelg_state>(); |
| 161 | | UINT8 *GFX = state->memregion("gfx1")->base(); |
| 162 | | int width = machine.primary_screen->width(); |
| 153 | UINT8 *GFX = memregion("gfx1")->base(); |
| 154 | int width = machine().primary_screen->width(); |
| 163 | 155 | |
| 164 | 156 | int x, y; |
| 165 | 157 | int dx, dy; |
| r20973 | r20974 | |
| 174 | 166 | |
| 175 | 167 | nb1413m3_busyctr = 0; |
| 176 | 168 | |
| 177 | | startx = state->m_blitter_destx + state->m_blitter_sizex; |
| 178 | | starty = state->m_blitter_desty + state->m_blitter_sizey; |
| 169 | startx = m_blitter_destx + m_blitter_sizex; |
| 170 | starty = m_blitter_desty + m_blitter_sizey; |
| 179 | 171 | |
| 180 | 172 | |
| 181 | | if (state->m_blitter_direction_x) |
| 173 | if (m_blitter_direction_x) |
| 182 | 174 | { |
| 183 | | if (state->m_blitter_sizex&0x80) sizex = 0xff-state->m_blitter_sizex; |
| 184 | | else sizex=state->m_blitter_sizex; |
| 175 | if (m_blitter_sizex&0x80) sizex = 0xff-m_blitter_sizex; |
| 176 | else sizex=m_blitter_sizex; |
| 185 | 177 | incx = 1; |
| 186 | 178 | } |
| 187 | 179 | else |
| 188 | 180 | { |
| 189 | | sizex = state->m_blitter_sizex; |
| 181 | sizex = m_blitter_sizex; |
| 190 | 182 | incx = -1; |
| 191 | 183 | } |
| 192 | 184 | |
| 193 | | if (state->m_blitter_direction_y) |
| 185 | if (m_blitter_direction_y) |
| 194 | 186 | { |
| 195 | | if (state->m_blitter_sizey&0x80) sizey = 0xff-state->m_blitter_sizey; |
| 196 | | else sizey=state->m_blitter_sizey; |
| 187 | if (m_blitter_sizey&0x80) sizey = 0xff-m_blitter_sizey; |
| 188 | else sizey=m_blitter_sizey; |
| 197 | 189 | incy = 1; |
| 198 | 190 | } |
| 199 | 191 | else |
| 200 | 192 | { |
| 201 | | sizey = state->m_blitter_sizey; |
| 193 | sizey = m_blitter_sizey; |
| 202 | 194 | incy = -1; |
| 203 | 195 | } |
| 204 | 196 | |
| 205 | | gfxlen = machine.root_device().memregion("gfx1")->bytes(); |
| 206 | | gfxaddr = (state->m_gfxrom << 16) + state->m_blitter_src_addr; |
| 197 | gfxlen = machine().root_device().memregion("gfx1")->bytes(); |
| 198 | gfxaddr = (m_gfxrom << 16) + m_blitter_src_addr; |
| 207 | 199 | |
| 208 | 200 | readflag = 0; |
| 209 | 201 | |
| r20973 | r20974 | |
| 216 | 208 | |
| 217 | 209 | for (ctrx = sizex; ctrx >= 0; ctrx--) |
| 218 | 210 | { |
| 219 | | gfxaddr = (state->m_gfxrom << 16) + ((state->m_blitter_src_addr + count)); |
| 211 | gfxaddr = (m_gfxrom << 16) + ((m_blitter_src_addr + count)); |
| 220 | 212 | |
| 221 | 213 | if ((gfxaddr > (gfxlen - 1))) |
| 222 | 214 | { |
| r20973 | r20974 | |
| 231 | 223 | dx = x & 0xff; |
| 232 | 224 | dy = y & 0xff; |
| 233 | 225 | |
| 234 | | if (state->m_flipscreen) |
| 226 | if (m_flipscreen) |
| 235 | 227 | { |
| 236 | 228 | dx ^= 0xff; |
| 237 | 229 | dy ^= 0xff; |
| r20973 | r20974 | |
| 251 | 243 | |
| 252 | 244 | readflag ^= 1; |
| 253 | 245 | |
| 254 | | if (state->m_clut[color] & 0xf0) |
| 246 | if (m_clut[color] & 0xf0) |
| 255 | 247 | { |
| 256 | 248 | if (color) |
| 257 | 249 | { |
| 258 | | color = ((state->m_palbank * 0x10) + color); |
| 259 | | state->m_videoram[(dy * width) + dx] = color; |
| 250 | color = ((m_palbank * 0x10) + color); |
| 251 | m_videoram[(dy * width) + dx] = color; |
| 260 | 252 | } |
| 261 | 253 | } |
| 262 | 254 | else |
| 263 | 255 | { |
| 264 | | if(state->m_clut[color] != 0) |
| 256 | if(m_clut[color] != 0) |
| 265 | 257 | { |
| 266 | | color = ((state->m_palbank * 0x10) + state->m_clut[color]); |
| 267 | | state->m_videoram[(dy * width) + dx] = color; |
| 258 | color = ((m_palbank * 0x10) + m_clut[color]); |
| 259 | m_videoram[(dy * width) + dx] = color; |
| 268 | 260 | } |
| 269 | 261 | } |
| 270 | 262 | |
| r20973 | r20974 | |
| 276 | 268 | } |
| 277 | 269 | |
| 278 | 270 | nb1413m3_busyflag = 0; |
| 279 | | machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(pastelg_state::blitter_timer_callback),state)); |
| 271 | machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(pastelg_state::blitter_timer_callback),this)); |
| 280 | 272 | } |
| 281 | 273 | |
| 282 | 274 | /****************************************************************************** |