trunk/src/mame/drivers/nmk16.c
| r20971 | r20972 | |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /*coin setting MCU simulation*/ |
| 730 | | static void mcu_run(running_machine &machine, UINT8 dsw_setting) |
| 730 | void nmk16_state::mcu_run(UINT8 dsw_setting) |
| 731 | 731 | { |
| 732 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 733 | 732 | UINT16 coin_input; |
| 734 | 733 | UINT8 dsw[2]; |
| 735 | 734 | UINT8 i; |
| 736 | 735 | |
| 737 | 736 | /*Accept the start button but needs some m68k processing first,otherwise you can't start a play with 1 credit inserted*/ |
| 738 | | if(state->m_start_helper & 1 && state->m_mainram[0x9000/2] & 0x0200) /*start 1 */ |
| 737 | if(m_start_helper & 1 && m_mainram[0x9000/2] & 0x0200) /*start 1 */ |
| 739 | 738 | { |
| 740 | | state->m_mainram[0xef00/2]--; |
| 741 | | state->m_start_helper = state->m_start_helper & 2; |
| 739 | m_mainram[0xef00/2]--; |
| 740 | m_start_helper = m_start_helper & 2; |
| 742 | 741 | } |
| 743 | | if(state->m_start_helper & 2 && state->m_mainram[0x9000/2] & 0x0100) /*start 2*/ |
| 742 | if(m_start_helper & 2 && m_mainram[0x9000/2] & 0x0100) /*start 2*/ |
| 744 | 743 | { |
| 745 | | state->m_mainram[0xef00/2]--; |
| 746 | | state->m_start_helper = state->m_start_helper & 1; |
| 744 | m_mainram[0xef00/2]--; |
| 745 | m_start_helper = m_start_helper & 1; |
| 747 | 746 | } |
| 748 | 747 | |
| 749 | 748 | /*needed because of the uncompatibility of the dsw settings.*/ |
| 750 | 749 | if(dsw_setting) // Thunder Dragon |
| 751 | 750 | { |
| 752 | | dsw[0] = (machine.root_device().ioport("DSW2")->read() & 0x7); |
| 753 | | dsw[1] = (machine.root_device().ioport("DSW2")->read() & 0x38) >> 3; |
| 751 | dsw[0] = (machine().root_device().ioport("DSW2")->read() & 0x7); |
| 752 | dsw[1] = (machine().root_device().ioport("DSW2")->read() & 0x38) >> 3; |
| 754 | 753 | for(i=0;i<2;i++) |
| 755 | 754 | { |
| 756 | 755 | switch(dsw[i] & 7) |
| 757 | 756 | { |
| 758 | | case 0: state->m_mainram[0x9000/2]|=0x4000; break; //free play |
| 759 | | case 1: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 4; break; |
| 760 | | case 2: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 3; break; |
| 761 | | case 3: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 2; break; |
| 762 | | case 4: state->m_coin_count_frac[i] = 4; state->m_coin_count[i] = 1; break; |
| 763 | | case 5: state->m_coin_count_frac[i] = 3; state->m_coin_count[i] = 1; break; |
| 764 | | case 6: state->m_coin_count_frac[i] = 2; state->m_coin_count[i] = 1; break; |
| 765 | | case 7: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 1; break; |
| 757 | case 0: m_mainram[0x9000/2]|=0x4000; break; //free play |
| 758 | case 1: m_coin_count_frac[i] = 1; m_coin_count[i] = 4; break; |
| 759 | case 2: m_coin_count_frac[i] = 1; m_coin_count[i] = 3; break; |
| 760 | case 3: m_coin_count_frac[i] = 1; m_coin_count[i] = 2; break; |
| 761 | case 4: m_coin_count_frac[i] = 4; m_coin_count[i] = 1; break; |
| 762 | case 5: m_coin_count_frac[i] = 3; m_coin_count[i] = 1; break; |
| 763 | case 6: m_coin_count_frac[i] = 2; m_coin_count[i] = 1; break; |
| 764 | case 7: m_coin_count_frac[i] = 1; m_coin_count[i] = 1; break; |
| 766 | 765 | } |
| 767 | 766 | } |
| 768 | 767 | } |
| 769 | 768 | else // Hacha Mecha Fighter |
| 770 | 769 | { |
| 771 | | dsw[0] = (machine.root_device().ioport("DSW1")->read() & 0x0700) >> 8; |
| 772 | | dsw[1] = (machine.root_device().ioport("DSW1")->read() & 0x3800) >> 11; |
| 770 | dsw[0] = (machine().root_device().ioport("DSW1")->read() & 0x0700) >> 8; |
| 771 | dsw[1] = (machine().root_device().ioport("DSW1")->read() & 0x3800) >> 11; |
| 773 | 772 | for(i=0;i<2;i++) |
| 774 | 773 | { |
| 775 | 774 | switch(dsw[i] & 7) |
| 776 | 775 | { |
| 777 | | case 0: state->m_mainram[0x9000/2]|=0x4000; break; //free play |
| 778 | | case 1: state->m_coin_count_frac[i] = 4; state->m_coin_count[i] = 1; break; |
| 779 | | case 2: state->m_coin_count_frac[i] = 3; state->m_coin_count[i] = 1; break; |
| 780 | | case 3: state->m_coin_count_frac[i] = 2; state->m_coin_count[i] = 1; break; |
| 781 | | case 4: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 4; break; |
| 782 | | case 5: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 3; break; |
| 783 | | case 6: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 2; break; |
| 784 | | case 7: state->m_coin_count_frac[i] = 1; state->m_coin_count[i] = 1; break; |
| 776 | case 0: m_mainram[0x9000/2]|=0x4000; break; //free play |
| 777 | case 1: m_coin_count_frac[i] = 4; m_coin_count[i] = 1; break; |
| 778 | case 2: m_coin_count_frac[i] = 3; m_coin_count[i] = 1; break; |
| 779 | case 3: m_coin_count_frac[i] = 2; m_coin_count[i] = 1; break; |
| 780 | case 4: m_coin_count_frac[i] = 1; m_coin_count[i] = 4; break; |
| 781 | case 5: m_coin_count_frac[i] = 1; m_coin_count[i] = 3; break; |
| 782 | case 6: m_coin_count_frac[i] = 1; m_coin_count[i] = 2; break; |
| 783 | case 7: m_coin_count_frac[i] = 1; m_coin_count[i] = 1; break; |
| 785 | 784 | } |
| 786 | 785 | } |
| 787 | 786 | } |
| 788 | 787 | |
| 789 | 788 | /*read the coin port*/ |
| 790 | | coin_input = (~(machine.root_device().ioport("IN0")->read())); |
| 789 | coin_input = (~(machine().root_device().ioport("IN0")->read())); |
| 791 | 790 | |
| 792 | 791 | if(coin_input & 0x01)//coin 1 |
| 793 | 792 | { |
| 794 | | if((state->m_input_pressed & 0x01) == 0) |
| 793 | if((m_input_pressed & 0x01) == 0) |
| 795 | 794 | { |
| 796 | | if(state->m_coin_count_frac[0] != 1) |
| 795 | if(m_coin_count_frac[0] != 1) |
| 797 | 796 | { |
| 798 | | state->m_mainram[0xef02/2]+=state->m_coin_count[0]; |
| 799 | | if(state->m_coin_count_frac[0] == state->m_mainram[0xef02/2]) |
| 797 | m_mainram[0xef02/2]+=m_coin_count[0]; |
| 798 | if(m_coin_count_frac[0] == m_mainram[0xef02/2]) |
| 800 | 799 | { |
| 801 | | state->m_mainram[0xef00/2]+=state->m_coin_count[0]; |
| 802 | | state->m_mainram[0xef02/2] = 0; |
| 800 | m_mainram[0xef00/2]+=m_coin_count[0]; |
| 801 | m_mainram[0xef02/2] = 0; |
| 803 | 802 | } |
| 804 | 803 | } |
| 805 | 804 | else |
| 806 | | state->m_mainram[0xef00/2]+=state->m_coin_count[0]; |
| 805 | m_mainram[0xef00/2]+=m_coin_count[0]; |
| 807 | 806 | } |
| 808 | | state->m_input_pressed = (state->m_input_pressed & 0xfe) | 1; |
| 807 | m_input_pressed = (m_input_pressed & 0xfe) | 1; |
| 809 | 808 | } |
| 810 | 809 | else |
| 811 | | state->m_input_pressed = (state->m_input_pressed & 0xfe); |
| 810 | m_input_pressed = (m_input_pressed & 0xfe); |
| 812 | 811 | |
| 813 | 812 | if(coin_input & 0x02)//coin 2 |
| 814 | 813 | { |
| 815 | | if((state->m_input_pressed & 0x02) == 0) |
| 814 | if((m_input_pressed & 0x02) == 0) |
| 816 | 815 | { |
| 817 | | if(state->m_coin_count_frac[1] != 1) |
| 816 | if(m_coin_count_frac[1] != 1) |
| 818 | 817 | { |
| 819 | | state->m_mainram[0xef02/2]+=state->m_coin_count[1]; |
| 820 | | if(state->m_coin_count_frac[1] == state->m_mainram[0xef02/2]) |
| 818 | m_mainram[0xef02/2]+=m_coin_count[1]; |
| 819 | if(m_coin_count_frac[1] == m_mainram[0xef02/2]) |
| 821 | 820 | { |
| 822 | | state->m_mainram[0xef00/2]+=state->m_coin_count[1]; |
| 823 | | state->m_mainram[0xef02/2] = 0; |
| 821 | m_mainram[0xef00/2]+=m_coin_count[1]; |
| 822 | m_mainram[0xef02/2] = 0; |
| 824 | 823 | } |
| 825 | 824 | } |
| 826 | 825 | else |
| 827 | | state->m_mainram[0xef00/2]+=state->m_coin_count[1]; |
| 826 | m_mainram[0xef00/2]+=m_coin_count[1]; |
| 828 | 827 | } |
| 829 | | state->m_input_pressed = (state->m_input_pressed & 0xfd) | 2; |
| 828 | m_input_pressed = (m_input_pressed & 0xfd) | 2; |
| 830 | 829 | } |
| 831 | 830 | else |
| 832 | | state->m_input_pressed = (state->m_input_pressed & 0xfd); |
| 831 | m_input_pressed = (m_input_pressed & 0xfd); |
| 833 | 832 | |
| 834 | 833 | if(coin_input & 0x04)//service 1 |
| 835 | 834 | { |
| 836 | | if((state->m_input_pressed & 0x04) == 0) |
| 837 | | state->m_mainram[0xef00/2]++; |
| 838 | | state->m_input_pressed = (state->m_input_pressed & 0xfb) | 4; |
| 835 | if((m_input_pressed & 0x04) == 0) |
| 836 | m_mainram[0xef00/2]++; |
| 837 | m_input_pressed = (m_input_pressed & 0xfb) | 4; |
| 839 | 838 | } |
| 840 | 839 | else |
| 841 | | state->m_input_pressed = (state->m_input_pressed & 0xfb); |
| 840 | m_input_pressed = (m_input_pressed & 0xfb); |
| 842 | 841 | |
| 843 | 842 | /*The 0x9000 ram address is the status */ |
| 844 | | if(state->m_mainram[0xef00/2] > 0 && state->m_mainram[0x9000/2] & 0x8000) //enable start button |
| 843 | if(m_mainram[0xef00/2] > 0 && m_mainram[0x9000/2] & 0x8000) //enable start button |
| 845 | 844 | { |
| 846 | 845 | if(coin_input & 0x08)//start 1 |
| 847 | 846 | { |
| 848 | | if((state->m_input_pressed & 0x08) == 0 && (!(state->m_mainram[0x9000/2] & 0x0200))) //start 1 |
| 849 | | state->m_start_helper = 1; |
| 847 | if((m_input_pressed & 0x08) == 0 && (!(m_mainram[0x9000/2] & 0x0200))) //start 1 |
| 848 | m_start_helper = 1; |
| 850 | 849 | |
| 851 | | state->m_input_pressed = (state->m_input_pressed & 0xf7) | 8; |
| 850 | m_input_pressed = (m_input_pressed & 0xf7) | 8; |
| 852 | 851 | } |
| 853 | 852 | else |
| 854 | | state->m_input_pressed = (state->m_input_pressed & 0xf7); |
| 853 | m_input_pressed = (m_input_pressed & 0xf7); |
| 855 | 854 | |
| 856 | 855 | if(coin_input & 0x10)//start 2 |
| 857 | 856 | { |
| 858 | 857 | /*Decrease two coins to let two players play with one start 2 button and two credits inserted at the insert coin screen.*/ |
| 859 | | if((state->m_input_pressed & 0x10) == 0 && (!(state->m_mainram[0x9000/2] & 0x0100))) // start 2 |
| 860 | | state->m_start_helper = (state->m_mainram[0x9000/2] == 0x8000) ? (3) : (2); |
| 858 | if((m_input_pressed & 0x10) == 0 && (!(m_mainram[0x9000/2] & 0x0100))) // start 2 |
| 859 | m_start_helper = (m_mainram[0x9000/2] == 0x8000) ? (3) : (2); |
| 861 | 860 | |
| 862 | | state->m_input_pressed = (state->m_input_pressed & 0xef) | 0x10; |
| 861 | m_input_pressed = (m_input_pressed & 0xef) | 0x10; |
| 863 | 862 | } |
| 864 | 863 | else |
| 865 | | state->m_input_pressed = (state->m_input_pressed & 0xef); |
| 864 | m_input_pressed = (m_input_pressed & 0xef); |
| 866 | 865 | } |
| 867 | 866 | } |
| 868 | 867 | |
| 869 | 868 | TIMER_DEVICE_CALLBACK_MEMBER(nmk16_state::tdragon_mcu_sim) |
| 870 | 869 | { |
| 871 | | mcu_run(machine(),1); |
| 870 | mcu_run(1); |
| 872 | 871 | } |
| 873 | 872 | |
| 874 | 873 | TIMER_DEVICE_CALLBACK_MEMBER(nmk16_state::hachamf_mcu_sim) |
| 875 | 874 | { |
| 876 | | mcu_run(machine(),0); |
| 875 | mcu_run(0); |
| 877 | 876 | } |
| 878 | 877 | |
| 879 | 878 | static ADDRESS_MAP_START( tdragon_map, AS_PROGRAM, 16, nmk16_state ) |
| r20971 | r20972 | |
| 4343 | 4342 | MACHINE_CONFIG_END |
| 4344 | 4343 | |
| 4345 | 4344 | |
| 4346 | | static UINT8 decode_byte(UINT8 src, const UINT8 *bitp) |
| 4345 | UINT8 nmk16_state::decode_byte(UINT8 src, const UINT8 *bitp) |
| 4347 | 4346 | { |
| 4348 | 4347 | UINT8 ret, i; |
| 4349 | 4348 | |
| r20971 | r20972 | |
| 4354 | 4353 | return ret; |
| 4355 | 4354 | } |
| 4356 | 4355 | |
| 4357 | | static UINT32 bjtwin_address_map_bg0(UINT32 addr) |
| 4356 | UINT32 nmk16_state::bjtwin_address_map_bg0(UINT32 addr) |
| 4358 | 4357 | { |
| 4359 | 4358 | return ((addr&0x00004)>> 2) | ((addr&0x00800)>> 10) | ((addr&0x40000)>>16); |
| 4360 | 4359 | } |
| 4361 | 4360 | |
| 4362 | 4361 | |
| 4363 | | static UINT16 decode_word(UINT16 src, const UINT8 *bitp) |
| 4362 | UINT16 nmk16_state::decode_word(UINT16 src, const UINT8 *bitp) |
| 4364 | 4363 | { |
| 4365 | 4364 | UINT16 ret, i; |
| 4366 | 4365 | |
| r20971 | r20972 | |
| 4372 | 4371 | } |
| 4373 | 4372 | |
| 4374 | 4373 | |
| 4375 | | static UINT32 bjtwin_address_map_sprites(UINT32 addr) |
| 4374 | UINT32 nmk16_state::bjtwin_address_map_sprites(UINT32 addr) |
| 4376 | 4375 | { |
| 4377 | 4376 | return ((addr&0x00010)>> 4) | ((addr&0x20000)>>16) | ((addr&0x100000)>>18); |
| 4378 | 4377 | } |
| 4379 | 4378 | |
| 4380 | 4379 | |
| 4381 | | static void decode_gfx(running_machine &machine) |
| 4380 | void nmk16_state::decode_gfx() |
| 4382 | 4381 | { |
| 4383 | 4382 | /* GFX are scrambled. We decode them here. (BIG Thanks to Antiriad for descrambling info) */ |
| 4384 | 4383 | UINT8 *rom; |
| r20971 | r20972 | |
| 4411 | 4410 | |
| 4412 | 4411 | |
| 4413 | 4412 | /* background */ |
| 4414 | | rom = machine.root_device().memregion("gfx2")->base(); |
| 4415 | | len = machine.root_device().memregion("gfx2")->bytes(); |
| 4413 | rom = machine().root_device().memregion("gfx2")->base(); |
| 4414 | len = machine().root_device().memregion("gfx2")->bytes(); |
| 4416 | 4415 | for (A = 0;A < len;A++) |
| 4417 | 4416 | { |
| 4418 | 4417 | rom[A] = decode_byte( rom[A], decode_data_bg[bjtwin_address_map_bg0(A)]); |
| 4419 | 4418 | } |
| 4420 | 4419 | |
| 4421 | 4420 | /* sprites */ |
| 4422 | | rom = machine.root_device().memregion("gfx3")->base(); |
| 4423 | | len = machine.root_device().memregion("gfx3")->bytes(); |
| 4421 | rom = machine().root_device().memregion("gfx3")->base(); |
| 4422 | len = machine().root_device().memregion("gfx3")->bytes(); |
| 4424 | 4423 | for (A = 0;A < len;A += 2) |
| 4425 | 4424 | { |
| 4426 | 4425 | UINT16 tmp = decode_word( rom[A+1]*256 + rom[A], decode_data_sprite[bjtwin_address_map_sprites(A)]); |
| r20971 | r20972 | |
| 4429 | 4428 | } |
| 4430 | 4429 | } |
| 4431 | 4430 | |
| 4432 | | static void decode_tdragonb(running_machine &machine) |
| 4431 | void nmk16_state::decode_tdragonb() |
| 4433 | 4432 | { |
| 4434 | 4433 | /* Descrambling Info Again Taken from Raine, Huge Thanks to Antiriad and the Raine Team for |
| 4435 | 4434 | going Open Source, best of luck in future development. */ |
| r20971 | r20972 | |
| 4449 | 4448 | {0x7,0x6,0x5,0x3,0x4,0x2,0x1,0x0}, |
| 4450 | 4449 | }; |
| 4451 | 4450 | |
| 4452 | | rom = machine.root_device().memregion("maincpu")->base(); |
| 4453 | | len = machine.root_device().memregion("maincpu")->bytes(); |
| 4451 | rom = machine().root_device().memregion("maincpu")->base(); |
| 4452 | len = machine().root_device().memregion("maincpu")->bytes(); |
| 4454 | 4453 | for (A = 0;A < len;A += 2) |
| 4455 | 4454 | { |
| 4456 | 4455 | int h = A+NATIVE_ENDIAN_VALUE_LE_BE(1,0), l = A+NATIVE_ENDIAN_VALUE_LE_BE(0,1); |
| r20971 | r20972 | |
| 4459 | 4458 | rom[l] = tmp & 0xff; |
| 4460 | 4459 | } |
| 4461 | 4460 | |
| 4462 | | rom = machine.root_device().memregion("gfx2")->base(); |
| 4463 | | len = machine.root_device().memregion("gfx2")->bytes(); |
| 4461 | rom = machine().root_device().memregion("gfx2")->base(); |
| 4462 | len = machine().root_device().memregion("gfx2")->bytes(); |
| 4464 | 4463 | for (A = 0;A < len;A++) |
| 4465 | 4464 | { |
| 4466 | 4465 | rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); |
| 4467 | 4466 | } |
| 4468 | 4467 | |
| 4469 | | rom = machine.root_device().memregion("gfx3")->base(); |
| 4470 | | len = machine.root_device().memregion("gfx3")->bytes(); |
| 4468 | rom = machine().root_device().memregion("gfx3")->base(); |
| 4469 | len = machine().root_device().memregion("gfx3")->bytes(); |
| 4471 | 4470 | for (A = 0;A < len;A++) |
| 4472 | 4471 | { |
| 4473 | 4472 | rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); |
| 4474 | 4473 | } |
| 4475 | 4474 | } |
| 4476 | 4475 | |
| 4477 | | static void decode_ssmissin(running_machine &machine) |
| 4476 | void nmk16_state::decode_ssmissin() |
| 4478 | 4477 | { |
| 4479 | 4478 | /* Like Thunder Dragon Bootleg without the Program Rom Swapping */ |
| 4480 | 4479 | UINT8 *rom; |
| r20971 | r20972 | |
| 4486 | 4485 | {0x7,0x6,0x5,0x3,0x4,0x2,0x1,0x0}, |
| 4487 | 4486 | }; |
| 4488 | 4487 | |
| 4489 | | rom = machine.root_device().memregion("gfx2")->base(); |
| 4490 | | len = machine.root_device().memregion("gfx2")->bytes(); |
| 4488 | rom = machine().root_device().memregion("gfx2")->base(); |
| 4489 | len = machine().root_device().memregion("gfx2")->bytes(); |
| 4491 | 4490 | for (A = 0;A < len;A++) |
| 4492 | 4491 | { |
| 4493 | 4492 | rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); |
| 4494 | 4493 | } |
| 4495 | 4494 | |
| 4496 | | rom = machine.root_device().memregion("gfx3")->base(); |
| 4497 | | len = machine.root_device().memregion("gfx3")->bytes(); |
| 4495 | rom = machine().root_device().memregion("gfx3")->base(); |
| 4496 | len = machine().root_device().memregion("gfx3")->bytes(); |
| 4498 | 4497 | for (A = 0;A < len;A++) |
| 4499 | 4498 | { |
| 4500 | 4499 | rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); |
| r20971 | r20972 | |
| 4504 | 4503 | |
| 4505 | 4504 | DRIVER_INIT_MEMBER(nmk16_state,nmk) |
| 4506 | 4505 | { |
| 4507 | | decode_gfx(machine()); |
| 4506 | decode_gfx(); |
| 4508 | 4507 | } |
| 4509 | 4508 | |
| 4510 | 4509 | DRIVER_INIT_MEMBER(nmk16_state,hachamf) |
| r20971 | r20972 | |
| 4520 | 4519 | |
| 4521 | 4520 | DRIVER_INIT_MEMBER(nmk16_state,tdragonb) |
| 4522 | 4521 | { |
| 4523 | | decode_tdragonb(machine()); |
| 4522 | decode_tdragonb(); |
| 4524 | 4523 | } |
| 4525 | 4524 | |
| 4526 | 4525 | DRIVER_INIT_MEMBER(nmk16_state,tdragon) |
| r20971 | r20972 | |
| 4537 | 4536 | |
| 4538 | 4537 | DRIVER_INIT_MEMBER(nmk16_state,ssmissin) |
| 4539 | 4538 | { |
| 4540 | | decode_ssmissin(machine()); |
| 4539 | decode_ssmissin(); |
| 4541 | 4540 | } |
| 4542 | 4541 | |
| 4543 | 4542 | DRIVER_INIT_MEMBER(nmk16_state,bjtwin) |
trunk/src/mame/video/nbmj8891.c
| r20971 | r20972 | |
| 11 | 11 | #include "includes/nbmj8891.h" |
| 12 | 12 | |
| 13 | 13 | |
| 14 | | static void nbmj8891_vramflip(running_machine &machine, int vram); |
| 15 | | static void nbmj8891_gfxdraw(running_machine &machine); |
| 16 | | |
| 17 | | |
| 18 | 14 | /****************************************************************************** |
| 19 | 15 | |
| 20 | 16 | |
| r20971 | r20972 | |
| 115 | 111 | case 0x04: m_blitter_sizex = data; break; |
| 116 | 112 | case 0x05: m_blitter_sizey = data; |
| 117 | 113 | /* writing here also starts the blit */ |
| 118 | | nbmj8891_gfxdraw(machine()); |
| 114 | nbmj8891_gfxdraw(); |
| 119 | 115 | break; |
| 120 | 116 | case 0x06: m_blitter_direction_x = (data & 0x01) ? 1 : 0; |
| 121 | 117 | m_blitter_direction_y = (data & 0x02) ? 1 : 0; |
| 122 | 118 | m_flipscreen = (data & 0x04) ? 1 : 0; |
| 123 | 119 | m_dispflag = (data & 0x08) ? 0 : 1; |
| 124 | | if (m_gfxdraw_mode) nbmj8891_vramflip(machine(), 1); |
| 125 | | nbmj8891_vramflip(machine(), 0); |
| 120 | if (m_gfxdraw_mode) nbmj8891_vramflip(1); |
| 121 | nbmj8891_vramflip(0); |
| 126 | 122 | break; |
| 127 | 123 | case 0x07: break; |
| 128 | 124 | } |
| r20971 | r20972 | |
| 143 | 139 | |
| 144 | 140 | WRITE8_MEMBER(nbmj8891_state::nbmj8891_taiwanmb_gfxdraw_w) |
| 145 | 141 | { |
| 146 | | // nbmj8891_gfxdraw(machine()); |
| 142 | // nbmj8891_gfxdraw(); |
| 147 | 143 | } |
| 148 | 144 | |
| 149 | 145 | WRITE8_MEMBER(nbmj8891_state::nbmj8891_taiwanmb_gfxflag_w) |
| 150 | 146 | { |
| 151 | 147 | m_flipscreen = (data & 0x04) ? 1 : 0; |
| 152 | 148 | |
| 153 | | nbmj8891_vramflip(machine(), 0); |
| 149 | nbmj8891_vramflip(0); |
| 154 | 150 | } |
| 155 | 151 | |
| 156 | 152 | WRITE8_MEMBER(nbmj8891_state::nbmj8891_taiwanmb_mcu_w) |
| r20971 | r20972 | |
| 226 | 222 | m_blitter_sizey ^= 0x00; |
| 227 | 223 | } |
| 228 | 224 | |
| 229 | | nbmj8891_gfxdraw(machine()); |
| 225 | nbmj8891_gfxdraw(); |
| 230 | 226 | } |
| 231 | 227 | |
| 232 | 228 | // m_blitter_direction_x = 0; // for debug |
| r20971 | r20972 | |
| 267 | 263 | |
| 268 | 264 | |
| 269 | 265 | ******************************************************************************/ |
| 270 | | void nbmj8891_vramflip(running_machine &machine, int vram) |
| 266 | void nbmj8891_state::nbmj8891_vramflip(int vram) |
| 271 | 267 | { |
| 272 | | nbmj8891_state *state = machine.driver_data<nbmj8891_state>(); |
| 273 | 268 | int x, y; |
| 274 | 269 | UINT8 color1, color2; |
| 275 | 270 | UINT8 *vidram; |
| 276 | 271 | |
| 277 | | int width = machine.primary_screen->width(); |
| 278 | | int height = machine.primary_screen->height(); |
| 272 | int width = machine().primary_screen->width(); |
| 273 | int height = machine().primary_screen->height(); |
| 279 | 274 | |
| 280 | | if (state->m_flipscreen == state->m_flipscreen_old) return; |
| 275 | if (m_flipscreen == m_flipscreen_old) return; |
| 281 | 276 | |
| 282 | | vidram = vram ? state->m_videoram1 : state->m_videoram0; |
| 277 | vidram = vram ? m_videoram1 : m_videoram0; |
| 283 | 278 | |
| 284 | 279 | for (y = 0; y < (height / 2); y++) |
| 285 | 280 | { |
| r20971 | r20972 | |
| 292 | 287 | } |
| 293 | 288 | } |
| 294 | 289 | |
| 295 | | state->m_flipscreen_old = state->m_flipscreen; |
| 296 | | state->m_screen_refresh = 1; |
| 290 | m_flipscreen_old = m_flipscreen; |
| 291 | m_screen_refresh = 1; |
| 297 | 292 | } |
| 298 | 293 | |
| 299 | 294 | |
| 300 | | static void update_pixel0(running_machine &machine, int x, int y) |
| 295 | void nbmj8891_state::update_pixel0(int x, int y) |
| 301 | 296 | { |
| 302 | | nbmj8891_state *state = machine.driver_data<nbmj8891_state>(); |
| 303 | | UINT8 color = state->m_videoram0[(y * machine.primary_screen->width()) + x]; |
| 304 | | state->m_tmpbitmap0.pix16(y, x) = color; |
| 297 | UINT8 color = m_videoram0[(y * machine().primary_screen->width()) + x]; |
| 298 | m_tmpbitmap0.pix16(y, x) = color; |
| 305 | 299 | } |
| 306 | 300 | |
| 307 | | static void update_pixel1(running_machine &machine, int x, int y) |
| 301 | void nbmj8891_state::update_pixel1(int x, int y) |
| 308 | 302 | { |
| 309 | | nbmj8891_state *state = machine.driver_data<nbmj8891_state>(); |
| 310 | | UINT8 color = state->m_videoram1[(y * machine.primary_screen->width()) + x]; |
| 311 | | state->m_tmpbitmap1.pix16(y, x) = (color == 0x7f) ? 0xff : color; |
| 303 | UINT8 color = m_videoram1[(y * machine().primary_screen->width()) + x]; |
| 304 | m_tmpbitmap1.pix16(y, x) = (color == 0x7f) ? 0xff : color; |
| 312 | 305 | } |
| 313 | 306 | |
| 314 | 307 | TIMER_CALLBACK_MEMBER(nbmj8891_state::blitter_timer_callback) |
| r20971 | r20972 | |
| 316 | 309 | nb1413m3_busyflag = 1; |
| 317 | 310 | } |
| 318 | 311 | |
| 319 | | static void nbmj8891_gfxdraw(running_machine &machine) |
| 312 | void nbmj8891_state::nbmj8891_gfxdraw() |
| 320 | 313 | { |
| 321 | | nbmj8891_state *state = machine.driver_data<nbmj8891_state>(); |
| 322 | | UINT8 *GFX = state->memregion("gfx1")->base(); |
| 323 | | int width = machine.primary_screen->width(); |
| 314 | UINT8 *GFX = memregion("gfx1")->base(); |
| 315 | int width = machine().primary_screen->width(); |
| 324 | 316 | |
| 325 | 317 | int x, y; |
| 326 | 318 | int dx1, dx2, dy1, dy2; |
| r20971 | r20972 | |
| 333 | 325 | |
| 334 | 326 | nb1413m3_busyctr = 0; |
| 335 | 327 | |
| 336 | | startx = state->m_blitter_destx + state->m_blitter_sizex; |
| 337 | | starty = state->m_blitter_desty + state->m_blitter_sizey; |
| 328 | startx = m_blitter_destx + m_blitter_sizex; |
| 329 | starty = m_blitter_desty + m_blitter_sizey; |
| 338 | 330 | |
| 339 | | if (state->m_blitter_direction_x) |
| 331 | if (m_blitter_direction_x) |
| 340 | 332 | { |
| 341 | | sizex = state->m_blitter_sizex ^ 0xff; |
| 333 | sizex = m_blitter_sizex ^ 0xff; |
| 342 | 334 | skipx = 1; |
| 343 | 335 | } |
| 344 | 336 | else |
| 345 | 337 | { |
| 346 | | sizex = state->m_blitter_sizex; |
| 338 | sizex = m_blitter_sizex; |
| 347 | 339 | skipx = -1; |
| 348 | 340 | } |
| 349 | 341 | |
| 350 | | if (state->m_blitter_direction_y) |
| 342 | if (m_blitter_direction_y) |
| 351 | 343 | { |
| 352 | | sizey = state->m_blitter_sizey ^ 0xff; |
| 344 | sizey = m_blitter_sizey ^ 0xff; |
| 353 | 345 | skipy = 1; |
| 354 | 346 | } |
| 355 | 347 | else |
| 356 | 348 | { |
| 357 | | sizey = state->m_blitter_sizey; |
| 349 | sizey = m_blitter_sizey; |
| 358 | 350 | skipy = -1; |
| 359 | 351 | } |
| 360 | 352 | |
| 361 | | gfxlen = machine.root_device().memregion("gfx1")->bytes(); |
| 362 | | gfxaddr = (state->m_gfxrom << 17) + (state->m_blitter_src_addr << 1); |
| 353 | gfxlen = machine().root_device().memregion("gfx1")->bytes(); |
| 354 | gfxaddr = (m_gfxrom << 17) + (m_blitter_src_addr << 1); |
| 363 | 355 | |
| 364 | 356 | for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) |
| 365 | 357 | { |
| r20971 | r20972 | |
| 378 | 370 | // for hanamomo font type |
| 379 | 371 | if (nb1413m3_type == NB1413M3_HANAMOMO) |
| 380 | 372 | { |
| 381 | | if ((state->ioport("FONTTYPE")->read()) == 0x00) |
| 373 | if ((ioport("FONTTYPE")->read()) == 0x00) |
| 382 | 374 | { |
| 383 | 375 | if ((gfxaddr >= 0x20000) && (gfxaddr < 0x28000)) |
| 384 | 376 | { |
| r20971 | r20972 | |
| 390 | 382 | dx1 = (2 * x + 0) & 0x1ff; |
| 391 | 383 | dx2 = (2 * x + 1) & 0x1ff; |
| 392 | 384 | |
| 393 | | if (state->m_gfxdraw_mode) |
| 385 | if (m_gfxdraw_mode) |
| 394 | 386 | { |
| 395 | 387 | // 2 layer type |
| 396 | 388 | dy1 = y & 0xff; |
| 397 | | dy2 = (y + state->m_scrolly) & 0xff; |
| 389 | dy2 = (y + m_scrolly) & 0xff; |
| 398 | 390 | } |
| 399 | 391 | else |
| 400 | 392 | { |
| 401 | 393 | // 1 layer type |
| 402 | | dy1 = (y + state->m_scrolly) & 0xff; |
| 394 | dy1 = (y + m_scrolly) & 0xff; |
| 403 | 395 | dy2 = 0; |
| 404 | 396 | } |
| 405 | 397 | |
| 406 | | if (!state->m_flipscreen) |
| 398 | if (!m_flipscreen) |
| 407 | 399 | { |
| 408 | 400 | dx1 ^= 0x1ff; |
| 409 | 401 | dx2 ^= 0x1ff; |
| r20971 | r20972 | |
| 411 | 403 | dy2 ^= 0xff; |
| 412 | 404 | } |
| 413 | 405 | |
| 414 | | if (state->m_blitter_direction_x) |
| 406 | if (m_blitter_direction_x) |
| 415 | 407 | { |
| 416 | 408 | // flip |
| 417 | 409 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 424 | 416 | color2 = (color & 0x0f) >> 0; |
| 425 | 417 | } |
| 426 | 418 | |
| 427 | | color1 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color1]; |
| 428 | | color2 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color2]; |
| 419 | color1 = m_clut[((m_clutsel & 0x7f) << 4) + color1]; |
| 420 | color2 = m_clut[((m_clutsel & 0x7f) << 4) + color2]; |
| 429 | 421 | |
| 430 | | if ((!state->m_gfxdraw_mode) || (state->m_vram & 0x01)) |
| 422 | if ((!m_gfxdraw_mode) || (m_vram & 0x01)) |
| 431 | 423 | { |
| 432 | 424 | // layer 1 |
| 433 | 425 | if (color1 != 0xff) |
| 434 | 426 | { |
| 435 | | state->m_videoram0[(dy1 * width) + dx1] = color1; |
| 436 | | update_pixel0(machine, dx1, dy1); |
| 427 | m_videoram0[(dy1 * width) + dx1] = color1; |
| 428 | update_pixel0(dx1, dy1); |
| 437 | 429 | } |
| 438 | 430 | if (color2 != 0xff) |
| 439 | 431 | { |
| 440 | | state->m_videoram0[(dy1 * width) + dx2] = color2; |
| 441 | | update_pixel0(machine, dx2, dy1); |
| 432 | m_videoram0[(dy1 * width) + dx2] = color2; |
| 433 | update_pixel0(dx2, dy1); |
| 442 | 434 | } |
| 443 | 435 | } |
| 444 | | if (state->m_gfxdraw_mode && (state->m_vram & 0x02)) |
| 436 | if (m_gfxdraw_mode && (m_vram & 0x02)) |
| 445 | 437 | { |
| 446 | 438 | // layer 2 |
| 447 | | if (state->m_vram & 0x08) |
| 439 | if (m_vram & 0x08) |
| 448 | 440 | { |
| 449 | 441 | // transparent enable |
| 450 | 442 | if (color1 != 0xff) |
| 451 | 443 | { |
| 452 | | state->m_videoram1[(dy2 * width) + dx1] = color1; |
| 453 | | update_pixel1(machine, dx1, dy2); |
| 444 | m_videoram1[(dy2 * width) + dx1] = color1; |
| 445 | update_pixel1(dx1, dy2); |
| 454 | 446 | } |
| 455 | 447 | if (color2 != 0xff) |
| 456 | 448 | { |
| 457 | | state->m_videoram1[(dy2 * width) + dx2] = color2; |
| 458 | | update_pixel1(machine, dx2, dy2); |
| 449 | m_videoram1[(dy2 * width) + dx2] = color2; |
| 450 | update_pixel1(dx2, dy2); |
| 459 | 451 | } |
| 460 | 452 | } |
| 461 | 453 | else |
| 462 | 454 | { |
| 463 | 455 | // transparent disable |
| 464 | | state->m_videoram1[(dy2 * width) + dx1] = color1; |
| 465 | | update_pixel1(machine, dx1, dy2); |
| 466 | | state->m_videoram1[(dy2 * width) + dx2] = color2; |
| 467 | | update_pixel1(machine, dx2, dy2); |
| 456 | m_videoram1[(dy2 * width) + dx1] = color1; |
| 457 | update_pixel1(dx1, dy2); |
| 458 | m_videoram1[(dy2 * width) + dx2] = color2; |
| 459 | update_pixel1(dx2, dy2); |
| 468 | 460 | } |
| 469 | 461 | } |
| 470 | 462 | |
| r20971 | r20972 | |
| 473 | 465 | } |
| 474 | 466 | |
| 475 | 467 | nb1413m3_busyflag = 0; |
| 476 | | machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8891_state::blitter_timer_callback),state)); |
| 468 | machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8891_state::blitter_timer_callback),this)); |
| 477 | 469 | } |
| 478 | 470 | |
| 479 | 471 | /****************************************************************************** |
| r20971 | r20972 | |
| 530 | 522 | m_screen_refresh = 0; |
| 531 | 523 | for (y = 0; y < height; y++) |
| 532 | 524 | for (x = 0; x < width; x++) |
| 533 | | update_pixel0(machine(), x, y); |
| 525 | update_pixel0(x, y); |
| 534 | 526 | |
| 535 | 527 | if (m_gfxdraw_mode) |
| 536 | 528 | for (y = 0; y < height; y++) |
| 537 | 529 | for (x = 0; x < width; x++) |
| 538 | | update_pixel1(machine(), x, y); |
| 530 | update_pixel1(x, y); |
| 539 | 531 | } |
| 540 | 532 | |
| 541 | 533 | if (m_dispflag) |
trunk/src/mame/video/nbmj8688.c
| r20971 | r20972 | |
| 11 | 11 | #include "includes/nbmj8688.h" |
| 12 | 12 | |
| 13 | 13 | |
| 14 | | static void mbmj8688_gfxdraw(running_machine &machine, int gfxtype); |
| 15 | | |
| 16 | | |
| 17 | 14 | /* the blitter can copy data both in "direct" mode, where every byte of the source |
| 18 | 15 | data is copied verbatim to video RAM *twice* (thus doubling the pixel width), |
| 19 | 16 | and in "lookup" mode, where the source byte is taken 4 bits at a time and indexed |
| r20971 | r20972 | |
| 123 | 120 | case 0x04: m_blitter_sizex = data; break; |
| 124 | 121 | case 0x05: m_blitter_sizey = data; |
| 125 | 122 | /* writing here also starts the blit */ |
| 126 | | mbmj8688_gfxdraw(machine(), m_mjsikaku_gfxmode); |
| 123 | mbmj8688_gfxdraw(m_mjsikaku_gfxmode); |
| 127 | 124 | break; |
| 128 | 125 | case 0x06: m_blitter_direction_x = (data & 0x01) ? 1 : 0; |
| 129 | 126 | m_blitter_direction_y = (data & 0x02) ? 1 : 0; |
| r20971 | r20972 | |
| 246 | 243 | } |
| 247 | 244 | |
| 248 | 245 | |
| 249 | | static void update_pixel(nbmj8688_state *state, int x, int y) |
| 246 | void nbmj8688_state::update_pixel(int x, int y) |
| 250 | 247 | { |
| 251 | | int color = state->m_mjsikaku_videoram[(y * 512) + x]; |
| 252 | | state->m_mjsikaku_tmpbitmap->pix16(y, x) = color; |
| 248 | int color = m_mjsikaku_videoram[(y * 512) + x]; |
| 249 | m_mjsikaku_tmpbitmap->pix16(y, x) = color; |
| 253 | 250 | } |
| 254 | 251 | |
| 255 | | static void writeram_low(nbmj8688_state *state, int x, int y, int color) |
| 252 | void nbmj8688_state::writeram_low(int x, int y, int color) |
| 256 | 253 | { |
| 257 | | state->m_mjsikaku_videoram[(y * 512) + x] &= 0xff00; |
| 258 | | state->m_mjsikaku_videoram[(y * 512) + x] |= color; |
| 259 | | update_pixel(state, x, y); |
| 254 | m_mjsikaku_videoram[(y * 512) + x] &= 0xff00; |
| 255 | m_mjsikaku_videoram[(y * 512) + x] |= color; |
| 256 | update_pixel(x, y); |
| 260 | 257 | } |
| 261 | 258 | |
| 262 | | static void writeram_high(nbmj8688_state *state, int x, int y, int color) |
| 259 | void nbmj8688_state::writeram_high(int x, int y, int color) |
| 263 | 260 | { |
| 264 | | state->m_mjsikaku_videoram[(y * 512) + x] &= 0x00ff; |
| 265 | | state->m_mjsikaku_videoram[(y * 512) + x] |= color << 8; |
| 266 | | update_pixel(state, x, y); |
| 261 | m_mjsikaku_videoram[(y * 512) + x] &= 0x00ff; |
| 262 | m_mjsikaku_videoram[(y * 512) + x] |= color << 8; |
| 263 | update_pixel(x, y); |
| 267 | 264 | } |
| 268 | 265 | |
| 269 | 266 | TIMER_CALLBACK_MEMBER(nbmj8688_state::blitter_timer_callback) |
| r20971 | r20972 | |
| 271 | 268 | nb1413m3_busyflag = 1; |
| 272 | 269 | } |
| 273 | 270 | |
| 274 | | static void mbmj8688_gfxdraw(running_machine &machine, int gfxtype) |
| 271 | void nbmj8688_state::mbmj8688_gfxdraw(int gfxtype) |
| 275 | 272 | { |
| 276 | | nbmj8688_state *state = machine.driver_data<nbmj8688_state>(); |
| 277 | | UINT8 *GFX = state->memregion("gfx1")->base(); |
| 273 | UINT8 *GFX = memregion("gfx1")->base(); |
| 278 | 274 | |
| 279 | 275 | int x, y; |
| 280 | 276 | int dx1, dx2, dy; |
| r20971 | r20972 | |
| 287 | 283 | |
| 288 | 284 | if (gfxtype == GFXTYPE_PURE_12BIT) |
| 289 | 285 | { |
| 290 | | if (state->m_mjsikaku_gfxflag2 & 0x20) return; |
| 286 | if (m_mjsikaku_gfxflag2 & 0x20) return; |
| 291 | 287 | } |
| 292 | 288 | |
| 293 | 289 | nb1413m3_busyctr = 0; |
| 294 | 290 | |
| 295 | | startx = state->m_blitter_destx + state->m_blitter_sizex; |
| 296 | | starty = state->m_blitter_desty + state->m_blitter_sizey; |
| 291 | startx = m_blitter_destx + m_blitter_sizex; |
| 292 | starty = m_blitter_desty + m_blitter_sizey; |
| 297 | 293 | |
| 298 | | if (state->m_blitter_direction_x) |
| 294 | if (m_blitter_direction_x) |
| 299 | 295 | { |
| 300 | | sizex = state->m_blitter_sizex ^ 0xff; |
| 296 | sizex = m_blitter_sizex ^ 0xff; |
| 301 | 297 | skipx = 1; |
| 302 | 298 | } |
| 303 | 299 | else |
| 304 | 300 | { |
| 305 | | sizex = state->m_blitter_sizex; |
| 301 | sizex = m_blitter_sizex; |
| 306 | 302 | skipx = -1; |
| 307 | 303 | } |
| 308 | 304 | |
| 309 | | if (state->m_blitter_direction_y) |
| 305 | if (m_blitter_direction_y) |
| 310 | 306 | { |
| 311 | | sizey = state->m_blitter_sizey ^ 0xff; |
| 307 | sizey = m_blitter_sizey ^ 0xff; |
| 312 | 308 | skipy = 1; |
| 313 | 309 | } |
| 314 | 310 | else |
| 315 | 311 | { |
| 316 | | sizey = state->m_blitter_sizey; |
| 312 | sizey = m_blitter_sizey; |
| 317 | 313 | skipy = -1; |
| 318 | 314 | } |
| 319 | 315 | |
| 320 | | gfxlen = machine.root_device().memregion("gfx1")->bytes(); |
| 321 | | gfxaddr = (state->m_mjsikaku_gfxrom << 17) + (state->m_blitter_src_addr << 1); |
| 316 | gfxlen = machine().root_device().memregion("gfx1")->bytes(); |
| 317 | gfxaddr = (m_mjsikaku_gfxrom << 17) + (m_blitter_src_addr << 1); |
| 322 | 318 | |
| 323 | 319 | //popmessage("ADDR:%08X DX:%03d DY:%03d SX:%03d SY:%03d", gfxaddr, startx, starty, sizex, sizey); |
| 324 | 320 | //logerror("ADDR:%08X DX:%03d DY:%03d SX:%03d SY:%03d\n", gfxaddr, startx, starty, sizex, sizey); |
| 325 | | //if (state->m_blitter_direction_x|state->m_blitter_direction_y) popmessage("ADDR:%08X FX:%01d FY:%01d", gfxaddr, state->m_blitter_direction_x, state->m_blitter_direction_y); |
| 321 | //if (m_blitter_direction_x|m_blitter_direction_y) popmessage("ADDR:%08X FX:%01d FY:%01d", gfxaddr, m_blitter_direction_x, m_blitter_direction_y); |
| 326 | 322 | |
| 327 | 323 | for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) |
| 328 | 324 | { |
| r20971 | r20972 | |
| 340 | 336 | |
| 341 | 337 | dx1 = (2 * x + 0) & 0x1ff; |
| 342 | 338 | dx2 = (2 * x + 1) & 0x1ff; |
| 343 | | dy = (y + state->m_mjsikaku_scrolly) & 0xff; |
| 339 | dy = (y + m_mjsikaku_scrolly) & 0xff; |
| 344 | 340 | |
| 345 | | if (state->m_mjsikaku_flipscreen) |
| 341 | if (m_mjsikaku_flipscreen) |
| 346 | 342 | { |
| 347 | 343 | dx1 ^= 0x1ff; |
| 348 | 344 | dx2 ^= 0x1ff; |
| r20971 | r20972 | |
| 351 | 347 | |
| 352 | 348 | if (gfxtype == GFXTYPE_HYBRID_16BIT) |
| 353 | 349 | { |
| 354 | | if (state->m_mjsikaku_gfxflag3 & 0x40) |
| 350 | if (m_mjsikaku_gfxflag3 & 0x40) |
| 355 | 351 | { |
| 356 | 352 | // direct mode |
| 357 | 353 | |
| 358 | | if (state->m_mjsikaku_gfxflag3 & 0x80) |
| 354 | if (m_mjsikaku_gfxflag3 & 0x80) |
| 359 | 355 | { |
| 360 | 356 | /* least significant bits */ |
| 361 | 357 | if (color != 0xff) |
| 362 | 358 | { |
| 363 | | writeram_low(state, dx1, dy, color); |
| 364 | | writeram_low(state, dx2, dy, color); |
| 359 | writeram_low(dx1, dy, color); |
| 360 | writeram_low(dx2, dy, color); |
| 365 | 361 | } |
| 366 | 362 | } |
| 367 | 363 | else |
| r20971 | r20972 | |
| 369 | 365 | /* most significant bits */ |
| 370 | 366 | if (color != 0xff) |
| 371 | 367 | { |
| 372 | | writeram_high(state, dx1, dy, color); |
| 373 | | writeram_high(state, dx2, dy, color); |
| 368 | writeram_high(dx1, dy, color); |
| 369 | writeram_high(dx2, dy, color); |
| 374 | 370 | } |
| 375 | 371 | } |
| 376 | 372 | } |
| r20971 | r20972 | |
| 380 | 376 | // lookup table mode |
| 381 | 377 | |
| 382 | 378 | // unknown flag (seiha, seiham) |
| 383 | | // if (state->m_mjsikaku_gfxflag3 & 0x80) return; |
| 379 | // if (m_mjsikaku_gfxflag3 & 0x80) return; |
| 384 | 380 | |
| 385 | 381 | // unknown (seiha, seiham, iemoto, ojousan) |
| 386 | | if (!(state->m_mjsikaku_gfxflag2 & 0x20)) return; |
| 382 | if (!(m_mjsikaku_gfxflag2 & 0x20)) return; |
| 387 | 383 | |
| 388 | | if (state->m_blitter_direction_x) |
| 384 | if (m_blitter_direction_x) |
| 389 | 385 | { |
| 390 | 386 | // flip |
| 391 | 387 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 398 | 394 | color2 = (color & 0x0f) >> 0; |
| 399 | 395 | } |
| 400 | 396 | |
| 401 | | color1 = (state->m_clut[color1] << 8) | ((state->m_clut[color1 | 0x10] & 0x0f) << 4); |
| 402 | | color2 = (state->m_clut[color2] << 8) | ((state->m_clut[color2 | 0x10] & 0x0f) << 4); |
| 397 | color1 = (m_clut[color1] << 8) | ((m_clut[color1 | 0x10] & 0x0f) << 4); |
| 398 | color2 = (m_clut[color2] << 8) | ((m_clut[color2 | 0x10] & 0x0f) << 4); |
| 403 | 399 | |
| 404 | 400 | if (color1 != 0xfff0) |
| 405 | 401 | { |
| 406 | 402 | /* extend color from 12-bit to 16-bit */ |
| 407 | 403 | color1 = (color1 & 0xffc0) | ((color1 & 0x20) >> 1) | ((color1 & 0x10) >> 2); |
| 408 | | state->m_mjsikaku_videoram[(dy * 512) + dx1] = color1; |
| 409 | | update_pixel(state, dx1, dy); |
| 404 | m_mjsikaku_videoram[(dy * 512) + dx1] = color1; |
| 405 | update_pixel(dx1, dy); |
| 410 | 406 | } |
| 411 | 407 | |
| 412 | 408 | if (color2 != 0xfff0) |
| 413 | 409 | { |
| 414 | 410 | /* extend color from 12-bit to 16-bit */ |
| 415 | 411 | color2 = (color2 & 0xffc0) | ((color2 & 0x20) >> 1) | ((color2 & 0x10) >> 2); |
| 416 | | state->m_mjsikaku_videoram[(dy * 512) + dx2] = color2; |
| 417 | | update_pixel(state, dx2, dy); |
| 412 | m_mjsikaku_videoram[(dy * 512) + dx2] = color2; |
| 413 | update_pixel(dx2, dy); |
| 418 | 414 | } |
| 419 | 415 | } |
| 420 | 416 | } |
| r20971 | r20972 | |
| 422 | 418 | { |
| 423 | 419 | /* 12-bit palette with 4-to-12 bit lookup table */ |
| 424 | 420 | |
| 425 | | if (state->m_blitter_direction_x) |
| 421 | if (m_blitter_direction_x) |
| 426 | 422 | { |
| 427 | 423 | // flip |
| 428 | 424 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 435 | 431 | color2 = (color & 0x0f) >> 0; |
| 436 | 432 | } |
| 437 | 433 | |
| 438 | | color1 = state->m_clut[color1] | ((state->m_clut[color1 | 0x10] & 0x0f) << 8); |
| 439 | | color2 = state->m_clut[color2] | ((state->m_clut[color2 | 0x10] & 0x0f) << 8); |
| 434 | color1 = m_clut[color1] | ((m_clut[color1 | 0x10] & 0x0f) << 8); |
| 435 | color2 = m_clut[color2] | ((m_clut[color2 | 0x10] & 0x0f) << 8); |
| 440 | 436 | |
| 441 | 437 | if (color1 != 0x0fff) |
| 442 | 438 | { |
| 443 | | state->m_mjsikaku_videoram[(dy * 512) + dx1] = color1; |
| 444 | | update_pixel(state, dx1, dy); |
| 439 | m_mjsikaku_videoram[(dy * 512) + dx1] = color1; |
| 440 | update_pixel(dx1, dy); |
| 445 | 441 | } |
| 446 | 442 | if (color2 != 0x0fff) |
| 447 | 443 | { |
| 448 | | state->m_mjsikaku_videoram[(dy * 512) + dx2] = color2; |
| 449 | | update_pixel(state, dx2, dy); |
| 444 | m_mjsikaku_videoram[(dy * 512) + dx2] = color2; |
| 445 | update_pixel(dx2, dy); |
| 450 | 446 | } |
| 451 | 447 | } |
| 452 | 448 | else |
| 453 | 449 | { |
| 454 | | if (gfxtype == GFXTYPE_HYBRID_12BIT && (state->m_mjsikaku_gfxflag2 & 0x20)) |
| 450 | if (gfxtype == GFXTYPE_HYBRID_12BIT && (m_mjsikaku_gfxflag2 & 0x20)) |
| 455 | 451 | { |
| 456 | 452 | /* 4096 colors mode, wedged in on top of normal mode |
| 457 | 453 | Here we affect only the 4 least significant bits, the others are |
| 458 | 454 | changed as usual. |
| 459 | 455 | */ |
| 460 | 456 | |
| 461 | | if (state->m_mjsikaku_gfxflag2 & 0x10) |
| 457 | if (m_mjsikaku_gfxflag2 & 0x10) |
| 462 | 458 | { |
| 463 | 459 | // 4096 colors low mode (2nd draw upper) |
| 464 | | color = state->m_clut[((color & 0xf0) >> 4)]; |
| 460 | color = m_clut[((color & 0xf0) >> 4)]; |
| 465 | 461 | } |
| 466 | 462 | else |
| 467 | 463 | { |
| 468 | 464 | // 4096 colors low mode (1st draw lower) |
| 469 | | color = state->m_clut[((color & 0x0f) >> 0)]; |
| 465 | color = m_clut[((color & 0x0f) >> 0)]; |
| 470 | 466 | } |
| 471 | 467 | |
| 472 | 468 | if (color != 0xff) |
| 473 | 469 | { |
| 474 | 470 | color &= 0x0f; |
| 475 | | writeram_high(state, dx1, dy, color); |
| 476 | | writeram_high(state, dx2, dy, color); |
| 471 | writeram_high(dx1, dy, color); |
| 472 | writeram_high(dx2, dy, color); |
| 477 | 473 | } |
| 478 | 474 | } |
| 479 | 475 | else |
| 480 | 476 | { |
| 481 | | if (state->m_mjsikaku_gfxflag2 & 0x04) |
| 477 | if (m_mjsikaku_gfxflag2 & 0x04) |
| 482 | 478 | { |
| 483 | 479 | // direct mode |
| 484 | 480 | |
| r20971 | r20972 | |
| 488 | 484 | { |
| 489 | 485 | // lookup table mode |
| 490 | 486 | |
| 491 | | if (state->m_blitter_direction_x) |
| 487 | if (m_blitter_direction_x) |
| 492 | 488 | { |
| 493 | 489 | // flip |
| 494 | 490 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 501 | 497 | color2 = (color & 0x0f) >> 0; |
| 502 | 498 | } |
| 503 | 499 | |
| 504 | | color1 = state->m_clut[color1]; |
| 505 | | color2 = state->m_clut[color2]; |
| 500 | color1 = m_clut[color1]; |
| 501 | color2 = m_clut[color2]; |
| 506 | 502 | } |
| 507 | 503 | |
| 508 | | if (gfxtype == GFXTYPE_PURE_16BIT && !(state->m_mjsikaku_gfxflag2 & 0x20)) |
| 504 | if (gfxtype == GFXTYPE_PURE_16BIT && !(m_mjsikaku_gfxflag2 & 0x20)) |
| 509 | 505 | { |
| 510 | 506 | /* 16-bit palette most significant bits */ |
| 511 | | if (color1 != 0xff) writeram_high(state, dx1, dy, color1); |
| 512 | | if (color2 != 0xff) writeram_high(state, dx2, dy, color2); |
| 507 | if (color1 != 0xff) writeram_high(dx1, dy, color1); |
| 508 | if (color2 != 0xff) writeram_high(dx2, dy, color2); |
| 513 | 509 | } |
| 514 | 510 | else |
| 515 | 511 | { |
| 516 | 512 | /* 8-bit palette or 16-bit palette least significant bits */ |
| 517 | | if (color1 != 0xff) writeram_low(state, dx1, dy, color1); |
| 518 | | if (color2 != 0xff) writeram_low(state, dx2, dy, color2); |
| 513 | if (color1 != 0xff) writeram_low(dx1, dy, color1); |
| 514 | if (color2 != 0xff) writeram_low(dx2, dy, color2); |
| 519 | 515 | } |
| 520 | 516 | } |
| 521 | 517 | } |
| r20971 | r20972 | |
| 527 | 523 | nb1413m3_busyflag = 0; |
| 528 | 524 | |
| 529 | 525 | if (gfxtype == GFXTYPE_8BIT) |
| 530 | | machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),state)); |
| 526 | machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),this)); |
| 531 | 527 | else |
| 532 | | machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),state)); |
| 528 | machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8688_state::blitter_timer_callback),this)); |
| 533 | 529 | } |
| 534 | 530 | |
| 535 | 531 | |
| r20971 | r20972 | |
| 538 | 534 | |
| 539 | 535 | ******************************************************************************/ |
| 540 | 536 | |
| 541 | | static void common_video_start(running_machine &machine) |
| 537 | void nbmj8688_state::common_video_start() |
| 542 | 538 | { |
| 543 | | nbmj8688_state *state = machine.driver_data<nbmj8688_state>(); |
| 544 | | state->m_mjsikaku_tmpbitmap = auto_bitmap_ind16_alloc(machine, 512, 256); |
| 545 | | state->m_mjsikaku_videoram = auto_alloc_array_clear(machine, UINT16, 512 * 256); |
| 546 | | state->m_clut = auto_alloc_array(machine, UINT8, 0x20); |
| 539 | m_mjsikaku_tmpbitmap = auto_bitmap_ind16_alloc(machine(), 512, 256); |
| 540 | m_mjsikaku_videoram = auto_alloc_array_clear(machine(), UINT16, 512 * 256); |
| 541 | m_clut = auto_alloc_array(machine(), UINT8, 0x20); |
| 547 | 542 | |
| 548 | | state->m_mjsikaku_scrolly = 0; // reset because crystalg/crystal2 don't write to this register |
| 543 | m_mjsikaku_scrolly = 0; // reset because crystalg/crystal2 don't write to this register |
| 549 | 544 | } |
| 550 | 545 | |
| 551 | 546 | VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_8bit) |
| 552 | 547 | { |
| 553 | 548 | m_mjsikaku_gfxmode = GFXTYPE_8BIT; |
| 554 | | common_video_start(machine()); |
| 549 | common_video_start(); |
| 555 | 550 | } |
| 556 | 551 | |
| 557 | 552 | VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_hybrid_12bit) |
| 558 | 553 | { |
| 559 | 554 | m_mjsikaku_gfxmode = GFXTYPE_HYBRID_12BIT; |
| 560 | | common_video_start(machine()); |
| 555 | common_video_start(); |
| 561 | 556 | } |
| 562 | 557 | |
| 563 | 558 | VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_pure_12bit) |
| 564 | 559 | { |
| 565 | 560 | m_mjsikaku_gfxmode = GFXTYPE_PURE_12BIT; |
| 566 | | common_video_start(machine()); |
| 561 | common_video_start(); |
| 567 | 562 | } |
| 568 | 563 | |
| 569 | 564 | VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_hybrid_16bit) |
| 570 | 565 | { |
| 571 | 566 | m_mjsikaku_gfxmode = GFXTYPE_HYBRID_16BIT; |
| 572 | | common_video_start(machine()); |
| 567 | common_video_start(); |
| 573 | 568 | } |
| 574 | 569 | |
| 575 | 570 | VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_pure_16bit) |
| 576 | 571 | { |
| 577 | 572 | m_mjsikaku_gfxmode = GFXTYPE_PURE_16BIT; |
| 578 | | common_video_start(machine()); |
| 573 | common_video_start(); |
| 579 | 574 | } |
| 580 | 575 | |
| 581 | 576 | VIDEO_START_MEMBER(nbmj8688_state,mbmj8688_pure_16bit_LCD) |
| r20971 | r20972 | |
| 585 | 580 | m_HD61830B_ram[0] = auto_alloc_array(machine(), UINT8, 0x10000); |
| 586 | 581 | m_HD61830B_ram[1] = auto_alloc_array(machine(), UINT8, 0x10000); |
| 587 | 582 | |
| 588 | | common_video_start(machine()); |
| 583 | common_video_start(); |
| 589 | 584 | } |
| 590 | 585 | |
| 591 | 586 | |
| r20971 | r20972 | |
| 596 | 591 | |
| 597 | 592 | ******************************************************************************/ |
| 598 | 593 | |
| 599 | | static void nbmj8688_HD61830B_instr_w(address_space &space,int offset,int data,int chip) |
| 594 | void nbmj8688_state::nbmj8688_HD61830B_instr_w(address_space &space,int offset,int data,int chip) |
| 600 | 595 | { |
| 601 | | nbmj8688_state *state = space.machine().driver_data<nbmj8688_state>(); |
| 602 | | state->m_HD61830B_instr[chip] = data; |
| 596 | m_HD61830B_instr[chip] = data; |
| 603 | 597 | } |
| 604 | 598 | |
| 605 | | static void nbmj8688_HD61830B_data_w(address_space &space,int offset,int data,int chip) |
| 599 | void nbmj8688_state::nbmj8688_HD61830B_data_w(address_space &space,int offset,int data,int chip) |
| 606 | 600 | { |
| 607 | | nbmj8688_state *state = space.machine().driver_data<nbmj8688_state>(); |
| 608 | | switch (state->m_HD61830B_instr[chip]) |
| 601 | switch (m_HD61830B_instr[chip]) |
| 609 | 602 | { |
| 610 | 603 | case 0x0a: // set cursor address (low order) |
| 611 | | state->m_HD61830B_addr[chip] = (state->m_HD61830B_addr[chip] & 0xff00) | data; |
| 604 | m_HD61830B_addr[chip] = (m_HD61830B_addr[chip] & 0xff00) | data; |
| 612 | 605 | break; |
| 613 | 606 | case 0x0b: // set cursor address (high order) |
| 614 | | state->m_HD61830B_addr[chip] = (state->m_HD61830B_addr[chip] & 0x00ff) | (data << 8); |
| 607 | m_HD61830B_addr[chip] = (m_HD61830B_addr[chip] & 0x00ff) | (data << 8); |
| 615 | 608 | break; |
| 616 | 609 | case 0x0c: // write display data |
| 617 | | state->m_HD61830B_ram[chip][state->m_HD61830B_addr[chip]++] = data; |
| 610 | m_HD61830B_ram[chip][m_HD61830B_addr[chip]++] = data; |
| 618 | 611 | break; |
| 619 | 612 | default: |
| 620 | | logerror("HD61830B unsupported instruction %02x %02x\n",state->m_HD61830B_instr[chip],data); |
| 613 | logerror("HD61830B unsupported instruction %02x %02x\n",m_HD61830B_instr[chip],data); |
| 621 | 614 | break; |
| 622 | 615 | } |
| 623 | 616 | } |
| r20971 | r20972 | |
| 678 | 671 | { |
| 679 | 672 | for (x = 0; x < 512; x++) |
| 680 | 673 | { |
| 681 | | update_pixel(this, x, y); |
| 674 | update_pixel(x, y); |
| 682 | 675 | } |
| 683 | 676 | } |
| 684 | 677 | } |
trunk/src/mame/video/nbmj8991.c
| r20971 | r20972 | |
| 10 | 10 | #include "includes/nb1413m3.h" |
| 11 | 11 | #include "includes/nbmj8991.h" |
| 12 | 12 | |
| 13 | | |
| 14 | | static void nbmj8991_vramflip(running_machine &machine); |
| 15 | | static void nbmj8991_gfxdraw(running_machine &machine); |
| 16 | | static void update_pixel(running_machine &machine, int x, int y); |
| 17 | | |
| 18 | | |
| 19 | 13 | /****************************************************************************** |
| 20 | 14 | |
| 21 | 15 | |
| r20971 | r20972 | |
| 89 | 83 | case 0x04: m_blitter_sizex = data; break; |
| 90 | 84 | case 0x05: m_blitter_sizey = data; |
| 91 | 85 | /* writing here also starts the blit */ |
| 92 | | nbmj8991_gfxdraw(machine()); |
| 86 | nbmj8991_gfxdraw(); |
| 93 | 87 | break; |
| 94 | 88 | case 0x06: m_blitter_direction_x = (data & 0x01) ? 1 : 0; |
| 95 | 89 | m_blitter_direction_y = (data & 0x02) ? 1 : 0; |
| 96 | 90 | m_flipscreen = (data & 0x04) ? 0 : 1; |
| 97 | 91 | m_dispflag = (data & 0x10) ? 0 : 1; |
| 98 | | nbmj8991_vramflip(machine()); |
| 92 | nbmj8991_vramflip(); |
| 99 | 93 | break; |
| 100 | 94 | case 0x07: break; |
| 101 | 95 | case 0x10: m_blitter_destx = (m_blitter_destx & 0xff00) | data; break; |
| r20971 | r20972 | |
| 134 | 128 | |
| 135 | 129 | |
| 136 | 130 | ******************************************************************************/ |
| 137 | | static void nbmj8991_vramflip(running_machine &machine) |
| 131 | void nbmj8991_state::nbmj8991_vramflip() |
| 138 | 132 | { |
| 139 | | nbmj8991_state *state = machine.driver_data<nbmj8991_state>(); |
| 140 | 133 | int x, y; |
| 141 | 134 | UINT8 color1, color2; |
| 142 | | int width = machine.primary_screen->width(); |
| 143 | | int height = machine.primary_screen->height(); |
| 135 | int width = machine().primary_screen->width(); |
| 136 | int height = machine().primary_screen->height(); |
| 144 | 137 | |
| 145 | | if (state->m_flipscreen == state->m_flipscreen_old) return; |
| 138 | if (m_flipscreen == m_flipscreen_old) return; |
| 146 | 139 | |
| 147 | 140 | for (y = 0; y < height / 2; y++) |
| 148 | 141 | { |
| 149 | 142 | for (x = 0; x < width / 2; x++) |
| 150 | 143 | { |
| 151 | 144 | // rotate 180 degrees ( 0, 0) - ( 511, 511) |
| 152 | | color1 = state->m_videoram[(y * width) + x]; |
| 153 | | color2 = state->m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)]; |
| 154 | | state->m_videoram[(y * width) + x] = color2; |
| 155 | | state->m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)] = color1; |
| 145 | color1 = m_videoram[(y * width) + x]; |
| 146 | color2 = m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)]; |
| 147 | m_videoram[(y * width) + x] = color2; |
| 148 | m_videoram[(((height - 1) - y) * width) + (((width / 2) - 1) - x)] = color1; |
| 156 | 149 | // rotate 180 degrees ( 512, 0) - (1023, 511) |
| 157 | | color1 = state->m_videoram[(y * width) + (x + (width / 2))]; |
| 158 | | color2 = state->m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))]; |
| 159 | | state->m_videoram[(y * width) + (x + (width / 2))] = color2; |
| 160 | | state->m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))] = color1; |
| 150 | color1 = m_videoram[(y * width) + (x + (width / 2))]; |
| 151 | color2 = m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))]; |
| 152 | m_videoram[(y * width) + (x + (width / 2))] = color2; |
| 153 | m_videoram[(((height - 1) - y) * width) + ((((width / 2) - 1) - x) + (width / 2))] = color1; |
| 161 | 154 | } |
| 162 | 155 | } |
| 163 | 156 | |
| 164 | | state->m_flipscreen_old = state->m_flipscreen; |
| 165 | | state->m_screen_refresh = 1; |
| 157 | m_flipscreen_old = m_flipscreen; |
| 158 | m_screen_refresh = 1; |
| 166 | 159 | } |
| 167 | 160 | |
| 168 | | static void update_pixel(running_machine &machine, int x, int y) |
| 161 | void nbmj8991_state::update_pixel(int x, int y) |
| 169 | 162 | { |
| 170 | | nbmj8991_state *state = machine.driver_data<nbmj8991_state>(); |
| 171 | | UINT8 color = state->m_videoram[(y * machine.primary_screen->width()) + x]; |
| 172 | | state->m_tmpbitmap.pix16(y, x) = color; |
| 163 | UINT8 color = m_videoram[(y * machine().primary_screen->width()) + x]; |
| 164 | m_tmpbitmap.pix16(y, x) = color; |
| 173 | 165 | } |
| 174 | 166 | |
| 175 | 167 | TIMER_CALLBACK_MEMBER(nbmj8991_state::blitter_timer_callback) |
| r20971 | r20972 | |
| 177 | 169 | nb1413m3_busyflag = 1; |
| 178 | 170 | } |
| 179 | 171 | |
| 180 | | static void nbmj8991_gfxdraw(running_machine &machine) |
| 172 | void nbmj8991_state::nbmj8991_gfxdraw() |
| 181 | 173 | { |
| 182 | | nbmj8991_state *state = machine.driver_data<nbmj8991_state>(); |
| 183 | | UINT8 *GFX = state->memregion("gfx1")->base(); |
| 184 | | int width = machine.primary_screen->width(); |
| 174 | UINT8 *GFX = memregion("gfx1")->base(); |
| 175 | int width = machine().primary_screen->width(); |
| 185 | 176 | |
| 186 | 177 | int x, y; |
| 187 | 178 | int dx1, dx2, dy; |
| r20971 | r20972 | |
| 194 | 185 | |
| 195 | 186 | nb1413m3_busyctr = 0; |
| 196 | 187 | |
| 197 | | if (state->m_blitter_direction_x) |
| 188 | if (m_blitter_direction_x) |
| 198 | 189 | { |
| 199 | | startx = state->m_blitter_destx; |
| 200 | | sizex = state->m_blitter_sizex ^ 0xff; |
| 190 | startx = m_blitter_destx; |
| 191 | sizex = m_blitter_sizex ^ 0xff; |
| 201 | 192 | skipx = 1; |
| 202 | 193 | } |
| 203 | 194 | else |
| 204 | 195 | { |
| 205 | | startx = state->m_blitter_destx + state->m_blitter_sizex; |
| 206 | | sizex = state->m_blitter_sizex; |
| 196 | startx = m_blitter_destx + m_blitter_sizex; |
| 197 | sizex = m_blitter_sizex; |
| 207 | 198 | skipx = -1; |
| 208 | 199 | } |
| 209 | 200 | |
| 210 | | if (state->m_blitter_direction_y) |
| 201 | if (m_blitter_direction_y) |
| 211 | 202 | { |
| 212 | | starty = state->m_blitter_desty; |
| 213 | | sizey = state->m_blitter_sizey ^ 0xff; |
| 203 | starty = m_blitter_desty; |
| 204 | sizey = m_blitter_sizey ^ 0xff; |
| 214 | 205 | skipy = 1; |
| 215 | 206 | } |
| 216 | 207 | else |
| 217 | 208 | { |
| 218 | | starty = state->m_blitter_desty + state->m_blitter_sizey; |
| 219 | | sizey = state->m_blitter_sizey; |
| 209 | starty = m_blitter_desty + m_blitter_sizey; |
| 210 | sizey = m_blitter_sizey; |
| 220 | 211 | skipy = -1; |
| 221 | 212 | } |
| 222 | 213 | |
| 223 | | gfxlen = machine.root_device().memregion("gfx1")->bytes(); |
| 224 | | gfxaddr = (state->m_gfxrom << 17) + (state->m_blitter_src_addr << 1); |
| 214 | gfxlen = machine().root_device().memregion("gfx1")->bytes(); |
| 215 | gfxaddr = (m_gfxrom << 17) + (m_blitter_src_addr << 1); |
| 225 | 216 | |
| 226 | 217 | for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) |
| 227 | 218 | { |
| r20971 | r20972 | |
| 241 | 232 | dx2 = (2 * x + 1) & 0x3ff; |
| 242 | 233 | dy = y & 0x1ff; |
| 243 | 234 | |
| 244 | | if (!state->m_flipscreen) |
| 235 | if (!m_flipscreen) |
| 245 | 236 | { |
| 246 | 237 | dx1 ^= 0x1ff; |
| 247 | 238 | dx2 ^= 0x1ff; |
| 248 | 239 | dy ^= 0x1ff; |
| 249 | 240 | } |
| 250 | 241 | |
| 251 | | if (state->m_blitter_direction_x) |
| 242 | if (m_blitter_direction_x) |
| 252 | 243 | { |
| 253 | 244 | // flip |
| 254 | 245 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 261 | 252 | color2 = (color & 0x0f) >> 0; |
| 262 | 253 | } |
| 263 | 254 | |
| 264 | | color1 = state->m_clut[((state->m_clutsel & 0x7f) * 0x10) + color1]; |
| 265 | | color2 = state->m_clut[((state->m_clutsel & 0x7f) * 0x10) + color2]; |
| 255 | color1 = m_clut[((m_clutsel & 0x7f) * 0x10) + color1]; |
| 256 | color2 = m_clut[((m_clutsel & 0x7f) * 0x10) + color2]; |
| 266 | 257 | |
| 267 | 258 | if (color1 != 0xff) |
| 268 | 259 | { |
| 269 | | state->m_videoram[(dy * width) + dx1] = color1; |
| 270 | | update_pixel(machine, dx1, dy); |
| 260 | m_videoram[(dy * width) + dx1] = color1; |
| 261 | update_pixel(dx1, dy); |
| 271 | 262 | } |
| 272 | 263 | if (color2 != 0xff) |
| 273 | 264 | { |
| 274 | | state->m_videoram[(dy * width) + dx2] = color2; |
| 275 | | update_pixel(machine, dx2, dy); |
| 265 | m_videoram[(dy * width) + dx2] = color2; |
| 266 | update_pixel(dx2, dy); |
| 276 | 267 | } |
| 277 | 268 | |
| 278 | 269 | nb1413m3_busyctr++; |
| r20971 | r20972 | |
| 280 | 271 | } |
| 281 | 272 | |
| 282 | 273 | nb1413m3_busyflag = 0; |
| 283 | | machine.scheduler().timer_set(attotime::from_nsec(1650) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8991_state::blitter_timer_callback),state)); |
| 274 | machine().scheduler().timer_set(attotime::from_nsec(1650) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8991_state::blitter_timer_callback),this)); |
| 284 | 275 | } |
| 285 | 276 | |
| 286 | 277 | /****************************************************************************** |
| r20971 | r20972 | |
| 311 | 302 | |
| 312 | 303 | for (y = 0; y < height; y++) |
| 313 | 304 | for (x = 0; x < width; x++) |
| 314 | | update_pixel(machine(), x, y); |
| 305 | update_pixel(x, y); |
| 315 | 306 | } |
| 316 | 307 | |
| 317 | 308 | if (m_dispflag) |
| r20971 | r20972 | |
| 350 | 341 | |
| 351 | 342 | for (y = 0; y < height; y++) |
| 352 | 343 | for (x = 0; x < width; x++) |
| 353 | | update_pixel(machine(), x, y); |
| 344 | update_pixel(x, y); |
| 354 | 345 | } |
| 355 | 346 | |
| 356 | 347 | if (nb1413m3_inputport & 0x20) |
trunk/src/mame/video/nbmj8900.c
| r20971 | r20972 | |
| 11 | 11 | #include "includes/nbmj8900.h" |
| 12 | 12 | |
| 13 | 13 | |
| 14 | | static void nbmj8900_vramflip(running_machine &machine, int vram); |
| 15 | | static void nbmj8900_gfxdraw(running_machine &machine); |
| 16 | | |
| 17 | | |
| 18 | 14 | /****************************************************************************** |
| 19 | 15 | |
| 20 | 16 | |
| r20971 | r20972 | |
| 117 | 113 | case 0x04: m_blitter_sizex = data; break; |
| 118 | 114 | case 0x05: m_blitter_sizey = data; |
| 119 | 115 | /* writing here also starts the blit */ |
| 120 | | nbmj8900_gfxdraw(machine()); |
| 116 | nbmj8900_gfxdraw(); |
| 121 | 117 | break; |
| 122 | 118 | case 0x06: m_blitter_direction_x = (data & 0x01) ? 1 : 0; |
| 123 | 119 | m_blitter_direction_y = (data & 0x02) ? 1 : 0; |
| 124 | 120 | m_flipscreen = (data & 0x04) ? 1 : 0; |
| 125 | 121 | m_dispflag = (data & 0x08) ? 0 : 1; |
| 126 | | if (m_gfxdraw_mode) nbmj8900_vramflip(machine(), 1); |
| 127 | | nbmj8900_vramflip(machine(), 0); |
| 122 | if (m_gfxdraw_mode) nbmj8900_vramflip(1); |
| 123 | nbmj8900_vramflip(0); |
| 128 | 124 | break; |
| 129 | 125 | case 0x07: break; |
| 130 | 126 | } |
| r20971 | r20972 | |
| 160 | 156 | |
| 161 | 157 | |
| 162 | 158 | ******************************************************************************/ |
| 163 | | void nbmj8900_vramflip(running_machine &machine, int vram) |
| 159 | void nbmj8900_state::nbmj8900_vramflip(int vram) |
| 164 | 160 | { |
| 165 | | nbmj8900_state *state = machine.driver_data<nbmj8900_state>(); |
| 166 | 161 | int x, y; |
| 167 | 162 | unsigned char color1, color2; |
| 168 | 163 | unsigned char *vidram; |
| 169 | | int width = machine.primary_screen->width(); |
| 170 | | int height = machine.primary_screen->height(); |
| 164 | int width = machine().primary_screen->width(); |
| 165 | int height = machine().primary_screen->height(); |
| 171 | 166 | |
| 172 | | if (state->m_flipscreen == state->m_flipscreen_old) return; |
| 167 | if (m_flipscreen == m_flipscreen_old) return; |
| 173 | 168 | |
| 174 | | vidram = vram ? state->m_videoram1 : state->m_videoram0; |
| 169 | vidram = vram ? m_videoram1 : m_videoram0; |
| 175 | 170 | |
| 176 | 171 | for (y = 0; y < (height / 2); y++) |
| 177 | 172 | { |
| r20971 | r20972 | |
| 184 | 179 | } |
| 185 | 180 | } |
| 186 | 181 | |
| 187 | | state->m_flipscreen_old = state->m_flipscreen; |
| 188 | | state->m_screen_refresh = 1; |
| 182 | m_flipscreen_old = m_flipscreen; |
| 183 | m_screen_refresh = 1; |
| 189 | 184 | } |
| 190 | 185 | |
| 191 | 186 | |
| 192 | | static void update_pixel0(running_machine &machine, int x, int y) |
| 187 | void nbmj8900_state::update_pixel0(int x, int y) |
| 193 | 188 | { |
| 194 | | nbmj8900_state *state = machine.driver_data<nbmj8900_state>(); |
| 195 | | UINT8 color = state->m_videoram0[(y * state->m_screen_width) + x]; |
| 196 | | state->m_tmpbitmap0.pix16(y, x) = machine.pens[color]; |
| 189 | UINT8 color = m_videoram0[(y * m_screen_width) + x]; |
| 190 | m_tmpbitmap0.pix16(y, x) = machine().pens[color]; |
| 197 | 191 | } |
| 198 | 192 | |
| 199 | | static void update_pixel1(running_machine &machine, int x, int y) |
| 193 | void nbmj8900_state::update_pixel1(int x, int y) |
| 200 | 194 | { |
| 201 | | nbmj8900_state *state = machine.driver_data<nbmj8900_state>(); |
| 202 | | UINT8 color = state->m_videoram1[(y * state->m_screen_width) + x]; |
| 203 | | state->m_tmpbitmap1.pix16(y, x) = machine.pens[color]; |
| 195 | UINT8 color = m_videoram1[(y * m_screen_width) + x]; |
| 196 | m_tmpbitmap1.pix16(y, x) = machine().pens[color]; |
| 204 | 197 | } |
| 205 | 198 | |
| 206 | 199 | TIMER_CALLBACK_MEMBER(nbmj8900_state::blitter_timer_callback) |
| r20971 | r20972 | |
| 208 | 201 | nb1413m3_busyflag = 1; |
| 209 | 202 | } |
| 210 | 203 | |
| 211 | | static void nbmj8900_gfxdraw(running_machine &machine) |
| 204 | void nbmj8900_state::nbmj8900_gfxdraw() |
| 212 | 205 | { |
| 213 | | nbmj8900_state *state = machine.driver_data<nbmj8900_state>(); |
| 214 | | unsigned char *GFX = state->memregion("gfx")->base(); |
| 206 | unsigned char *GFX = memregion("gfx")->base(); |
| 215 | 207 | |
| 216 | 208 | int x, y; |
| 217 | 209 | int dx1, dx2, dy1, dy2; |
| r20971 | r20972 | |
| 224 | 216 | |
| 225 | 217 | nb1413m3_busyctr = 0; |
| 226 | 218 | |
| 227 | | startx = state->m_blitter_destx + state->m_blitter_sizex; |
| 228 | | starty = state->m_blitter_desty + state->m_blitter_sizey; |
| 219 | startx = m_blitter_destx + m_blitter_sizex; |
| 220 | starty = m_blitter_desty + m_blitter_sizey; |
| 229 | 221 | |
| 230 | | if (state->m_blitter_direction_x) |
| 222 | if (m_blitter_direction_x) |
| 231 | 223 | { |
| 232 | | sizex = state->m_blitter_sizex ^ 0xff; |
| 224 | sizex = m_blitter_sizex ^ 0xff; |
| 233 | 225 | skipx = 1; |
| 234 | 226 | } |
| 235 | 227 | else |
| 236 | 228 | { |
| 237 | | sizex = state->m_blitter_sizex; |
| 229 | sizex = m_blitter_sizex; |
| 238 | 230 | skipx = -1; |
| 239 | 231 | } |
| 240 | 232 | |
| 241 | | if (state->m_blitter_direction_y) |
| 233 | if (m_blitter_direction_y) |
| 242 | 234 | { |
| 243 | | sizey = state->m_blitter_sizey ^ 0xff; |
| 235 | sizey = m_blitter_sizey ^ 0xff; |
| 244 | 236 | skipy = 1; |
| 245 | 237 | } |
| 246 | 238 | else |
| 247 | 239 | { |
| 248 | | sizey = state->m_blitter_sizey; |
| 240 | sizey = m_blitter_sizey; |
| 249 | 241 | skipy = -1; |
| 250 | 242 | } |
| 251 | 243 | |
| 252 | | gfxaddr = (state->m_gfxrom << 17) + (state->m_blitter_src_addr << 1); |
| 244 | gfxaddr = (m_gfxrom << 17) + (m_blitter_src_addr << 1); |
| 253 | 245 | |
| 254 | 246 | for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) |
| 255 | 247 | { |
| 256 | 248 | for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) |
| 257 | 249 | { |
| 258 | | if ((gfxaddr > (machine.root_device().memregion("gfx")->bytes() - 1))) |
| 250 | if ((gfxaddr > (machine().root_device().memregion("gfx")->bytes() - 1))) |
| 259 | 251 | { |
| 260 | 252 | #ifdef MAME_DEBUG |
| 261 | 253 | popmessage("GFXROM ADDRESS OVER!!"); |
| 262 | 254 | #endif |
| 263 | | gfxaddr &= (machine.root_device().memregion("gfx")->bytes() - 1); |
| 255 | gfxaddr &= (machine().root_device().memregion("gfx")->bytes() - 1); |
| 264 | 256 | } |
| 265 | 257 | |
| 266 | 258 | color = GFX[gfxaddr++]; |
| r20971 | r20972 | |
| 274 | 266 | dx1 = (2 * x + 0) & 0x1ff; |
| 275 | 267 | dx2 = (2 * x + 1) & 0x1ff; |
| 276 | 268 | |
| 277 | | if (state->m_gfxdraw_mode) |
| 269 | if (m_gfxdraw_mode) |
| 278 | 270 | { |
| 279 | 271 | // 2 layer type |
| 280 | 272 | dy1 = y & 0xff; |
| 281 | | dy2 = (y + state->m_scrolly) & 0xff; |
| 273 | dy2 = (y + m_scrolly) & 0xff; |
| 282 | 274 | } |
| 283 | 275 | else |
| 284 | 276 | { |
| 285 | 277 | // 1 layer type |
| 286 | | dy1 = (y + state->m_scrolly) & 0xff; |
| 278 | dy1 = (y + m_scrolly) & 0xff; |
| 287 | 279 | dy2 = 0; |
| 288 | 280 | } |
| 289 | 281 | |
| 290 | | if (!state->m_flipscreen) |
| 282 | if (!m_flipscreen) |
| 291 | 283 | { |
| 292 | 284 | dx1 ^= 0x1ff; |
| 293 | 285 | dx2 ^= 0x1ff; |
| r20971 | r20972 | |
| 295 | 287 | dy2 ^= 0xff; |
| 296 | 288 | } |
| 297 | 289 | |
| 298 | | if (state->m_blitter_direction_x) |
| 290 | if (m_blitter_direction_x) |
| 299 | 291 | { |
| 300 | 292 | // flip |
| 301 | 293 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 308 | 300 | color2 = (color & 0x0f) >> 0; |
| 309 | 301 | } |
| 310 | 302 | |
| 311 | | color1 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color1]; |
| 312 | | color2 = state->m_clut[((state->m_clutsel & 0x7f) << 4) + color2]; |
| 303 | color1 = m_clut[((m_clutsel & 0x7f) << 4) + color1]; |
| 304 | color2 = m_clut[((m_clutsel & 0x7f) << 4) + color2]; |
| 313 | 305 | |
| 314 | | if ((!state->m_gfxdraw_mode) || (state->m_vram & 0x01)) |
| 306 | if ((!m_gfxdraw_mode) || (m_vram & 0x01)) |
| 315 | 307 | { |
| 316 | 308 | // layer 1 |
| 317 | 309 | if (color1 != 0xff) |
| 318 | 310 | { |
| 319 | | state->m_videoram0[(dy1 * state->m_screen_width) + dx1] = color1; |
| 320 | | update_pixel0(machine, dx1, dy1); |
| 311 | m_videoram0[(dy1 * m_screen_width) + dx1] = color1; |
| 312 | update_pixel0(dx1, dy1); |
| 321 | 313 | } |
| 322 | 314 | if (color2 != 0xff) |
| 323 | 315 | { |
| 324 | | state->m_videoram0[(dy1 * state->m_screen_width) + dx2] = color2; |
| 325 | | update_pixel0(machine, dx2, dy1); |
| 316 | m_videoram0[(dy1 * m_screen_width) + dx2] = color2; |
| 317 | update_pixel0(dx2, dy1); |
| 326 | 318 | } |
| 327 | 319 | } |
| 328 | | if (state->m_gfxdraw_mode && (state->m_vram & 0x02)) |
| 320 | if (m_gfxdraw_mode && (m_vram & 0x02)) |
| 329 | 321 | { |
| 330 | 322 | // layer 2 |
| 331 | | if (state->m_vram & 0x08) |
| 323 | if (m_vram & 0x08) |
| 332 | 324 | { |
| 333 | 325 | // transparent enable |
| 334 | 326 | if (color1 != 0xff) |
| 335 | 327 | { |
| 336 | | state->m_videoram1[(dy2 * state->m_screen_width) + dx1] = color1; |
| 337 | | update_pixel1(machine, dx1, dy2); |
| 328 | m_videoram1[(dy2 * m_screen_width) + dx1] = color1; |
| 329 | update_pixel1(dx1, dy2); |
| 338 | 330 | } |
| 339 | 331 | if (color2 != 0xff) |
| 340 | 332 | { |
| 341 | | state->m_videoram1[(dy2 * state->m_screen_width) + dx2] = color2; |
| 342 | | update_pixel1(machine, dx2, dy2); |
| 333 | m_videoram1[(dy2 * m_screen_width) + dx2] = color2; |
| 334 | update_pixel1(dx2, dy2); |
| 343 | 335 | } |
| 344 | 336 | } |
| 345 | 337 | else |
| 346 | 338 | { |
| 347 | 339 | // transparent disable |
| 348 | | state->m_videoram1[(dy2 * state->m_screen_width) + dx1] = color1; |
| 349 | | update_pixel1(machine, dx1, dy2); |
| 350 | | state->m_videoram1[(dy2 * state->m_screen_width) + dx2] = color2; |
| 351 | | update_pixel1(machine, dx2, dy2); |
| 340 | m_videoram1[(dy2 * m_screen_width) + dx1] = color1; |
| 341 | update_pixel1(dx1, dy2); |
| 342 | m_videoram1[(dy2 * m_screen_width) + dx2] = color2; |
| 343 | update_pixel1(dx2, dy2); |
| 352 | 344 | } |
| 353 | 345 | } |
| 354 | 346 | |
| r20971 | r20972 | |
| 357 | 349 | } |
| 358 | 350 | |
| 359 | 351 | nb1413m3_busyflag = 0; |
| 360 | | machine.scheduler().timer_set(attotime::from_nsec(2500) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8900_state::blitter_timer_callback),state)); |
| 352 | machine().scheduler().timer_set(attotime::from_nsec(2500) * nb1413m3_busyctr, timer_expired_delegate(FUNC(nbmj8900_state::blitter_timer_callback),this)); |
| 361 | 353 | } |
| 362 | 354 | |
| 363 | 355 | /****************************************************************************** |
| r20971 | r20972 | |
| 396 | 388 | { |
| 397 | 389 | for (x = 0; x < m_screen_width; x++) |
| 398 | 390 | { |
| 399 | | update_pixel0(machine(), x, y); |
| 391 | update_pixel0(x, y); |
| 400 | 392 | } |
| 401 | 393 | } |
| 402 | 394 | if (m_gfxdraw_mode) |
| r20971 | r20972 | |
| 405 | 397 | { |
| 406 | 398 | for (x = 0; x < m_screen_width; x++) |
| 407 | 399 | { |
| 408 | | update_pixel1(machine(), x, y); |
| 400 | update_pixel1(x, y); |
| 409 | 401 | } |
| 410 | 402 | } |
| 411 | 403 | } |
trunk/src/mame/video/nmk16.c
| r20971 | r20972 | |
| 108 | 108 | |
| 109 | 109 | ***************************************************************************/ |
| 110 | 110 | |
| 111 | | static void nmk16_video_init(running_machine &machine) |
| 111 | void nmk16_state::nmk16_video_init() |
| 112 | 112 | { |
| 113 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 114 | | state->m_spriteram_old = auto_alloc_array_clear(machine, UINT16, 0x1000/2); |
| 115 | | state->m_spriteram_old2 = auto_alloc_array_clear(machine, UINT16, 0x1000/2); |
| 113 | m_spriteram_old = auto_alloc_array_clear(machine(), UINT16, 0x1000/2); |
| 114 | m_spriteram_old2 = auto_alloc_array_clear(machine(), UINT16, 0x1000/2); |
| 116 | 115 | |
| 117 | | state->m_videoshift = 0; /* 256x224 screen, no shift */ |
| 118 | | state->m_background_bitmap = NULL; |
| 119 | | state->m_simple_scroll = 1; |
| 116 | m_videoshift = 0; /* 256x224 screen, no shift */ |
| 117 | m_background_bitmap = NULL; |
| 118 | m_simple_scroll = 1; |
| 120 | 119 | } |
| 121 | 120 | |
| 122 | 121 | |
| r20971 | r20972 | |
| 128 | 127 | m_bg_tilemap0->set_transparent_pen(15); |
| 129 | 128 | m_tx_tilemap->set_transparent_pen(15); |
| 130 | 129 | |
| 131 | | nmk16_video_init(machine()); |
| 130 | nmk16_video_init(); |
| 132 | 131 | m_background_bitmap = auto_bitmap_ind16_alloc(machine(),8192,512); |
| 133 | 132 | m_bioship_background_bank=0; |
| 134 | 133 | m_redraw_bitmap = 1; |
| r20971 | r20972 | |
| 144 | 143 | m_fg_tilemap->set_transparent_pen(15); |
| 145 | 144 | m_tx_tilemap->set_transparent_pen(15); |
| 146 | 145 | |
| 147 | | nmk16_video_init(machine()); |
| 146 | nmk16_video_init(); |
| 148 | 147 | } |
| 149 | 148 | |
| 150 | 149 | VIDEO_START_MEMBER(nmk16_state,macross) |
| r20971 | r20972 | |
| 154 | 153 | |
| 155 | 154 | m_tx_tilemap->set_transparent_pen(15); |
| 156 | 155 | |
| 157 | | nmk16_video_init(machine()); |
| 156 | nmk16_video_init(); |
| 158 | 157 | } |
| 159 | 158 | |
| 160 | 159 | VIDEO_START_MEMBER(nmk16_state,gunnail) |
| r20971 | r20972 | |
| 165 | 164 | m_tx_tilemap->set_transparent_pen(15); |
| 166 | 165 | m_bg_tilemap0->set_scroll_rows(512); |
| 167 | 166 | |
| 168 | | nmk16_video_init(machine()); |
| 167 | nmk16_video_init(); |
| 169 | 168 | m_videoshift = 64; /* 384x224 screen, leftmost 64 pixels have to be retrieved */ |
| 170 | 169 | /* from the other side of the tilemap (!) */ |
| 171 | 170 | m_simple_scroll = 0; |
| r20971 | r20972 | |
| 182 | 181 | |
| 183 | 182 | m_tx_tilemap->set_transparent_pen(15); |
| 184 | 183 | |
| 185 | | nmk16_video_init(machine()); |
| 184 | nmk16_video_init(); |
| 186 | 185 | m_videoshift = 64; /* 384x224 screen, leftmost 64 pixels have to be retrieved */ |
| 187 | 186 | /* from the other side of the tilemap (!) */ |
| 188 | 187 | } |
| r20971 | r20972 | |
| 197 | 196 | { |
| 198 | 197 | m_bg_tilemap0 = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(nmk16_state::bjtwin_get_bg_tile_info),this),TILEMAP_SCAN_COLS,8,8,64,32); |
| 199 | 198 | |
| 200 | | nmk16_video_init(machine()); |
| 199 | nmk16_video_init(); |
| 201 | 200 | m_videoshift = 64; /* 384x224 screen, leftmost 64 pixels have to be retrieved */ |
| 202 | 201 | /* from the other side of the tilemap (!) */ |
| 203 | 202 | } |
| r20971 | r20972 | |
| 389 | 388 | |
| 390 | 389 | // manybloc uses extra flip bits on the sprites, but these break other games |
| 391 | 390 | |
| 392 | | static inline void nmk16_draw_sprite(nmk16_state *state, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr) |
| 391 | inline void nmk16_state::nmk16_draw_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr) |
| 393 | 392 | { |
| 394 | 393 | if ((spr[0] & 0x0001)) |
| 395 | 394 | { |
| 396 | | int sx = (spr[4] & 0x1FF) + state->m_videoshift; |
| 395 | int sx = (spr[4] & 0x1FF) + m_videoshift; |
| 397 | 396 | int sy = spr[6] & 0x1FF; |
| 398 | 397 | int code = spr[3]; |
| 399 | 398 | int color = spr[7]; |
| r20971 | r20972 | |
| 406 | 405 | if(pri != priority) |
| 407 | 406 | return; |
| 408 | 407 | |
| 409 | | if (state->flip_screen()) |
| 408 | if (flip_screen()) |
| 410 | 409 | { |
| 411 | 410 | sx = 368 - sx; |
| 412 | 411 | sy = 240 - sy; |
| r20971 | r20972 | |
| 420 | 419 | xx = w; |
| 421 | 420 | do |
| 422 | 421 | { |
| 423 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[2], |
| 422 | drawgfx_transpen(bitmap,cliprect,machine().gfx[2], |
| 424 | 423 | code, |
| 425 | 424 | color, |
| 426 | | state->flip_screen(), state->flip_screen(), |
| 425 | flip_screen(), flip_screen(), |
| 427 | 426 | ((x + 16) & 0x1FF) - 16,sy & 0x1FF,15); |
| 428 | 427 | code++; |
| 429 | 428 | x += delta; |
| r20971 | r20972 | |
| 434 | 433 | } |
| 435 | 434 | } |
| 436 | 435 | |
| 437 | | static inline void nmk16_draw_sprite_flipsupported(nmk16_state *state, running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr) |
| 436 | inline void nmk16_state::nmk16_draw_sprite_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16 *spr) |
| 438 | 437 | { |
| 439 | 438 | if ((spr[0] & 0x0001)) |
| 440 | 439 | { |
| 441 | | int sx = (spr[4] & 0x1FF) + state->m_videoshift; |
| 440 | int sx = (spr[4] & 0x1FF) + m_videoshift; |
| 442 | 441 | int sy = spr[6] & 0x1FF; |
| 443 | 442 | int code = spr[3]; |
| 444 | 443 | int color = spr[7]; |
| r20971 | r20972 | |
| 454 | 453 | if(pri != priority) |
| 455 | 454 | return; |
| 456 | 455 | |
| 457 | | flipx ^= state->flip_screen(); |
| 458 | | flipy ^= state->flip_screen(); |
| 456 | flipx ^= flip_screen(); |
| 457 | flipy ^= flip_screen(); |
| 459 | 458 | |
| 460 | | if (state->flip_screen()) |
| 459 | if (flip_screen()) |
| 461 | 460 | { |
| 462 | 461 | sx = 368 - sx; |
| 463 | 462 | sy = 240 - sy; |
| r20971 | r20972 | |
| 472 | 471 | xx = w; |
| 473 | 472 | do |
| 474 | 473 | { |
| 475 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[2], |
| 474 | drawgfx_transpen(bitmap,cliprect,machine().gfx[2], |
| 476 | 475 | code, |
| 477 | 476 | color, |
| 478 | 477 | flipx, flipy, |
| r20971 | r20972 | |
| 485 | 484 | } |
| 486 | 485 | } |
| 487 | 486 | |
| 488 | | static void nmk16_draw_sprites_swap(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl) |
| 487 | void nmk16_state::nmk16_draw_sprites_swap(bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl) |
| 489 | 488 | { |
| 490 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 491 | 489 | int i, prio; |
| 492 | 490 | |
| 493 | 491 | // Priority level (4 levels, 0x100 sprites) |
| r20971 | r20972 | |
| 497 | 495 | for ( i = 0; i < 0x100; i++ ) |
| 498 | 496 | { |
| 499 | 497 | int spr = BITSWAP8(i, bittbl[0], bittbl[1], bittbl[2], bittbl[3], bittbl[4], bittbl[5], bittbl[6], bittbl[7]); |
| 500 | | nmk16_draw_sprite(state, machine, bitmap, cliprect, prio, state->m_spriteram_old2 + (spr * 8)); |
| 498 | nmk16_draw_sprite(bitmap, cliprect, prio, m_spriteram_old2 + (spr * 8)); |
| 501 | 499 | } |
| 502 | 500 | } |
| 503 | 501 | } |
| 504 | 502 | |
| 505 | | static void nmk16_draw_sprites_swap_flipsupported(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl) |
| 503 | void nmk16_state::nmk16_draw_sprites_swap_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int *bittbl) |
| 506 | 504 | { |
| 507 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 508 | 505 | int i, prio; |
| 509 | 506 | |
| 510 | 507 | // Priority level (4 levels, 0x100 sprites) |
| r20971 | r20972 | |
| 514 | 511 | for ( i = 0; i < 0x100; i++ ) |
| 515 | 512 | { |
| 516 | 513 | int spr = BITSWAP8(i, bittbl[0], bittbl[1], bittbl[2], bittbl[3], bittbl[4], bittbl[5], bittbl[6], bittbl[7]); |
| 517 | | nmk16_draw_sprite_flipsupported(state, machine, bitmap, cliprect, prio, state->m_spriteram_old2 + (spr * 16/2)); |
| 514 | nmk16_draw_sprite_flipsupported(bitmap, cliprect, prio, m_spriteram_old2 + (spr * 16/2)); |
| 518 | 515 | } |
| 519 | 516 | } |
| 520 | 517 | } |
| 521 | 518 | |
| 522 | | static void nmk16_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 519 | void nmk16_state::nmk16_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 523 | 520 | { |
| 524 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 525 | 521 | int offs; |
| 526 | 522 | |
| 527 | 523 | for (offs = 0;offs < 0x1000/2;offs += 8) |
| 528 | 524 | { |
| 529 | | nmk16_draw_sprite(state, machine, bitmap, cliprect, priority, state->m_spriteram_old2 + offs); |
| 525 | nmk16_draw_sprite(bitmap, cliprect, priority, m_spriteram_old2 + offs); |
| 530 | 526 | } |
| 531 | 527 | } |
| 532 | 528 | |
| 533 | | static void nmk16_draw_sprites_flipsupported(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 529 | void nmk16_state::nmk16_draw_sprites_flipsupported(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 534 | 530 | { |
| 535 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 536 | 531 | int offs; |
| 537 | 532 | |
| 538 | 533 | for (offs = 0;offs < 0x1000/2;offs += 8) |
| 539 | 534 | { |
| 540 | | if (state->m_spriteram_old2[offs] & 0x0001) |
| 535 | if (m_spriteram_old2[offs] & 0x0001) |
| 541 | 536 | { |
| 542 | | nmk16_draw_sprite_flipsupported(state, machine, bitmap, cliprect, priority, state->m_spriteram_old2 + offs); |
| 537 | nmk16_draw_sprite_flipsupported(bitmap, cliprect, priority, m_spriteram_old2 + offs); |
| 543 | 538 | } |
| 544 | 539 | } |
| 545 | 540 | } |
| r20971 | r20972 | |
| 552 | 547 | |
| 553 | 548 | ***************************************************************************/ |
| 554 | 549 | |
| 555 | | int nmk16_bg_spr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 550 | int nmk16_state::nmk16_bg_spr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 556 | 551 | { |
| 557 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 558 | | state->m_bg_tilemap0->set_scrollx(0,-state->m_videoshift); |
| 552 | m_bg_tilemap0->set_scrollx(0,-m_videoshift); |
| 559 | 553 | |
| 560 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 554 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 561 | 555 | |
| 562 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3); |
| 563 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2); |
| 564 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1); |
| 565 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0); |
| 556 | nmk16_draw_sprites(bitmap,cliprect,3); |
| 557 | nmk16_draw_sprites(bitmap,cliprect,2); |
| 558 | nmk16_draw_sprites(bitmap,cliprect,1); |
| 559 | nmk16_draw_sprites(bitmap,cliprect,0); |
| 566 | 560 | return 0; |
| 567 | 561 | } |
| 568 | 562 | |
| 569 | | int nmk16_bg_fg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 563 | int nmk16_state::nmk16_bg_fg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 570 | 564 | { |
| 571 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 572 | | state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift); |
| 565 | m_tx_tilemap->set_scrollx(0,-m_videoshift); |
| 573 | 566 | |
| 574 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 575 | | state->m_fg_tilemap->draw(bitmap, cliprect, 0,0); |
| 567 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 568 | m_fg_tilemap->draw(bitmap, cliprect, 0,0); |
| 576 | 569 | |
| 577 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3); |
| 578 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2); |
| 579 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1); |
| 580 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0); |
| 570 | nmk16_draw_sprites(bitmap,cliprect,3); |
| 571 | nmk16_draw_sprites(bitmap,cliprect,2); |
| 572 | nmk16_draw_sprites(bitmap,cliprect,1); |
| 573 | nmk16_draw_sprites(bitmap,cliprect,0); |
| 581 | 574 | |
| 582 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 575 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 583 | 576 | return 0; |
| 584 | 577 | } |
| 585 | 578 | |
| 586 | | int nmk16_bg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 579 | int nmk16_state::nmk16_bg_spr_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 587 | 580 | { |
| 588 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 589 | | state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift); |
| 581 | m_tx_tilemap->set_scrollx(0,-m_videoshift); |
| 590 | 582 | |
| 591 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 583 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 592 | 584 | |
| 593 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3); |
| 594 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2); |
| 595 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1); |
| 596 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0); |
| 585 | nmk16_draw_sprites(bitmap,cliprect,3); |
| 586 | nmk16_draw_sprites(bitmap,cliprect,2); |
| 587 | nmk16_draw_sprites(bitmap,cliprect,1); |
| 588 | nmk16_draw_sprites(bitmap,cliprect,0); |
| 597 | 589 | |
| 598 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 590 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 599 | 591 | return 0; |
| 600 | 592 | } |
| 601 | 593 | |
| 602 | | int nmk16_bg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 594 | int nmk16_state::nmk16_bg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 603 | 595 | { |
| 604 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 605 | | state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift); |
| 596 | m_tx_tilemap->set_scrollx(0,-m_videoshift); |
| 606 | 597 | |
| 607 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 598 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 608 | 599 | |
| 609 | | nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,3); |
| 610 | | nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,2); |
| 611 | | nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,1); |
| 612 | | nmk16_draw_sprites_flipsupported(screen.machine(), bitmap,cliprect,0); |
| 600 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,3); |
| 601 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,2); |
| 602 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,1); |
| 603 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,0); |
| 613 | 604 | |
| 614 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 605 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 615 | 606 | return 0; |
| 616 | 607 | } |
| 617 | 608 | |
| 618 | | int nmk16_bioshipbg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 609 | int nmk16_state::nmk16_bioshipbg_sprflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 619 | 610 | { |
| 620 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 621 | | UINT16 *tilerom = (UINT16 *)state->memregion("gfx5")->base(); |
| 622 | | int scrollx=-(state->m_bioship_scroll[1] + state->m_bioship_scroll[0]*256); |
| 623 | | int scrolly=-(state->m_bioship_scroll[3] + state->m_bioship_scroll[2]*256); |
| 611 | UINT16 *tilerom = (UINT16 *)memregion("gfx5")->base(); |
| 612 | int scrollx=-(m_bioship_scroll[1] + m_bioship_scroll[0]*256); |
| 613 | int scrolly=-(m_bioship_scroll[3] + m_bioship_scroll[2]*256); |
| 624 | 614 | |
| 625 | | state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift); |
| 615 | m_tx_tilemap->set_scrollx(0,-m_videoshift); |
| 626 | 616 | |
| 627 | | if (state->m_redraw_bitmap) |
| 617 | if (m_redraw_bitmap) |
| 628 | 618 | { |
| 629 | | int bank = state->m_bioship_background_bank * 0x2000; |
| 619 | int bank = m_bioship_background_bank * 0x2000; |
| 630 | 620 | int sx=0, sy=0, offs; |
| 631 | | state->m_redraw_bitmap=0; |
| 621 | m_redraw_bitmap=0; |
| 632 | 622 | |
| 633 | 623 | /* Draw background from tile rom */ |
| 634 | 624 | for (offs = 0;offs <0x1000;offs++) { |
| r20971 | r20972 | |
| 636 | 626 | int numtile = data&0xfff; |
| 637 | 627 | int color = (data&0xf000)>>12; |
| 638 | 628 | |
| 639 | | drawgfx_opaque(*state->m_background_bitmap,state->m_background_bitmap->cliprect(),screen.machine().gfx[3], |
| 629 | drawgfx_opaque(*m_background_bitmap,m_background_bitmap->cliprect(),screen.machine().gfx[3], |
| 640 | 630 | numtile, |
| 641 | 631 | color, |
| 642 | 632 | 0,0, /* no flip */ |
| r20971 | r20972 | |
| 645 | 635 | data = tilerom[offs+0x1000+bank]; |
| 646 | 636 | numtile = data&0xfff; |
| 647 | 637 | color = (data&0xf000)>>12; |
| 648 | | drawgfx_opaque(*state->m_background_bitmap,state->m_background_bitmap->cliprect(),screen.machine().gfx[3], |
| 638 | drawgfx_opaque(*m_background_bitmap,m_background_bitmap->cliprect(),screen.machine().gfx[3], |
| 649 | 639 | numtile, |
| 650 | 640 | color, |
| 651 | 641 | 0,0, /* no flip */ |
| r20971 | r20972 | |
| 656 | 646 | } |
| 657 | 647 | } |
| 658 | 648 | |
| 659 | | copyscrollbitmap(bitmap,*state->m_background_bitmap,1,&scrollx,1,&scrolly,cliprect); |
| 660 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 649 | copyscrollbitmap(bitmap,*m_background_bitmap,1,&scrollx,1,&scrolly,cliprect); |
| 650 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 661 | 651 | |
| 662 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,3); |
| 663 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,2); |
| 664 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,1); |
| 665 | | nmk16_draw_sprites(screen.machine(), bitmap,cliprect,0); |
| 652 | nmk16_draw_sprites(bitmap,cliprect,3); |
| 653 | nmk16_draw_sprites(bitmap,cliprect,2); |
| 654 | nmk16_draw_sprites(bitmap,cliprect,1); |
| 655 | nmk16_draw_sprites(bitmap,cliprect,0); |
| 666 | 656 | |
| 667 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 657 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 668 | 658 | return 0; |
| 669 | 659 | } |
| 670 | 660 | |
| 671 | | int nmk16_bg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]) |
| 661 | int nmk16_state::nmk16_bg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]) |
| 672 | 662 | { |
| 673 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 674 | | state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift); |
| 663 | m_tx_tilemap->set_scrollx(0,-m_videoshift); |
| 675 | 664 | |
| 676 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 665 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 677 | 666 | |
| 678 | | nmk16_draw_sprites_swap(screen.machine(), bitmap,cliprect, bittbl); |
| 667 | nmk16_draw_sprites_swap(bitmap,cliprect, bittbl); |
| 679 | 668 | |
| 680 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 669 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 681 | 670 | return 0; |
| 682 | 671 | } |
| 683 | 672 | |
| 684 | | int nmk16_bg_sprswapflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]) |
| 673 | int nmk16_state::nmk16_bg_sprswapflip_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]) |
| 685 | 674 | { |
| 686 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 687 | | state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift); |
| 675 | m_tx_tilemap->set_scrollx(0,-m_videoshift); |
| 688 | 676 | |
| 689 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 677 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 690 | 678 | |
| 691 | | nmk16_draw_sprites_swap_flipsupported(screen.machine(), bitmap,cliprect, bittbl); |
| 679 | nmk16_draw_sprites_swap_flipsupported(bitmap,cliprect, bittbl); |
| 692 | 680 | |
| 693 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 681 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 694 | 682 | return 0; |
| 695 | 683 | } |
| 696 | 684 | |
| 697 | | int nmk16_complexbg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]) |
| 685 | int nmk16_state::nmk16_complexbg_sprswap_tx_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int bittbl[8]) |
| 698 | 686 | { |
| 699 | | nmk16_state *state = screen.machine().driver_data<nmk16_state>(); |
| 700 | | state->m_tx_tilemap->set_scrollx(0,-state->m_videoshift); |
| 687 | m_tx_tilemap->set_scrollx(0,-m_videoshift); |
| 701 | 688 | |
| 702 | 689 | // the hardware supports per-scanline X *and* Y scroll which isn't |
| 703 | 690 | // supported by tilemaps so we have to draw the tilemap one line at a time |
| 704 | | if (!state->m_simple_scroll) |
| 691 | if (!m_simple_scroll) |
| 705 | 692 | { |
| 706 | 693 | int i=16; |
| 707 | 694 | int y1; |
| r20971 | r20972 | |
| 709 | 696 | y1 = cliprect.min_y; |
| 710 | 697 | while (y1 <= cliprect.max_y) |
| 711 | 698 | { |
| 712 | | int const yscroll = state->m_gunnail_scrollramy[0] + state->m_gunnail_scrollramy[y1]; |
| 699 | int const yscroll = m_gunnail_scrollramy[0] + m_gunnail_scrollramy[y1]; |
| 713 | 700 | int tilemap_bank_select; |
| 714 | | tilemap_t* bg_tilemap = state->m_bg_tilemap0; |
| 701 | tilemap_t* bg_tilemap = m_bg_tilemap0; |
| 715 | 702 | |
| 716 | 703 | bgclip.min_y = y1; |
| 717 | 704 | bgclip.max_y = y1; |
| 718 | 705 | |
| 719 | 706 | |
| 720 | | tilemap_bank_select = (state->m_gunnail_scrollram[0]&0x3000)>>12; |
| 707 | tilemap_bank_select = (m_gunnail_scrollram[0]&0x3000)>>12; |
| 721 | 708 | switch (tilemap_bank_select) |
| 722 | 709 | { |
| 723 | | case 0: if (state->m_bg_tilemap0) bg_tilemap = state->m_bg_tilemap0; break; |
| 724 | | case 1: if (state->m_bg_tilemap1) bg_tilemap = state->m_bg_tilemap1; break; |
| 725 | | case 2: if (state->m_bg_tilemap2) bg_tilemap = state->m_bg_tilemap2; break; |
| 726 | | case 3: if (state->m_bg_tilemap3) bg_tilemap = state->m_bg_tilemap3; break; |
| 710 | case 0: if (m_bg_tilemap0) bg_tilemap = m_bg_tilemap0; break; |
| 711 | case 1: if (m_bg_tilemap1) bg_tilemap = m_bg_tilemap1; break; |
| 712 | case 2: if (m_bg_tilemap2) bg_tilemap = m_bg_tilemap2; break; |
| 713 | case 3: if (m_bg_tilemap3) bg_tilemap = m_bg_tilemap3; break; |
| 727 | 714 | } |
| 728 | 715 | |
| 729 | 716 | bg_tilemap->set_scroll_rows(512); |
| 730 | 717 | |
| 731 | 718 | bg_tilemap->set_scrolly(0, yscroll); |
| 732 | | bg_tilemap->set_scrollx((i + yscroll) & 0x1ff, state->m_gunnail_scrollram[0] + state->m_gunnail_scrollram[i] - state->m_videoshift); |
| 719 | bg_tilemap->set_scrollx((i + yscroll) & 0x1ff, m_gunnail_scrollram[0] + m_gunnail_scrollram[i] - m_videoshift); |
| 733 | 720 | |
| 734 | 721 | bg_tilemap->draw(bitmap, bgclip, 0,0); |
| 735 | 722 | |
| r20971 | r20972 | |
| 739 | 726 | } |
| 740 | 727 | else |
| 741 | 728 | { |
| 742 | | UINT16 yscroll = ((state->m_gunnail_scrollram[2]&0xff)<<8) | ((state->m_gunnail_scrollram[3]&0xff)<<0); |
| 743 | | UINT16 xscroll = ((state->m_gunnail_scrollram[0]&0xff)<<8) | ((state->m_gunnail_scrollram[1]&0xff)<<0); |
| 729 | UINT16 yscroll = ((m_gunnail_scrollram[2]&0xff)<<8) | ((m_gunnail_scrollram[3]&0xff)<<0); |
| 730 | UINT16 xscroll = ((m_gunnail_scrollram[0]&0xff)<<8) | ((m_gunnail_scrollram[1]&0xff)<<0); |
| 744 | 731 | int tilemap_bank_select; |
| 745 | | tilemap_t* bg_tilemap = state->m_bg_tilemap0; |
| 732 | tilemap_t* bg_tilemap = m_bg_tilemap0; |
| 746 | 733 | |
| 747 | 734 | //popmessage( "scroll %04x, %04x", yscroll,xscroll); |
| 748 | 735 | |
| 749 | 736 | tilemap_bank_select = (xscroll&0x3000)>>12; |
| 750 | 737 | switch (tilemap_bank_select) |
| 751 | 738 | { |
| 752 | | case 0: if (state->m_bg_tilemap0) bg_tilemap = state->m_bg_tilemap0; break; |
| 753 | | case 1: if (state->m_bg_tilemap1) bg_tilemap = state->m_bg_tilemap1; break; |
| 754 | | case 2: if (state->m_bg_tilemap2) bg_tilemap = state->m_bg_tilemap2; break; |
| 755 | | case 3: if (state->m_bg_tilemap3) bg_tilemap = state->m_bg_tilemap3; break; |
| 739 | case 0: if (m_bg_tilemap0) bg_tilemap = m_bg_tilemap0; break; |
| 740 | case 1: if (m_bg_tilemap1) bg_tilemap = m_bg_tilemap1; break; |
| 741 | case 2: if (m_bg_tilemap2) bg_tilemap = m_bg_tilemap2; break; |
| 742 | case 3: if (m_bg_tilemap3) bg_tilemap = m_bg_tilemap3; break; |
| 756 | 743 | } |
| 757 | 744 | |
| 758 | 745 | bg_tilemap->set_scroll_rows(1); |
| 759 | 746 | |
| 760 | 747 | bg_tilemap->set_scrolly(0, yscroll); |
| 761 | | bg_tilemap->set_scrollx(0, xscroll - state->m_videoshift); |
| 748 | bg_tilemap->set_scrollx(0, xscroll - m_videoshift); |
| 762 | 749 | |
| 763 | 750 | bg_tilemap->draw(bitmap, cliprect, 0,0); |
| 764 | 751 | } |
| 765 | 752 | |
| 766 | | nmk16_draw_sprites_swap(screen.machine(), bitmap,cliprect, bittbl); |
| 753 | nmk16_draw_sprites_swap(bitmap,cliprect, bittbl); |
| 767 | 754 | |
| 768 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 755 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 769 | 756 | return 0; |
| 770 | 757 | } |
| 771 | 758 | |
| r20971 | r20972 | |
| 934 | 921 | |
| 935 | 922 | ***************************************************************************/ |
| 936 | 923 | |
| 937 | | static void video_update(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, |
| 924 | void nmk16_state::video_update(bitmap_ind16 &bitmap, const rectangle &cliprect, |
| 938 | 925 | int dsw_flipscreen, // 1 = Horizontal and vertical screen flip are hardwired to 2 dip switches |
| 939 | 926 | int xoffset, int yoffset, // bg_tilemap0 offsets |
| 940 | 927 | int attr_mask // "sprite active" mask |
| 941 | 928 | ) |
| 942 | 929 | { |
| 943 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 944 | | |
| 945 | | |
| 946 | | |
| 947 | 930 | if (dsw_flipscreen) |
| 948 | 931 | { |
| 949 | | state->flip_screen_x_set(~state->ioport("DSW1")->read() & 0x0100); |
| 950 | | state->flip_screen_y_set(~state->ioport("DSW1")->read() & 0x0200); |
| 932 | flip_screen_x_set(~ioport("DSW1")->read() & 0x0100); |
| 933 | flip_screen_y_set(~ioport("DSW1")->read() & 0x0200); |
| 951 | 934 | } |
| 952 | 935 | |
| 953 | 936 | |
| 954 | | state->m_bg_tilemap0->set_scrollx(0, state->m_afega_scroll_0[1] + xoffset); |
| 955 | | state->m_bg_tilemap0->set_scrolly(0, state->m_afega_scroll_0[0] + yoffset); |
| 937 | m_bg_tilemap0->set_scrollx(0, m_afega_scroll_0[1] + xoffset); |
| 938 | m_bg_tilemap0->set_scrolly(0, m_afega_scroll_0[0] + yoffset); |
| 956 | 939 | |
| 957 | | state->m_tx_tilemap->set_scrollx(0, state->m_afega_scroll_1[1]); |
| 958 | | state->m_tx_tilemap->set_scrolly(0, state->m_afega_scroll_1[0]); |
| 940 | m_tx_tilemap->set_scrollx(0, m_afega_scroll_1[1]); |
| 941 | m_tx_tilemap->set_scrolly(0, m_afega_scroll_1[0]); |
| 959 | 942 | |
| 960 | 943 | |
| 961 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 944 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 962 | 945 | |
| 963 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,3); |
| 964 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,2); |
| 965 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,1); |
| 966 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,0); |
| 946 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,3); |
| 947 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,2); |
| 948 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,1); |
| 949 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,0); |
| 967 | 950 | |
| 968 | | state->m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 951 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 969 | 952 | } |
| 970 | 953 | |
| 971 | | static void redhawki_video_update(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 954 | void nmk16_state::redhawki_video_update(bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 972 | 955 | { |
| 973 | | nmk16_state *state = machine.driver_data<nmk16_state>(); |
| 974 | 956 | |
| 957 | m_bg_tilemap0->set_scrollx(0, m_afega_scroll_1[0]&0xff); |
| 958 | m_bg_tilemap0->set_scrolly(0, m_afega_scroll_1[1]&0xff); |
| 975 | 959 | |
| 976 | | state->m_bg_tilemap0->set_scrollx(0, state->m_afega_scroll_1[0]&0xff); |
| 977 | | state->m_bg_tilemap0->set_scrolly(0, state->m_afega_scroll_1[1]&0xff); |
| 960 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 978 | 961 | |
| 979 | | state->m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 980 | | |
| 981 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,3); |
| 982 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,2); |
| 983 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,1); |
| 984 | | nmk16_draw_sprites_flipsupported(machine, bitmap,cliprect,0); |
| 962 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,3); |
| 963 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,2); |
| 964 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,1); |
| 965 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,0); |
| 985 | 966 | } |
| 986 | 967 | |
| 987 | | UINT32 nmk16_state::screen_update_afega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(machine(),bitmap,cliprect, 1, -0x100,+0x000, 0x0001); return 0; } |
| 988 | | UINT32 nmk16_state::screen_update_bubl2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(machine(),bitmap,cliprect, 0, -0x100,+0x000, 0x0001); return 0; } // no flipscreen support, I really would confirmation from the schematics |
| 989 | | UINT32 nmk16_state::screen_update_redhawkb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(machine(),bitmap,cliprect, 0, +0x000,+0x100, 0x0001); return 0; } |
| 990 | | UINT32 nmk16_state::screen_update_redhawki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ redhawki_video_update(machine(),bitmap,cliprect); return 0;} // strange scroll regs |
| 968 | UINT32 nmk16_state::screen_update_afega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { video_update(bitmap,cliprect, 1, -0x100,+0x000, 0x0001); return 0; } |
| 969 | UINT32 nmk16_state::screen_update_bubl2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(bitmap,cliprect, 0, -0x100,+0x000, 0x0001); return 0; } // no flipscreen support, I really would confirmation from the schematics |
| 970 | UINT32 nmk16_state::screen_update_redhawkb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ video_update(bitmap,cliprect, 0, +0x000,+0x100, 0x0001); return 0; } |
| 971 | UINT32 nmk16_state::screen_update_redhawki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ redhawki_video_update(bitmap,cliprect); return 0;} // strange scroll regs |
| 991 | 972 | |
| 992 | 973 | UINT32 nmk16_state::screen_update_firehawk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 993 | 974 | { |
| r20971 | r20972 | |
| 996 | 977 | |
| 997 | 978 | m_bg_tilemap0->draw(bitmap, cliprect, 0,0); |
| 998 | 979 | |
| 999 | | nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,3); |
| 1000 | | nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,2); |
| 1001 | | nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,1); |
| 1002 | | nmk16_draw_sprites_flipsupported(machine(), bitmap,cliprect,0); |
| 980 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,3); |
| 981 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,2); |
| 982 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,1); |
| 983 | nmk16_draw_sprites_flipsupported(bitmap,cliprect,0); |
| 1003 | 984 | |
| 1004 | 985 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 1005 | 986 | return 0; |
trunk/src/mame/video/nycaptor.c
| r20971 | r20972 | |
| 15 | 15 | spot number isn't set to 0 in main menu ; lives - yes |
| 16 | 16 | sprites in main menu req priority 'type' 0 |
| 17 | 17 | */ |
| 18 | | static int nycaptor_spot( running_machine &machine ) |
| 18 | int nycaptor_state::nycaptor_spot( ) |
| 19 | 19 | { |
| 20 | | nycaptor_state *state = machine.driver_data<nycaptor_state>(); |
| 21 | | |
| 22 | | if (state->m_gametype == 0 || state->m_gametype == 2) |
| 23 | | return state->m_sharedram[0x299] ? state->m_sharedram[0x298] : 0; |
| 20 | if (m_gametype == 0 || m_gametype == 2) |
| 21 | return m_sharedram[0x299] ? m_sharedram[0x298] : 0; |
| 24 | 22 | else |
| 25 | 23 | return 0; |
| 26 | 24 | |
| r20971 | r20972 | |
| 44 | 42 | |
| 45 | 43 | tileinfo.group = 0; |
| 46 | 44 | |
| 47 | | if ((!nycaptor_spot(machine())) && (pal == 6)) |
| 45 | if ((!nycaptor_spot()) && (pal == 6)) |
| 48 | 46 | tileinfo.group = 1; |
| 49 | 47 | |
| 50 | | if (((nycaptor_spot(machine()) == 3) && (pal == 8)) || ((nycaptor_spot(machine()) == 1) && (pal == 0xc))) |
| 48 | if (((nycaptor_spot() == 3) && (pal == 8)) || ((nycaptor_spot() == 1) && (pal == 0xc))) |
| 51 | 49 | tileinfo.group = 2; |
| 52 | 50 | |
| 53 | | if ((nycaptor_spot(machine()) == 1) && (tileinfo.category == 2)) |
| 51 | if ((nycaptor_spot() == 1) && (tileinfo.category == 2)) |
| 54 | 52 | tileinfo.group = 3; |
| 55 | 53 | |
| 56 | 54 | #if NYCAPTOR_DEBUG |
| 57 | 55 | if (m_mask & (1 << tileinfo.category)) |
| 58 | 56 | { |
| 59 | | if (nycaptor_spot(machine())) |
| 57 | if (nycaptor_spot()) |
| 60 | 58 | pal = 0xe; |
| 61 | 59 | else |
| 62 | 60 | pal = 4; |
| r20971 | r20972 | |
| 151 | 149 | m_bg_tilemap->set_scrolly(offset, data); |
| 152 | 150 | } |
| 153 | 151 | |
| 154 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri ) |
| 152 | void nycaptor_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri ) |
| 155 | 153 | { |
| 156 | | nycaptor_state *state = machine.driver_data<nycaptor_state>(); |
| 157 | 154 | int i; |
| 158 | 155 | |
| 159 | 156 | for (i = 0; i < 0x20; i++) |
| 160 | 157 | { |
| 161 | | int pr = state->m_spriteram[0x9f - i]; |
| 158 | int pr = m_spriteram[0x9f - i]; |
| 162 | 159 | int offs = (pr & 0x1f) * 4; |
| 163 | 160 | int code, sx, sy, flipx, flipy, pal, priori; |
| 164 | 161 | |
| 165 | | code = state->m_spriteram[offs + 2] + ((state->m_spriteram[offs + 1] & 0x10) << 4);//1 bit wolny = 0x20 |
| 166 | | pal = state->m_spriteram[offs + 1] & 0x0f; |
| 167 | | sx = state->m_spriteram[offs + 3]; |
| 168 | | sy = 240 - state->m_spriteram[offs + 0]; |
| 162 | code = m_spriteram[offs + 2] + ((m_spriteram[offs + 1] & 0x10) << 4);//1 bit wolny = 0x20 |
| 163 | pal = m_spriteram[offs + 1] & 0x0f; |
| 164 | sx = m_spriteram[offs + 3]; |
| 165 | sy = 240 - m_spriteram[offs + 0]; |
| 169 | 166 | priori = (pr & 0xe0) >> 5; |
| 170 | 167 | |
| 171 | 168 | if (priori == pri) |
| 172 | 169 | { |
| 173 | 170 | #if NYCAPTOR_DEBUG |
| 174 | | if (state->m_mask & (1 << (pri + 4))) pal = 0xd; |
| 171 | if (m_mask & (1 << (pri + 4))) pal = 0xd; |
| 175 | 172 | #endif |
| 176 | | flipx = BIT(state->m_spriteram[offs + 1], 6); |
| 177 | | flipy = BIT(state->m_spriteram[offs + 1], 7); |
| 173 | flipx = BIT(m_spriteram[offs + 1], 6); |
| 174 | flipy = BIT(m_spriteram[offs + 1], 7); |
| 178 | 175 | |
| 179 | | drawgfx_transpen(bitmap, cliprect, machine.gfx[1], |
| 176 | drawgfx_transpen(bitmap, cliprect, machine().gfx[1], |
| 180 | 177 | code, |
| 181 | 178 | pal, |
| 182 | 179 | flipx,flipy, |
| 183 | 180 | sx,sy,15); |
| 184 | 181 | |
| 185 | | if (state->m_spriteram[offs + 3] > 240) |
| 182 | if (m_spriteram[offs + 3] > 240) |
| 186 | 183 | { |
| 187 | | sx = (state->m_spriteram[offs + 3] - 256); |
| 188 | | drawgfx_transpen(bitmap, cliprect, machine.gfx[1], |
| 184 | sx = (m_spriteram[offs + 3] - 256); |
| 185 | drawgfx_transpen(bitmap, cliprect, machine().gfx[1], |
| 189 | 186 | code, |
| 190 | 187 | pal, |
| 191 | 188 | flipx,flipy, |
| r20971 | r20972 | |
| 210 | 207 | |
| 211 | 208 | #define mKEY_MASK(x,y) if (machine.input().code_pressed_once(x)) { state->m_mask |= y; state->m_bg_tilemap->mark_all_dirty(); } |
| 212 | 209 | |
| 213 | | static void nycaptor_setmask( running_machine &machine ) |
| 210 | void nycaptor_state::nycaptor_setmask( ) |
| 214 | 211 | { |
| 215 | | nycaptor_state *state = machine.driver_data<nycaptor_state>(); |
| 216 | | |
| 217 | 212 | mKEY_MASK(KEYCODE_Q, 1); /* bg */ |
| 218 | 213 | mKEY_MASK(KEYCODE_W, 2); |
| 219 | 214 | mKEY_MASK(KEYCODE_E, 4); |
| r20971 | r20972 | |
| 228 | 223 | mKEY_MASK(KEYCODE_J, 0x400); |
| 229 | 224 | mKEY_MASK(KEYCODE_K, 0x800); |
| 230 | 225 | |
| 231 | | if (machine.input().code_pressed_once(KEYCODE_Z)){state->m_mask = 0; state->m_bg_tilemap->mark_all_dirty();} /* disable */ |
| 232 | | if (machine.input().code_pressed_once(KEYCODE_X)){state->m_mask |= 0x1000; state->m_bg_tilemap->mark_all_dirty();} /* no layers */ |
| 226 | if (machine().input().code_pressed_once(KEYCODE_Z)){m_mask = 0; m_bg_tilemap->mark_all_dirty();} /* disable */ |
| 227 | if (machine().input().code_pressed_once(KEYCODE_X)){m_mask |= 0x1000; m_bg_tilemap->mark_all_dirty();} /* no layers */ |
| 233 | 228 | } |
| 234 | 229 | #endif |
| 235 | 230 | |
| r20971 | r20972 | |
| 258 | 253 | } |
| 259 | 254 | else |
| 260 | 255 | #endif |
| 261 | | switch (nycaptor_spot(machine()) & 3) |
| 256 | switch (nycaptor_spot() & 3) |
| 262 | 257 | { |
| 263 | 258 | case 0: |
| 264 | 259 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3, 0); |
| 265 | | draw_sprites(machine(), bitmap, cliprect, 6); |
| 260 | draw_sprites(bitmap, cliprect, 6); |
| 266 | 261 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3, 0); |
| 267 | 262 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2, 0); |
| 268 | 263 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2, 0); |
| 269 | 264 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0); |
| 270 | | draw_sprites(machine(), bitmap, cliprect, 3); |
| 265 | draw_sprites(bitmap, cliprect, 3); |
| 271 | 266 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0); |
| 272 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 273 | | draw_sprites(machine(), bitmap, cliprect, 2); |
| 267 | draw_sprites(bitmap, cliprect, 0); |
| 268 | draw_sprites(bitmap, cliprect, 2); |
| 274 | 269 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0); |
| 275 | | draw_sprites(machine(), bitmap, cliprect, 1); |
| 270 | draw_sprites(bitmap, cliprect, 1); |
| 276 | 271 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0); |
| 277 | 272 | break; |
| 278 | 273 | |
| 279 | 274 | case 1: |
| 280 | 275 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3, 0); |
| 281 | | draw_sprites(machine(), bitmap, cliprect, 3); |
| 276 | draw_sprites(bitmap, cliprect, 3); |
| 282 | 277 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3, 0); |
| 283 | | draw_sprites(machine(), bitmap, cliprect, 2); |
| 278 | draw_sprites(bitmap, cliprect, 2); |
| 284 | 279 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2, 0); |
| 285 | 280 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0); |
| 286 | | draw_sprites(machine(), bitmap, cliprect, 1); |
| 281 | draw_sprites(bitmap, cliprect, 1); |
| 287 | 282 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0); |
| 288 | 283 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2, 0); |
| 289 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 284 | draw_sprites(bitmap, cliprect, 0); |
| 290 | 285 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0); |
| 291 | 286 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0); |
| 292 | 287 | break; |
| r20971 | r20972 | |
| 295 | 290 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 3, 0); |
| 296 | 291 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 3, 0); |
| 297 | 292 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0); |
| 298 | | draw_sprites(machine(), bitmap, cliprect, 1); |
| 293 | draw_sprites(bitmap, cliprect, 1); |
| 299 | 294 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0); |
| 300 | 295 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 2, 0); |
| 301 | 296 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 2, 0); |
| 302 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 297 | draw_sprites(bitmap, cliprect, 0); |
| 303 | 298 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0); |
| 304 | 299 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0); |
| 305 | 300 | break; |
| 306 | 301 | |
| 307 | 302 | case 3: |
| 308 | 303 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 1, 0); |
| 309 | | draw_sprites(machine(), bitmap, cliprect, 1); |
| 304 | draw_sprites(bitmap, cliprect, 1); |
| 310 | 305 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 1, 0); |
| 311 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 306 | draw_sprites(bitmap, cliprect, 0); |
| 312 | 307 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1 | 0, 0); |
| 313 | 308 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0 | 0, 0); |
| 314 | 309 | break; |
trunk/src/mame/video/nbmj9195.c
| r20971 | r20972 | |
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "includes/nbmj9195.h" |
| 12 | 12 | |
| 13 | | |
| 14 | | static void nbmj9195_vramflip(running_machine &machine, int vram); |
| 15 | | static void nbmj9195_gfxdraw(running_machine &machine, int vram); |
| 16 | | |
| 17 | | |
| 18 | 13 | /****************************************************************************** |
| 19 | 14 | |
| 20 | 15 | |
| r20971 | r20972 | |
| 68 | 63 | |
| 69 | 64 | |
| 70 | 65 | ******************************************************************************/ |
| 71 | | static int nbmj9195_blitter_r(address_space &space, int offset, int vram) |
| 66 | int nbmj9195_state::nbmj9195_blitter_r(int offset, int vram) |
| 72 | 67 | { |
| 73 | | nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>(); |
| 74 | 68 | int ret; |
| 75 | | UINT8 *GFXROM = state->memregion("gfx1")->base(); |
| 69 | UINT8 *GFXROM = memregion("gfx1")->base(); |
| 76 | 70 | |
| 77 | 71 | switch (offset) |
| 78 | 72 | { |
| 79 | | case 0x00: ret = 0xfe | ((state->m_nb19010_busyflag & 0x01) ^ 0x01); break; // NB19010 Busy Flag |
| 80 | | case 0x01: ret = GFXROM[state->m_blitter_src_addr[vram]]; break; // NB19010 GFX-ROM Read |
| 73 | case 0x00: ret = 0xfe | ((m_nb19010_busyflag & 0x01) ^ 0x01); break; // NB19010 Busy Flag |
| 74 | case 0x01: ret = GFXROM[m_blitter_src_addr[vram]]; break; // NB19010 GFX-ROM Read |
| 81 | 75 | default: ret = 0xff; break; |
| 82 | 76 | } |
| 83 | 77 | |
| 84 | 78 | return ret; |
| 85 | 79 | } |
| 86 | 80 | |
| 87 | | static void nbmj9195_blitter_w(address_space &space, int offset, int data, int vram) |
| 81 | void nbmj9195_state::nbmj9195_blitter_w(int offset, int data, int vram) |
| 88 | 82 | { |
| 89 | | nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>(); |
| 90 | 83 | int new_line; |
| 91 | 84 | |
| 92 | 85 | switch (offset) |
| 93 | 86 | { |
| 94 | | case 0x00: state->m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0; |
| 95 | | state->m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0; |
| 96 | | state->m_clutmode[vram] = (data & 0x04) ? 1 : 0; |
| 87 | case 0x00: m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0; |
| 88 | m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0; |
| 89 | m_clutmode[vram] = (data & 0x04) ? 1 : 0; |
| 97 | 90 | // if (data & 0x08) popmessage("Unknown GFX Flag!! (0x08)"); |
| 98 | | state->m_transparency[vram] = (data & 0x10) ? 1 : 0; |
| 91 | m_transparency[vram] = (data & 0x10) ? 1 : 0; |
| 99 | 92 | // if (data & 0x20) popmessage("Unknown GFX Flag!! (0x20)"); |
| 100 | | state->m_flipscreen[vram] = (data & 0x40) ? 0 : 1; |
| 101 | | state->m_dispflag[vram] = (data & 0x80) ? 1 : 0; |
| 102 | | nbmj9195_vramflip(space.machine(), vram); |
| 93 | m_flipscreen[vram] = (data & 0x40) ? 0 : 1; |
| 94 | m_dispflag[vram] = (data & 0x80) ? 1 : 0; |
| 95 | nbmj9195_vramflip(vram); |
| 103 | 96 | break; |
| 104 | | case 0x01: state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x0100) | data; break; |
| 105 | | case 0x02: state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100); |
| 106 | | new_line = space.machine().primary_screen->vpos(); |
| 107 | | if (state->m_flipscreen[vram]) |
| 97 | case 0x01: m_scrollx[vram] = (m_scrollx[vram] & 0x0100) | data; break; |
| 98 | case 0x02: m_scrollx[vram] = (m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100); |
| 99 | new_line = machine().primary_screen->vpos(); |
| 100 | if (m_flipscreen[vram]) |
| 108 | 101 | { |
| 109 | | for ( ; state->m_scanline[vram] < new_line; state->m_scanline[vram]++) |
| 110 | | state->m_scrollx_raster[vram][state->m_scanline[vram]] = (((-state->m_scrollx[vram]) - 0x4e) & 0x1ff) << 1; |
| 102 | for ( ; m_scanline[vram] < new_line; m_scanline[vram]++) |
| 103 | m_scrollx_raster[vram][m_scanline[vram]] = (((-m_scrollx[vram]) - 0x4e) & 0x1ff) << 1; |
| 111 | 104 | } |
| 112 | 105 | else |
| 113 | 106 | { |
| 114 | | for ( ; state->m_scanline[vram] < new_line; state->m_scanline[vram]++) |
| 115 | | state->m_scrollx_raster[vram][(state->m_scanline[vram] ^ 0x1ff)] = (((-state->m_scrollx[vram]) - 0x4e) & 0x1ff) << 1; |
| 107 | for ( ; m_scanline[vram] < new_line; m_scanline[vram]++) |
| 108 | m_scrollx_raster[vram][(m_scanline[vram] ^ 0x1ff)] = (((-m_scrollx[vram]) - 0x4e) & 0x1ff) << 1; |
| 116 | 109 | } |
| 117 | 110 | break; |
| 118 | | case 0x03: state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x0100) | data; break; |
| 119 | | case 0x04: state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break; |
| 120 | | case 0x05: state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xffff00) | data; break; |
| 121 | | case 0x06: state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break; |
| 122 | | case 0x07: state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break; |
| 123 | | case 0x08: state->m_blitter_sizex[vram] = data; break; |
| 124 | | case 0x09: state->m_blitter_sizey[vram] = data; break; |
| 125 | | case 0x0a: state->m_blitter_destx[vram] = (state->m_blitter_destx[vram] & 0xff00) | data; break; |
| 126 | | case 0x0b: state->m_blitter_destx[vram] = (state->m_blitter_destx[vram] & 0x00ff) | (data << 8); break; |
| 127 | | case 0x0c: state->m_blitter_desty[vram] = (state->m_blitter_desty[vram] & 0xff00) | data; break; |
| 128 | | case 0x0d: state->m_blitter_desty[vram] = (state->m_blitter_desty[vram] & 0x00ff) | (data << 8); |
| 129 | | nbmj9195_gfxdraw(space.machine(), vram); |
| 111 | case 0x03: m_scrolly[vram] = (m_scrolly[vram] & 0x0100) | data; break; |
| 112 | case 0x04: m_scrolly[vram] = (m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break; |
| 113 | case 0x05: m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xffff00) | data; break; |
| 114 | case 0x06: m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break; |
| 115 | case 0x07: m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break; |
| 116 | case 0x08: m_blitter_sizex[vram] = data; break; |
| 117 | case 0x09: m_blitter_sizey[vram] = data; break; |
| 118 | case 0x0a: m_blitter_destx[vram] = (m_blitter_destx[vram] & 0xff00) | data; break; |
| 119 | case 0x0b: m_blitter_destx[vram] = (m_blitter_destx[vram] & 0x00ff) | (data << 8); break; |
| 120 | case 0x0c: m_blitter_desty[vram] = (m_blitter_desty[vram] & 0xff00) | data; break; |
| 121 | case 0x0d: m_blitter_desty[vram] = (m_blitter_desty[vram] & 0x00ff) | (data << 8); |
| 122 | nbmj9195_gfxdraw(vram); |
| 130 | 123 | break; |
| 131 | 124 | default: break; |
| 132 | 125 | } |
| 133 | 126 | } |
| 134 | 127 | |
| 135 | | void nbmj9195_clutsel_w(address_space &space, int data) |
| 128 | void nbmj9195_state::nbmj9195_clutsel_w(int data) |
| 136 | 129 | { |
| 137 | | nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>(); |
| 138 | | state->m_clutsel = data; |
| 130 | m_clutsel = data; |
| 139 | 131 | } |
| 140 | 132 | |
| 141 | | static void nbmj9195_clut_w(address_space &space, int offset, int data, int vram) |
| 133 | void nbmj9195_state::nbmj9195_clut_w(int offset, int data, int vram) |
| 142 | 134 | { |
| 143 | | nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>(); |
| 144 | | state->m_clut[vram][((state->m_clutsel & 0xff) * 0x10) + (offset & 0x0f)] = data; |
| 135 | m_clut[vram][((m_clutsel & 0xff) * 0x10) + (offset & 0x0f)] = data; |
| 145 | 136 | } |
| 146 | 137 | |
| 147 | | void nbmj9195_gfxflag2_w(address_space &space, int data) |
| 138 | void nbmj9195_state::nbmj9195_gfxflag2_w(int data) |
| 148 | 139 | { |
| 149 | | nbmj9195_state *state = space.machine().driver_data<nbmj9195_state>(); |
| 150 | | state->m_gfxflag2 = data; |
| 140 | m_gfxflag2 = data; |
| 151 | 141 | } |
| 152 | 142 | |
| 153 | 143 | /****************************************************************************** |
| 154 | 144 | |
| 155 | 145 | |
| 156 | 146 | ******************************************************************************/ |
| 157 | | static void nbmj9195_vramflip(running_machine &machine, int vram) |
| 147 | void nbmj9195_state::nbmj9195_vramflip(int vram) |
| 158 | 148 | { |
| 159 | | nbmj9195_state *state = machine.driver_data<nbmj9195_state>(); |
| 160 | 149 | int x, y; |
| 161 | 150 | UINT16 color1, color2; |
| 162 | | int width = machine.primary_screen->width(); |
| 163 | | int height = machine.primary_screen->height(); |
| 151 | int width = machine().primary_screen->width(); |
| 152 | int height = machine().primary_screen->height(); |
| 164 | 153 | |
| 165 | | if (state->m_flipscreen[vram] == state->m_flipscreen_old[vram]) return; |
| 154 | if (m_flipscreen[vram] == m_flipscreen_old[vram]) return; |
| 166 | 155 | |
| 167 | 156 | for (y = 0; y < (height / 2); y++) |
| 168 | 157 | { |
| 169 | 158 | for (x = 0; x < width; x++) |
| 170 | 159 | { |
| 171 | | color1 = state->m_videoram[vram][(y * width) + x]; |
| 172 | | color2 = state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 173 | | state->m_videoram[vram][(y * width) + x] = color2; |
| 174 | | state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 160 | color1 = m_videoram[vram][(y * width) + x]; |
| 161 | color2 = m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 162 | m_videoram[vram][(y * width) + x] = color2; |
| 163 | m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 175 | 164 | } |
| 176 | 165 | } |
| 177 | 166 | |
| 178 | | if (state->m_gfxdraw_mode == 2) |
| 167 | if (m_gfxdraw_mode == 2) |
| 179 | 168 | { |
| 180 | 169 | for (y = 0; y < (height / 2); y++) |
| 181 | 170 | { |
| 182 | 171 | for (x = 0; x < width; x++) |
| 183 | 172 | { |
| 184 | | color1 = state->m_videoworkram[vram][(y * width) + x]; |
| 185 | | color2 = state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 186 | | state->m_videoworkram[vram][(y * width) + x] = color2; |
| 187 | | state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 173 | color1 = m_videoworkram[vram][(y * width) + x]; |
| 174 | color2 = m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 175 | m_videoworkram[vram][(y * width) + x] = color2; |
| 176 | m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 188 | 177 | } |
| 189 | 178 | } |
| 190 | 179 | } |
| 191 | 180 | |
| 192 | | state->m_flipscreen_old[vram] = state->m_flipscreen[vram]; |
| 193 | | state->m_screen_refresh = 1; |
| 181 | m_flipscreen_old[vram] = m_flipscreen[vram]; |
| 182 | m_screen_refresh = 1; |
| 194 | 183 | } |
| 195 | 184 | |
| 196 | | static void update_pixel(running_machine &machine, int vram, int x, int y) |
| 185 | void nbmj9195_state::update_pixel(int vram, int x, int y) |
| 197 | 186 | { |
| 198 | | nbmj9195_state *state = machine.driver_data<nbmj9195_state>(); |
| 199 | | UINT16 color = state->m_videoram[vram][(y * machine.primary_screen->width()) + x]; |
| 200 | | state->m_tmpbitmap[vram].pix16(y, x) = color; |
| 187 | UINT16 color = m_videoram[vram][(y * machine().primary_screen->width()) + x]; |
| 188 | m_tmpbitmap[vram].pix16(y, x) = color; |
| 201 | 189 | } |
| 202 | 190 | |
| 203 | 191 | TIMER_CALLBACK_MEMBER(nbmj9195_state::blitter_timer_callback) |
| r20971 | r20972 | |
| 205 | 193 | m_nb19010_busyflag = 1; |
| 206 | 194 | } |
| 207 | 195 | |
| 208 | | static void nbmj9195_gfxdraw(running_machine &machine, int vram) |
| 196 | void nbmj9195_state::nbmj9195_gfxdraw(int vram) |
| 209 | 197 | { |
| 210 | | nbmj9195_state *state = machine.driver_data<nbmj9195_state>(); |
| 211 | | UINT8 *GFX = state->memregion("gfx1")->base(); |
| 212 | | int width = machine.primary_screen->width(); |
| 198 | UINT8 *GFX = memregion("gfx1")->base(); |
| 199 | int width = machine().primary_screen->width(); |
| 213 | 200 | |
| 214 | 201 | int x, y; |
| 215 | 202 | int dx1, dx2, dy; |
| r20971 | r20972 | |
| 220 | 207 | UINT16 color, color1, color2; |
| 221 | 208 | int gfxaddr, gfxlen; |
| 222 | 209 | |
| 223 | | state->m_nb19010_busyctr = 0; |
| 210 | m_nb19010_busyctr = 0; |
| 224 | 211 | |
| 225 | | if ((state->m_gfxdraw_mode == 2) && (state->m_clutmode[vram])) |
| 212 | if ((m_gfxdraw_mode == 2) && (m_clutmode[vram])) |
| 226 | 213 | { |
| 227 | 214 | // NB22090 clut256 mode |
| 228 | | state->m_blitter_sizex[vram] = GFX[((state->m_blitter_src_addr[vram] + 0) & 0x00ffffff)]; |
| 229 | | state->m_blitter_sizey[vram] = GFX[((state->m_blitter_src_addr[vram] + 1) & 0x00ffffff)]; |
| 215 | m_blitter_sizex[vram] = GFX[((m_blitter_src_addr[vram] + 0) & 0x00ffffff)]; |
| 216 | m_blitter_sizey[vram] = GFX[((m_blitter_src_addr[vram] + 1) & 0x00ffffff)]; |
| 230 | 217 | } |
| 231 | 218 | |
| 232 | | if (state->m_blitter_direction_x[vram]) |
| 219 | if (m_blitter_direction_x[vram]) |
| 233 | 220 | { |
| 234 | | startx = state->m_blitter_destx[vram]; |
| 235 | | sizex = state->m_blitter_sizex[vram]; |
| 221 | startx = m_blitter_destx[vram]; |
| 222 | sizex = m_blitter_sizex[vram]; |
| 236 | 223 | skipx = 1; |
| 237 | 224 | } |
| 238 | 225 | else |
| 239 | 226 | { |
| 240 | | startx = state->m_blitter_destx[vram] + state->m_blitter_sizex[vram]; |
| 241 | | sizex = state->m_blitter_sizex[vram]; |
| 227 | startx = m_blitter_destx[vram] + m_blitter_sizex[vram]; |
| 228 | sizex = m_blitter_sizex[vram]; |
| 242 | 229 | skipx = -1; |
| 243 | 230 | } |
| 244 | 231 | |
| 245 | | if (state->m_blitter_direction_y[vram]) |
| 232 | if (m_blitter_direction_y[vram]) |
| 246 | 233 | { |
| 247 | | starty = state->m_blitter_desty[vram]; |
| 248 | | sizey = state->m_blitter_sizey[vram]; |
| 234 | starty = m_blitter_desty[vram]; |
| 235 | sizey = m_blitter_sizey[vram]; |
| 249 | 236 | skipy = 1; |
| 250 | 237 | } |
| 251 | 238 | else |
| 252 | 239 | { |
| 253 | | starty = state->m_blitter_desty[vram] + state->m_blitter_sizey[vram]; |
| 254 | | sizey = state->m_blitter_sizey[vram]; |
| 240 | starty = m_blitter_desty[vram] + m_blitter_sizey[vram]; |
| 241 | sizey = m_blitter_sizey[vram]; |
| 255 | 242 | skipy = -1; |
| 256 | 243 | } |
| 257 | 244 | |
| 258 | | gfxlen = machine.root_device().memregion("gfx1")->bytes(); |
| 259 | | gfxaddr = ((state->m_blitter_src_addr[vram] + 2) & 0x00ffffff); |
| 245 | gfxlen = machine().root_device().memregion("gfx1")->bytes(); |
| 246 | gfxaddr = ((m_blitter_src_addr[vram] + 2) & 0x00ffffff); |
| 260 | 247 | |
| 261 | 248 | for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) |
| 262 | 249 | { |
| r20971 | r20972 | |
| 277 | 264 | dx2 = (2 * x + 1) & 0x3ff; |
| 278 | 265 | dy = y & 0x1ff; |
| 279 | 266 | |
| 280 | | if (!state->m_flipscreen[vram]) |
| 267 | if (!m_flipscreen[vram]) |
| 281 | 268 | { |
| 282 | 269 | dx1 ^= 0x3ff; |
| 283 | 270 | dx2 ^= 0x3ff; |
| 284 | 271 | dy ^= 0x1ff; |
| 285 | 272 | } |
| 286 | 273 | |
| 287 | | if (state->m_blitter_direction_x[vram]) |
| 274 | if (m_blitter_direction_x[vram]) |
| 288 | 275 | { |
| 289 | 276 | // flip |
| 290 | 277 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 297 | 284 | color2 = (color & 0x0f) >> 0; |
| 298 | 285 | } |
| 299 | 286 | |
| 300 | | if ((state->m_gfxdraw_mode == 2) && (state->m_clutmode[vram])) |
| 287 | if ((m_gfxdraw_mode == 2) && (m_clutmode[vram])) |
| 301 | 288 | { |
| 302 | 289 | // clut256 mode |
| 303 | 290 | |
| 304 | | if (state->m_gfxflag2 & 0xc0) |
| 291 | if (m_gfxflag2 & 0xc0) |
| 305 | 292 | { |
| 306 | 293 | // clut256 mode 1st(low) |
| 307 | | state->m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0; |
| 308 | | state->m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f; |
| 309 | | state->m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0; |
| 310 | | state->m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f; |
| 294 | m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0; |
| 295 | m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f; |
| 296 | m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0; |
| 297 | m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f; |
| 311 | 298 | |
| 312 | 299 | continue; |
| 313 | 300 | } |
| 314 | 301 | else |
| 315 | 302 | { |
| 316 | 303 | // clut256 mode 2nd(high) |
| 317 | | state->m_videoworkram[vram][(dy * width) + dx1] &= 0x000f; |
| 318 | | state->m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4; |
| 319 | | state->m_videoworkram[vram][(dy * width) + dx2] &= 0x000f; |
| 320 | | state->m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4; |
| 304 | m_videoworkram[vram][(dy * width) + dx1] &= 0x000f; |
| 305 | m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4; |
| 306 | m_videoworkram[vram][(dy * width) + dx2] &= 0x000f; |
| 307 | m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4; |
| 321 | 308 | |
| 322 | | state->m_videoworkram[vram][(dy * width) + dx1] += state->m_clut[vram][(state->m_clutsel * 0x10)]; |
| 323 | | state->m_videoworkram[vram][(dy * width) + dx2] += state->m_clut[vram][(state->m_clutsel * 0x10)]; |
| 309 | m_videoworkram[vram][(dy * width) + dx1] += m_clut[vram][(m_clutsel * 0x10)]; |
| 310 | m_videoworkram[vram][(dy * width) + dx2] += m_clut[vram][(m_clutsel * 0x10)]; |
| 324 | 311 | } |
| 325 | 312 | |
| 326 | | color1 = state->m_videoworkram[vram][(dy * width) + dx1]; |
| 327 | | color2 = state->m_videoworkram[vram][(dy * width) + dx2]; |
| 313 | color1 = m_videoworkram[vram][(dy * width) + dx1]; |
| 314 | color2 = m_videoworkram[vram][(dy * width) + dx2]; |
| 328 | 315 | } |
| 329 | 316 | else |
| 330 | 317 | { |
| 331 | 318 | // clut16 mode |
| 332 | | color1 = state->m_clut[vram][(state->m_clutsel * 0x10) + color1]; |
| 333 | | color2 = state->m_clut[vram][(state->m_clutsel * 0x10) + color2]; |
| 319 | color1 = m_clut[vram][(m_clutsel * 0x10) + color1]; |
| 320 | color2 = m_clut[vram][(m_clutsel * 0x10) + color2]; |
| 334 | 321 | } |
| 335 | 322 | |
| 336 | | if (state->m_gfxdraw_mode == 2) |
| 323 | if (m_gfxdraw_mode == 2) |
| 337 | 324 | { |
| 338 | 325 | color1 |= (0x0100 * vram); |
| 339 | 326 | color2 |= (0x0100 * vram); |
| 340 | 327 | } |
| 341 | 328 | |
| 342 | | if (((color1 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram])) |
| 329 | if (((color1 & 0x00ff) != 0x00ff) || (!m_transparency[vram])) |
| 343 | 330 | { |
| 344 | | state->m_videoram[vram][(dy * width) + dx1] = color1; |
| 345 | | update_pixel(machine, vram, dx1, dy); |
| 331 | m_videoram[vram][(dy * width) + dx1] = color1; |
| 332 | update_pixel(vram, dx1, dy); |
| 346 | 333 | } |
| 347 | | if (((color2 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram])) |
| 334 | if (((color2 & 0x00ff) != 0x00ff) || (!m_transparency[vram])) |
| 348 | 335 | { |
| 349 | | state->m_videoram[vram][(dy * width) + dx2] = color2; |
| 350 | | update_pixel(machine, vram, dx2, dy); |
| 336 | m_videoram[vram][(dy * width) + dx2] = color2; |
| 337 | update_pixel(vram, dx2, dy); |
| 351 | 338 | } |
| 352 | 339 | |
| 353 | | state->m_nb19010_busyctr++; |
| 340 | m_nb19010_busyctr++; |
| 354 | 341 | } |
| 355 | 342 | } |
| 356 | 343 | |
| 357 | | if ((state->m_gfxdraw_mode == 2) && (state->m_clutmode[vram])) |
| 344 | if ((m_gfxdraw_mode == 2) && (m_clutmode[vram])) |
| 358 | 345 | { |
| 359 | 346 | // NB22090 clut256 mode |
| 360 | | state->m_blitter_src_addr[vram] = gfxaddr; |
| 347 | m_blitter_src_addr[vram] = gfxaddr; |
| 361 | 348 | } |
| 362 | 349 | |
| 363 | | state->m_nb19010_busyflag = 0; |
| 350 | m_nb19010_busyflag = 0; |
| 364 | 351 | |
| 365 | 352 | /* 1650ns per count */ |
| 366 | | machine.scheduler().timer_set(attotime::from_nsec(state->m_nb19010_busyctr * 1650), timer_expired_delegate(FUNC(nbmj9195_state::blitter_timer_callback),state)); |
| 353 | machine().scheduler().timer_set(attotime::from_nsec(m_nb19010_busyctr * 1650), timer_expired_delegate(FUNC(nbmj9195_state::blitter_timer_callback),this)); |
| 367 | 354 | } |
| 368 | 355 | |
| 369 | 356 | /****************************************************************************** |
| 370 | 357 | |
| 371 | 358 | |
| 372 | 359 | ******************************************************************************/ |
| 373 | | WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_w){ nbmj9195_blitter_w(space, offset, data, 0); } |
| 374 | | WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_w){ nbmj9195_blitter_w(space, offset, data, 1); } |
| 360 | WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_w){ nbmj9195_blitter_w(offset, data, 0); } |
| 361 | WRITE8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_w){ nbmj9195_blitter_w(offset, data, 1); } |
| 375 | 362 | |
| 376 | | READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_r){ return nbmj9195_blitter_r(space, offset, 0); } |
| 377 | | READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_r){ return nbmj9195_blitter_r(space, offset, 1); } |
| 363 | READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_0_r){ return nbmj9195_blitter_r(offset, 0); } |
| 364 | READ8_MEMBER(nbmj9195_state::nbmj9195_blitter_1_r){ return nbmj9195_blitter_r(offset, 1); } |
| 378 | 365 | |
| 379 | | WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_0_w){ nbmj9195_clut_w(space, offset, data, 0); } |
| 380 | | WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_1_w){ nbmj9195_clut_w(space, offset, data, 1); } |
| 366 | WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_0_w){ nbmj9195_clut_w(offset, data, 0); } |
| 367 | WRITE8_MEMBER(nbmj9195_state::nbmj9195_clut_1_w){ nbmj9195_clut_w(offset, data, 1); } |
| 381 | 368 | |
| 382 | 369 | /****************************************************************************** |
| 383 | 370 | |
| r20971 | r20972 | |
| 453 | 440 | for (y = 0; y < height; y++) |
| 454 | 441 | for (x = 0; x < width; x++) |
| 455 | 442 | { |
| 456 | | update_pixel(machine(), 0, x, y); |
| 443 | update_pixel(0, x, y); |
| 457 | 444 | |
| 458 | 445 | if (m_gfxdraw_mode) |
| 459 | | update_pixel(machine(), 1, x, y); |
| 446 | update_pixel(1, x, y); |
| 460 | 447 | } |
| 461 | 448 | } |
| 462 | 449 | |
trunk/src/mame/video/niyanpai.c
| r20971 | r20972 | |
| 9 | 9 | #include "emu.h" |
| 10 | 10 | #include "includes/niyanpai.h" |
| 11 | 11 | |
| 12 | | |
| 13 | | static void niyanpai_vramflip(running_machine &machine, int vram); |
| 14 | | static void niyanpai_gfxdraw(running_machine &machine, int vram); |
| 15 | | |
| 16 | | |
| 17 | 12 | /****************************************************************************** |
| 18 | 13 | |
| 19 | 14 | |
| r20971 | r20972 | |
| 62 | 57 | |
| 63 | 58 | |
| 64 | 59 | ******************************************************************************/ |
| 65 | | static int niyanpai_blitter_r(running_machine &machine, int vram, int offset) |
| 60 | int niyanpai_state::niyanpai_blitter_r(int vram, int offset) |
| 66 | 61 | { |
| 67 | | niyanpai_state *state = machine.driver_data<niyanpai_state>(); |
| 68 | 62 | int ret; |
| 69 | | UINT8 *GFXROM = state->memregion("gfx1")->base(); |
| 63 | UINT8 *GFXROM = memregion("gfx1")->base(); |
| 70 | 64 | |
| 71 | 65 | switch (offset) |
| 72 | 66 | { |
| 73 | | case 0x00: ret = 0xfe | ((state->m_nb19010_busyflag & 0x01) ^ 0x01); break; // NB19010 Busy Flag |
| 74 | | case 0x01: ret = GFXROM[state->m_blitter_src_addr[vram]]; break; // NB19010 GFX-ROM Read |
| 67 | case 0x00: ret = 0xfe | ((m_nb19010_busyflag & 0x01) ^ 0x01); break; // NB19010 Busy Flag |
| 68 | case 0x01: ret = GFXROM[m_blitter_src_addr[vram]]; break; // NB19010 GFX-ROM Read |
| 75 | 69 | default: ret = 0xff; break; |
| 76 | 70 | } |
| 77 | 71 | |
| 78 | 72 | return ret; |
| 79 | 73 | } |
| 80 | 74 | |
| 81 | | static void niyanpai_blitter_w(running_machine &machine, int vram, int offset, int data) |
| 75 | void niyanpai_state::niyanpai_blitter_w(int vram, int offset, int data) |
| 82 | 76 | { |
| 83 | | niyanpai_state *state = machine.driver_data<niyanpai_state>(); |
| 84 | 77 | switch (offset) |
| 85 | 78 | { |
| 86 | | case 0x00: state->m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0; |
| 87 | | state->m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0; |
| 88 | | state->m_clutmode[vram] = (data & 0x04) ? 1 : 0; |
| 79 | case 0x00: m_blitter_direction_x[vram] = (data & 0x01) ? 1 : 0; |
| 80 | m_blitter_direction_y[vram] = (data & 0x02) ? 1 : 0; |
| 81 | m_clutmode[vram] = (data & 0x04) ? 1 : 0; |
| 89 | 82 | // if (data & 0x08) popmessage("Unknown GFX Flag!! (0x08)"); |
| 90 | | state->m_transparency[vram] = (data & 0x10) ? 1 : 0; |
| 83 | m_transparency[vram] = (data & 0x10) ? 1 : 0; |
| 91 | 84 | // if (data & 0x20) popmessage("Unknown GFX Flag!! (0x20)"); |
| 92 | | state->m_flipscreen[vram] = (data & 0x40) ? 0 : 1; |
| 93 | | state->m_dispflag[vram] = (data & 0x80) ? 1 : 0; |
| 94 | | niyanpai_vramflip(machine, vram); |
| 85 | m_flipscreen[vram] = (data & 0x40) ? 0 : 1; |
| 86 | m_dispflag[vram] = (data & 0x80) ? 1 : 0; |
| 87 | niyanpai_vramflip(vram); |
| 95 | 88 | break; |
| 96 | | case 0x01: state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x0100) | data; break; |
| 97 | | case 0x02: state->m_scrollx[vram] = (state->m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100); break; |
| 98 | | case 0x03: state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x0100) | data; break; |
| 99 | | case 0x04: state->m_scrolly[vram] = (state->m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break; |
| 100 | | case 0x05: state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xffff00) | data; break; |
| 101 | | case 0x06: state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break; |
| 102 | | case 0x07: state->m_blitter_src_addr[vram] = (state->m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break; |
| 103 | | case 0x08: state->m_blitter_sizex[vram] = data; break; |
| 104 | | case 0x09: state->m_blitter_sizey[vram] = data; break; |
| 105 | | case 0x0a: state->m_blitter_destx[vram] = (state->m_blitter_destx[vram] & 0xff00) | data; break; |
| 106 | | case 0x0b: state->m_blitter_destx[vram] = (state->m_blitter_destx[vram] & 0x00ff) | (data << 8); break; |
| 107 | | case 0x0c: state->m_blitter_desty[vram] = (state->m_blitter_desty[vram] & 0xff00) | data; break; |
| 108 | | case 0x0d: state->m_blitter_desty[vram] = (state->m_blitter_desty[vram] & 0x00ff) | (data << 8); |
| 109 | | niyanpai_gfxdraw(machine, vram); |
| 89 | case 0x01: m_scrollx[vram] = (m_scrollx[vram] & 0x0100) | data; break; |
| 90 | case 0x02: m_scrollx[vram] = (m_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100); break; |
| 91 | case 0x03: m_scrolly[vram] = (m_scrolly[vram] & 0x0100) | data; break; |
| 92 | case 0x04: m_scrolly[vram] = (m_scrolly[vram] & 0x00ff) | ((data << 8) & 0x0100); break; |
| 93 | case 0x05: m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xffff00) | data; break; |
| 94 | case 0x06: m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0xff00ff) | (data << 8); break; |
| 95 | case 0x07: m_blitter_src_addr[vram] = (m_blitter_src_addr[vram] & 0x00ffff) | (data << 16); break; |
| 96 | case 0x08: m_blitter_sizex[vram] = data; break; |
| 97 | case 0x09: m_blitter_sizey[vram] = data; break; |
| 98 | case 0x0a: m_blitter_destx[vram] = (m_blitter_destx[vram] & 0xff00) | data; break; |
| 99 | case 0x0b: m_blitter_destx[vram] = (m_blitter_destx[vram] & 0x00ff) | (data << 8); break; |
| 100 | case 0x0c: m_blitter_desty[vram] = (m_blitter_desty[vram] & 0xff00) | data; break; |
| 101 | case 0x0d: m_blitter_desty[vram] = (m_blitter_desty[vram] & 0x00ff) | (data << 8); |
| 102 | niyanpai_gfxdraw(vram); |
| 110 | 103 | break; |
| 111 | 104 | default: break; |
| 112 | 105 | } |
| 113 | 106 | } |
| 114 | 107 | |
| 115 | | static void niyanpai_clutsel_w(running_machine &machine, int vram, int data) |
| 108 | void niyanpai_state::niyanpai_clutsel_w(int vram, int data) |
| 116 | 109 | { |
| 117 | | niyanpai_state *state = machine.driver_data<niyanpai_state>(); |
| 118 | | state->m_clutsel[vram] = data; |
| 110 | m_clutsel[vram] = data; |
| 119 | 111 | } |
| 120 | 112 | |
| 121 | | static void niyanpai_clut_w(running_machine &machine, int vram, int offset, int data) |
| 113 | void niyanpai_state::niyanpai_clut_w(int vram, int offset, int data) |
| 122 | 114 | { |
| 123 | | niyanpai_state *state = machine.driver_data<niyanpai_state>(); |
| 124 | | state->m_clut[vram][((state->m_clutsel[vram] & 0xff) * 0x10) + (offset & 0x0f)] = data; |
| 115 | m_clut[vram][((m_clutsel[vram] & 0xff) * 0x10) + (offset & 0x0f)] = data; |
| 125 | 116 | } |
| 126 | 117 | |
| 127 | 118 | /****************************************************************************** |
| 128 | 119 | |
| 129 | 120 | |
| 130 | 121 | ******************************************************************************/ |
| 131 | | static void niyanpai_vramflip(running_machine &machine, int vram) |
| 122 | void niyanpai_state::niyanpai_vramflip(int vram) |
| 132 | 123 | { |
| 133 | | niyanpai_state *state = machine.driver_data<niyanpai_state>(); |
| 134 | 124 | int x, y; |
| 135 | 125 | UINT16 color1, color2; |
| 136 | | int width = machine.primary_screen->width(); |
| 137 | | int height = machine.primary_screen->height(); |
| 126 | int width = machine().primary_screen->width(); |
| 127 | int height = machine().primary_screen->height(); |
| 138 | 128 | |
| 139 | | if (state->m_flipscreen[vram] == state->m_flipscreen_old[vram]) return; |
| 129 | if (m_flipscreen[vram] == m_flipscreen_old[vram]) return; |
| 140 | 130 | |
| 141 | 131 | for (y = 0; y < (height / 2); y++) |
| 142 | 132 | { |
| 143 | 133 | for (x = 0; x < width; x++) |
| 144 | 134 | { |
| 145 | | color1 = state->m_videoram[vram][(y * width) + x]; |
| 146 | | color2 = state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 147 | | state->m_videoram[vram][(y * width) + x] = color2; |
| 148 | | state->m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 135 | color1 = m_videoram[vram][(y * width) + x]; |
| 136 | color2 = m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 137 | m_videoram[vram][(y * width) + x] = color2; |
| 138 | m_videoram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 149 | 139 | } |
| 150 | 140 | } |
| 151 | 141 | |
| r20971 | r20972 | |
| 153 | 143 | { |
| 154 | 144 | for (x = 0; x < width; x++) |
| 155 | 145 | { |
| 156 | | color1 = state->m_videoworkram[vram][(y * width) + x]; |
| 157 | | color2 = state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 158 | | state->m_videoworkram[vram][(y * width) + x] = color2; |
| 159 | | state->m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 146 | color1 = m_videoworkram[vram][(y * width) + x]; |
| 147 | color2 = m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)]; |
| 148 | m_videoworkram[vram][(y * width) + x] = color2; |
| 149 | m_videoworkram[vram][((y ^ 0x1ff) * width) + (x ^ 0x3ff)] = color1; |
| 160 | 150 | } |
| 161 | 151 | } |
| 162 | 152 | |
| 163 | | state->m_flipscreen_old[vram] = state->m_flipscreen[vram]; |
| 164 | | state->m_screen_refresh = 1; |
| 153 | m_flipscreen_old[vram] = m_flipscreen[vram]; |
| 154 | m_screen_refresh = 1; |
| 165 | 155 | } |
| 166 | 156 | |
| 167 | | static void update_pixel(running_machine &machine, int vram, int x, int y) |
| 157 | void niyanpai_state::update_pixel(int vram, int x, int y) |
| 168 | 158 | { |
| 169 | | niyanpai_state *state = machine.driver_data<niyanpai_state>(); |
| 170 | | UINT16 color = state->m_videoram[vram][(y * machine.primary_screen->width()) + x]; |
| 171 | | state->m_tmpbitmap[vram].pix16(y, x) = color; |
| 159 | UINT16 color = m_videoram[vram][(y * machine().primary_screen->width()) + x]; |
| 160 | m_tmpbitmap[vram].pix16(y, x) = color; |
| 172 | 161 | } |
| 173 | 162 | |
| 174 | 163 | TIMER_CALLBACK_MEMBER(niyanpai_state::blitter_timer_callback) |
| r20971 | r20972 | |
| 176 | 165 | m_nb19010_busyflag = 1; |
| 177 | 166 | } |
| 178 | 167 | |
| 179 | | static void niyanpai_gfxdraw(running_machine &machine, int vram) |
| 168 | void niyanpai_state::niyanpai_gfxdraw(int vram) |
| 180 | 169 | { |
| 181 | | niyanpai_state *state = machine.driver_data<niyanpai_state>(); |
| 182 | | UINT8 *GFX = state->memregion("gfx1")->base(); |
| 183 | | int width = machine.primary_screen->width(); |
| 170 | UINT8 *GFX = memregion("gfx1")->base(); |
| 171 | int width = machine().primary_screen->width(); |
| 184 | 172 | |
| 185 | 173 | int x, y; |
| 186 | 174 | int dx1, dx2, dy; |
| r20971 | r20972 | |
| 191 | 179 | UINT16 color, color1, color2; |
| 192 | 180 | int gfxaddr, gfxlen; |
| 193 | 181 | |
| 194 | | state->m_nb19010_busyctr = 0; |
| 182 | m_nb19010_busyctr = 0; |
| 195 | 183 | |
| 196 | | if (state->m_clutmode[vram]) |
| 184 | if (m_clutmode[vram]) |
| 197 | 185 | { |
| 198 | 186 | // NB22090 clut256 mode |
| 199 | | state->m_blitter_sizex[vram] = GFX[((state->m_blitter_src_addr[vram] + 0) & 0x00ffffff)]; |
| 200 | | state->m_blitter_sizey[vram] = GFX[((state->m_blitter_src_addr[vram] + 1) & 0x00ffffff)]; |
| 187 | m_blitter_sizex[vram] = GFX[((m_blitter_src_addr[vram] + 0) & 0x00ffffff)]; |
| 188 | m_blitter_sizey[vram] = GFX[((m_blitter_src_addr[vram] + 1) & 0x00ffffff)]; |
| 201 | 189 | } |
| 202 | 190 | |
| 203 | | if (state->m_blitter_direction_x[vram]) |
| 191 | if (m_blitter_direction_x[vram]) |
| 204 | 192 | { |
| 205 | | startx = state->m_blitter_destx[vram]; |
| 206 | | sizex = state->m_blitter_sizex[vram]; |
| 193 | startx = m_blitter_destx[vram]; |
| 194 | sizex = m_blitter_sizex[vram]; |
| 207 | 195 | skipx = 1; |
| 208 | 196 | } |
| 209 | 197 | else |
| 210 | 198 | { |
| 211 | | startx = state->m_blitter_destx[vram] + state->m_blitter_sizex[vram]; |
| 212 | | sizex = state->m_blitter_sizex[vram]; |
| 199 | startx = m_blitter_destx[vram] + m_blitter_sizex[vram]; |
| 200 | sizex = m_blitter_sizex[vram]; |
| 213 | 201 | skipx = -1; |
| 214 | 202 | } |
| 215 | 203 | |
| 216 | | if (state->m_blitter_direction_y[vram]) |
| 204 | if (m_blitter_direction_y[vram]) |
| 217 | 205 | { |
| 218 | | starty = state->m_blitter_desty[vram]; |
| 219 | | sizey = state->m_blitter_sizey[vram]; |
| 206 | starty = m_blitter_desty[vram]; |
| 207 | sizey = m_blitter_sizey[vram]; |
| 220 | 208 | skipy = 1; |
| 221 | 209 | } |
| 222 | 210 | else |
| 223 | 211 | { |
| 224 | | starty = state->m_blitter_desty[vram] + state->m_blitter_sizey[vram]; |
| 225 | | sizey = state->m_blitter_sizey[vram]; |
| 212 | starty = m_blitter_desty[vram] + m_blitter_sizey[vram]; |
| 213 | sizey = m_blitter_sizey[vram]; |
| 226 | 214 | skipy = -1; |
| 227 | 215 | } |
| 228 | 216 | |
| 229 | | gfxlen = machine.root_device().memregion("gfx1")->bytes(); |
| 230 | | gfxaddr = ((state->m_blitter_src_addr[vram] + 2) & 0x00ffffff); |
| 217 | gfxlen = machine().root_device().memregion("gfx1")->bytes(); |
| 218 | gfxaddr = ((m_blitter_src_addr[vram] + 2) & 0x00ffffff); |
| 231 | 219 | |
| 232 | 220 | for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) |
| 233 | 221 | { |
| r20971 | r20972 | |
| 248 | 236 | dx2 = (2 * x + 1) & 0x3ff; |
| 249 | 237 | dy = y & 0x1ff; |
| 250 | 238 | |
| 251 | | if (!state->m_flipscreen[vram]) |
| 239 | if (!m_flipscreen[vram]) |
| 252 | 240 | { |
| 253 | 241 | dx1 ^= 0x3ff; |
| 254 | 242 | dx2 ^= 0x3ff; |
| 255 | 243 | dy ^= 0x1ff; |
| 256 | 244 | } |
| 257 | 245 | |
| 258 | | if (state->m_blitter_direction_x[vram]) |
| 246 | if (m_blitter_direction_x[vram]) |
| 259 | 247 | { |
| 260 | 248 | // flip |
| 261 | 249 | color1 = (color & 0x0f) >> 0; |
| r20971 | r20972 | |
| 268 | 256 | color2 = (color & 0x0f) >> 0; |
| 269 | 257 | } |
| 270 | 258 | |
| 271 | | if (state->m_clutmode[vram]) |
| 259 | if (m_clutmode[vram]) |
| 272 | 260 | { |
| 273 | 261 | // clut256 mode |
| 274 | 262 | |
| 275 | | if (state->m_clutsel[vram] & 0x80) |
| 263 | if (m_clutsel[vram] & 0x80) |
| 276 | 264 | { |
| 277 | 265 | // clut256 mode 1st(low) |
| 278 | | state->m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0; |
| 279 | | state->m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f; |
| 280 | | state->m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0; |
| 281 | | state->m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f; |
| 266 | m_videoworkram[vram][(dy * width) + dx1] &= 0x00f0; |
| 267 | m_videoworkram[vram][(dy * width) + dx1] |= color1 & 0x0f; |
| 268 | m_videoworkram[vram][(dy * width) + dx2] &= 0x00f0; |
| 269 | m_videoworkram[vram][(dy * width) + dx2] |= color2 & 0x0f; |
| 282 | 270 | |
| 283 | 271 | continue; |
| 284 | 272 | } |
| 285 | 273 | else |
| 286 | 274 | { |
| 287 | 275 | // clut256 mode 2nd(high) |
| 288 | | state->m_videoworkram[vram][(dy * width) + dx1] &= 0x000f; |
| 289 | | state->m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4; |
| 290 | | state->m_videoworkram[vram][(dy * width) + dx2] &= 0x000f; |
| 291 | | state->m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4; |
| 276 | m_videoworkram[vram][(dy * width) + dx1] &= 0x000f; |
| 277 | m_videoworkram[vram][(dy * width) + dx1] |= (color1 & 0x0f) << 4; |
| 278 | m_videoworkram[vram][(dy * width) + dx2] &= 0x000f; |
| 279 | m_videoworkram[vram][(dy * width) + dx2] |= (color2 & 0x0f) << 4; |
| 292 | 280 | |
| 293 | | // state->m_videoworkram[vram][(dy * width) + dx1] += state->m_clut[vram][(state->m_clutsel[vram] * 0x10)]; |
| 294 | | // state->m_videoworkram[vram][(dy * width) + dx2] += state->m_clut[vram][(state->m_clutsel[vram] * 0x10)]; |
| 281 | // m_videoworkram[vram][(dy * width) + dx1] += m_clut[vram][(m_clutsel[vram] * 0x10)]; |
| 282 | // m_videoworkram[vram][(dy * width) + dx2] += m_clut[vram][(m_clutsel[vram] * 0x10)]; |
| 295 | 283 | } |
| 296 | 284 | |
| 297 | | color1 = state->m_videoworkram[vram][(dy * width) + dx1]; |
| 298 | | color2 = state->m_videoworkram[vram][(dy * width) + dx2]; |
| 285 | color1 = m_videoworkram[vram][(dy * width) + dx1]; |
| 286 | color2 = m_videoworkram[vram][(dy * width) + dx2]; |
| 299 | 287 | } |
| 300 | 288 | else |
| 301 | 289 | { |
| 302 | 290 | // clut16 mode |
| 303 | | color1 = state->m_clut[vram][(state->m_clutsel[vram] * 0x10) + color1]; |
| 304 | | color2 = state->m_clut[vram][(state->m_clutsel[vram] * 0x10) + color2]; |
| 291 | color1 = m_clut[vram][(m_clutsel[vram] * 0x10) + color1]; |
| 292 | color2 = m_clut[vram][(m_clutsel[vram] * 0x10) + color2]; |
| 305 | 293 | } |
| 306 | 294 | |
| 307 | 295 | color1 |= (0x0100 * vram); |
| 308 | 296 | color2 |= (0x0100 * vram); |
| 309 | 297 | |
| 310 | | if (((color1 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram])) |
| 298 | if (((color1 & 0x00ff) != 0x00ff) || (!m_transparency[vram])) |
| 311 | 299 | { |
| 312 | | state->m_videoram[vram][(dy * width) + dx1] = color1; |
| 313 | | update_pixel(machine, vram, dx1, dy); |
| 300 | m_videoram[vram][(dy * width) + dx1] = color1; |
| 301 | update_pixel(vram, dx1, dy); |
| 314 | 302 | } |
| 315 | | if (((color2 & 0x00ff) != 0x00ff) || (!state->m_transparency[vram])) |
| 303 | if (((color2 & 0x00ff) != 0x00ff) || (!m_transparency[vram])) |
| 316 | 304 | { |
| 317 | | state->m_videoram[vram][(dy * width) + dx2] = color2; |
| 318 | | update_pixel(machine, vram, dx2, dy); |
| 305 | m_videoram[vram][(dy * width) + dx2] = color2; |
| 306 | update_pixel(vram, dx2, dy); |
| 319 | 307 | } |
| 320 | 308 | |
| 321 | | state->m_nb19010_busyctr++; |
| 309 | m_nb19010_busyctr++; |
| 322 | 310 | } |
| 323 | 311 | } |
| 324 | 312 | |
| 325 | | if (state->m_clutmode[vram]) |
| 313 | if (m_clutmode[vram]) |
| 326 | 314 | { |
| 327 | 315 | // NB22090 clut256 mode |
| 328 | | state->m_blitter_src_addr[vram] = gfxaddr; |
| 316 | m_blitter_src_addr[vram] = gfxaddr; |
| 329 | 317 | } |
| 330 | 318 | |
| 331 | | state->m_nb19010_busyflag = 0; |
| 332 | | machine.scheduler().timer_set(attotime::from_nsec(1000 * state->m_nb19010_busyctr), timer_expired_delegate(FUNC(niyanpai_state::blitter_timer_callback),state)); |
| 319 | m_nb19010_busyflag = 0; |
| 320 | machine().scheduler().timer_set(attotime::from_nsec(1000 * m_nb19010_busyctr), timer_expired_delegate(FUNC(niyanpai_state::blitter_timer_callback),this)); |
| 333 | 321 | } |
| 334 | 322 | |
| 335 | 323 | /****************************************************************************** |
| 336 | 324 | |
| 337 | 325 | |
| 338 | 326 | ******************************************************************************/ |
| 339 | | WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_0_w){ niyanpai_blitter_w(machine(), 0, offset, data); } |
| 340 | | WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_1_w){ niyanpai_blitter_w(machine(), 1, offset, data); } |
| 341 | | WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_2_w){ niyanpai_blitter_w(machine(), 2, offset, data); } |
| 327 | WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_0_w){ niyanpai_blitter_w(0, offset, data); } |
| 328 | WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_1_w){ niyanpai_blitter_w(1, offset, data); } |
| 329 | WRITE16_MEMBER(niyanpai_state::niyanpai_blitter_2_w){ niyanpai_blitter_w(2, offset, data); } |
| 342 | 330 | |
| 343 | | READ16_MEMBER(niyanpai_state::niyanpai_blitter_0_r){ return niyanpai_blitter_r(machine(), 0, offset); } |
| 344 | | READ16_MEMBER(niyanpai_state::niyanpai_blitter_1_r){ return niyanpai_blitter_r(machine(), 1, offset); } |
| 345 | | READ16_MEMBER(niyanpai_state::niyanpai_blitter_2_r){ return niyanpai_blitter_r(machine(), 2, offset); } |
| 331 | READ16_MEMBER(niyanpai_state::niyanpai_blitter_0_r){ return niyanpai_blitter_r(0, offset); } |
| 332 | READ16_MEMBER(niyanpai_state::niyanpai_blitter_1_r){ return niyanpai_blitter_r(1, offset); } |
| 333 | READ16_MEMBER(niyanpai_state::niyanpai_blitter_2_r){ return niyanpai_blitter_r(2, offset); } |
| 346 | 334 | |
| 347 | | WRITE16_MEMBER(niyanpai_state::niyanpai_clut_0_w){ niyanpai_clut_w(machine(), 0, offset, data); } |
| 348 | | WRITE16_MEMBER(niyanpai_state::niyanpai_clut_1_w){ niyanpai_clut_w(machine(), 1, offset, data); } |
| 349 | | WRITE16_MEMBER(niyanpai_state::niyanpai_clut_2_w){ niyanpai_clut_w(machine(), 2, offset, data); } |
| 335 | WRITE16_MEMBER(niyanpai_state::niyanpai_clut_0_w){ niyanpai_clut_w(0, offset, data); } |
| 336 | WRITE16_MEMBER(niyanpai_state::niyanpai_clut_1_w){ niyanpai_clut_w(1, offset, data); } |
| 337 | WRITE16_MEMBER(niyanpai_state::niyanpai_clut_2_w){ niyanpai_clut_w(2, offset, data); } |
| 350 | 338 | |
| 351 | | WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_0_w){ niyanpai_clutsel_w(machine(), 0, data); } |
| 352 | | WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_1_w){ niyanpai_clutsel_w(machine(), 1, data); } |
| 353 | | WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_2_w){ niyanpai_clutsel_w(machine(), 2, data); } |
| 339 | WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_0_w){ niyanpai_clutsel_w(0, data); } |
| 340 | WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_1_w){ niyanpai_clutsel_w(1, data); } |
| 341 | WRITE16_MEMBER(niyanpai_state::niyanpai_clutsel_2_w){ niyanpai_clutsel_w(2, data); } |
| 354 | 342 | |
| 355 | 343 | /****************************************************************************** |
| 356 | 344 | |
| r20971 | r20972 | |
| 397 | 385 | for (y = 0; y < height; y++) |
| 398 | 386 | for (x = 0; x < width; x++) |
| 399 | 387 | { |
| 400 | | update_pixel(machine(), 0, x, y); |
| 401 | | update_pixel(machine(), 1, x, y); |
| 402 | | update_pixel(machine(), 2, x, y); |
| 388 | update_pixel(0, x, y); |
| 389 | update_pixel(1, x, y); |
| 390 | update_pixel(2, x, y); |
| 403 | 391 | } |
| 404 | 392 | } |
| 405 | 393 | |
trunk/src/mame/video/neogeo.c
| r20971 | r20972 | |
| 18 | 18 | * |
| 19 | 19 | *************************************/ |
| 20 | 20 | |
| 21 | | static void set_videoram_offset( running_machine &machine, UINT16 data ) |
| 21 | void neogeo_state::set_videoram_offset( UINT16 data ) |
| 22 | 22 | { |
| 23 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 24 | | state->m_videoram_offset = data; |
| 23 | m_videoram_offset = data; |
| 25 | 24 | |
| 26 | 25 | /* the read happens right away */ |
| 27 | | state->m_videoram_read_buffer = state->m_videoram[state->m_videoram_offset]; |
| 26 | m_videoram_read_buffer = m_videoram[m_videoram_offset]; |
| 28 | 27 | } |
| 29 | 28 | |
| 30 | 29 | |
| 31 | | static UINT16 get_videoram_data( running_machine &machine ) |
| 30 | UINT16 neogeo_state::get_videoram_data( ) |
| 32 | 31 | { |
| 33 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 34 | | return state->m_videoram_read_buffer; |
| 32 | return m_videoram_read_buffer; |
| 35 | 33 | } |
| 36 | 34 | |
| 37 | 35 | |
| 38 | | static void set_videoram_data( running_machine &machine, UINT16 data) |
| 36 | void neogeo_state::set_videoram_data( UINT16 data) |
| 39 | 37 | { |
| 40 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 41 | | state->m_videoram[state->m_videoram_offset] = data; |
| 38 | m_videoram[m_videoram_offset] = data; |
| 42 | 39 | |
| 43 | 40 | /* auto increment/decrement the current offset - A15 is NOT effected */ |
| 44 | | state->m_videoram_offset = (state->m_videoram_offset & 0x8000) | ((state->m_videoram_offset + state->m_videoram_modulo) & 0x7fff); |
| 41 | m_videoram_offset = (m_videoram_offset & 0x8000) | ((m_videoram_offset + m_videoram_modulo) & 0x7fff); |
| 45 | 42 | |
| 46 | 43 | /* read next value right away */ |
| 47 | | state->m_videoram_read_buffer = state->m_videoram[state->m_videoram_offset]; |
| 44 | m_videoram_read_buffer = m_videoram[m_videoram_offset]; |
| 48 | 45 | } |
| 49 | 46 | |
| 50 | 47 | |
| 51 | | static void set_videoram_modulo( running_machine &machine, UINT16 data) |
| 48 | void neogeo_state::set_videoram_modulo( UINT16 data) |
| 52 | 49 | { |
| 53 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 54 | | state->m_videoram_modulo = data; |
| 50 | m_videoram_modulo = data; |
| 55 | 51 | } |
| 56 | 52 | |
| 57 | 53 | |
| 58 | | static UINT16 get_videoram_modulo( running_machine &machine ) |
| 54 | UINT16 neogeo_state::get_videoram_modulo( ) |
| 59 | 55 | { |
| 60 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 61 | | return state->m_videoram_modulo; |
| 56 | return m_videoram_modulo; |
| 62 | 57 | } |
| 63 | 58 | |
| 64 | 59 | |
| r20971 | r20972 | |
| 69 | 64 | * |
| 70 | 65 | *************************************/ |
| 71 | 66 | |
| 72 | | static void compute_rgb_weights( running_machine &machine ) |
| 67 | void neogeo_state::compute_rgb_weights( ) |
| 73 | 68 | { |
| 74 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 75 | 69 | static const int resistances[] = { 220, 470, 1000, 2200, 3900 }; |
| 76 | 70 | |
| 77 | 71 | /* compute four sets of weights - with or without the pulldowns - |
| 78 | 72 | ensuring that we use the same scaler for all */ |
| 79 | 73 | |
| 80 | 74 | double scaler = compute_resistor_weights(0, 0xff, -1, |
| 81 | | 5, resistances, state->m_rgb_weights_normal, 0, 0, |
| 75 | 5, resistances, m_rgb_weights_normal, 0, 0, |
| 82 | 76 | 0, 0, 0, 0, 0, |
| 83 | 77 | 0, 0, 0, 0, 0); |
| 84 | 78 | |
| 85 | 79 | compute_resistor_weights(0, 0xff, scaler, |
| 86 | | 5, resistances, state->m_rgb_weights_normal_bit15, 8200, 0, |
| 80 | 5, resistances, m_rgb_weights_normal_bit15, 8200, 0, |
| 87 | 81 | 0, 0, 0, 0, 0, |
| 88 | 82 | 0, 0, 0, 0, 0); |
| 89 | 83 | |
| 90 | 84 | compute_resistor_weights(0, 0xff, scaler, |
| 91 | | 5, resistances, state->m_rgb_weights_dark, 150, 0, |
| 85 | 5, resistances, m_rgb_weights_dark, 150, 0, |
| 92 | 86 | 0, 0, 0, 0, 0, |
| 93 | 87 | 0, 0, 0, 0, 0); |
| 94 | 88 | |
| 95 | 89 | compute_resistor_weights(0, 0xff, scaler, |
| 96 | | 5, resistances, state->m_rgb_weights_dark_bit15, 1 / ((1.0 / 8200) + (1.0 / 150)), 0, |
| 90 | 5, resistances, m_rgb_weights_dark_bit15, 1 / ((1.0 / 8200) + (1.0 / 150)), 0, |
| 97 | 91 | 0, 0, 0, 0, 0, |
| 98 | 92 | 0, 0, 0, 0, 0); |
| 99 | 93 | } |
| 100 | 94 | |
| 101 | 95 | |
| 102 | | static pen_t get_pen( running_machine &machine, UINT16 data ) |
| 96 | pen_t neogeo_state::get_pen( UINT16 data ) |
| 103 | 97 | { |
| 104 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 105 | 98 | double *weights; |
| 106 | 99 | UINT8 r, g, b; |
| 107 | 100 | |
| 108 | | if (state->m_screen_dark) |
| 101 | if (m_screen_dark) |
| 109 | 102 | { |
| 110 | 103 | if (data & 0x8000) |
| 111 | | weights = state->m_rgb_weights_dark_bit15; |
| 104 | weights = m_rgb_weights_dark_bit15; |
| 112 | 105 | else |
| 113 | | weights = state->m_rgb_weights_dark; |
| 106 | weights = m_rgb_weights_dark; |
| 114 | 107 | } |
| 115 | 108 | else |
| 116 | 109 | { |
| 117 | 110 | if (data & 0x8000) |
| 118 | | weights = state->m_rgb_weights_normal_bit15; |
| 111 | weights = m_rgb_weights_normal_bit15; |
| 119 | 112 | else |
| 120 | | weights = state->m_rgb_weights_normal; |
| 113 | weights = m_rgb_weights_normal; |
| 121 | 114 | } |
| 122 | 115 | |
| 123 | 116 | r = combine_5_weights(weights, |
| r20971 | r20972 | |
| 150 | 143 | int i; |
| 151 | 144 | |
| 152 | 145 | for (i = 0; i < NUM_PENS; i++) |
| 153 | | m_pens[i] = get_pen(machine(), m_palettes[m_palette_bank][i]); |
| 146 | m_pens[i] = get_pen(m_palettes[m_palette_bank][i]); |
| 154 | 147 | } |
| 155 | 148 | |
| 156 | 149 | |
| 157 | | void neogeo_set_palette_bank( running_machine &machine, UINT8 data ) |
| 150 | void neogeo_state::neogeo_set_palette_bank( UINT8 data ) |
| 158 | 151 | { |
| 159 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 160 | | if (data != state->m_palette_bank) |
| 152 | if (data != m_palette_bank) |
| 161 | 153 | { |
| 162 | | state->m_palette_bank = data; |
| 154 | m_palette_bank = data; |
| 163 | 155 | |
| 164 | | state->regenerate_pens(); |
| 156 | regenerate_pens(); |
| 165 | 157 | } |
| 166 | 158 | } |
| 167 | 159 | |
| 168 | 160 | |
| 169 | | void neogeo_set_screen_dark( running_machine &machine, UINT8 data ) |
| 161 | void neogeo_state::neogeo_set_screen_dark( UINT8 data ) |
| 170 | 162 | { |
| 171 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 172 | | if (data != state->m_screen_dark) |
| 163 | if (data != m_screen_dark) |
| 173 | 164 | { |
| 174 | | state->m_screen_dark = data; |
| 165 | m_screen_dark = data; |
| 175 | 166 | |
| 176 | | state->regenerate_pens(); |
| 167 | regenerate_pens(); |
| 177 | 168 | } |
| 178 | 169 | } |
| 179 | 170 | |
| r20971 | r20972 | |
| 190 | 181 | |
| 191 | 182 | COMBINE_DATA(addr); |
| 192 | 183 | |
| 193 | | m_pens[offset] = get_pen(machine(), *addr); |
| 184 | m_pens[offset] = get_pen(*addr); |
| 194 | 185 | } |
| 195 | 186 | |
| 196 | 187 | |
| r20971 | r20972 | |
| 201 | 192 | * |
| 202 | 193 | *************************************/ |
| 203 | 194 | |
| 204 | | static void set_auto_animation_speed( running_machine &machine, UINT8 data) |
| 195 | void neogeo_state::set_auto_animation_speed( UINT8 data) |
| 205 | 196 | { |
| 206 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 207 | | state->m_auto_animation_speed = data; |
| 197 | m_auto_animation_speed = data; |
| 208 | 198 | } |
| 209 | 199 | |
| 210 | 200 | |
| 211 | | static void set_auto_animation_disabled( running_machine &machine, UINT8 data) |
| 201 | void neogeo_state::set_auto_animation_disabled( UINT8 data) |
| 212 | 202 | { |
| 213 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 214 | | state->m_auto_animation_disabled = data; |
| 203 | m_auto_animation_disabled = data; |
| 215 | 204 | } |
| 216 | 205 | |
| 217 | 206 | |
| 218 | | UINT8 neogeo_get_auto_animation_counter( running_machine &machine ) |
| 207 | UINT8 neogeo_state::neogeo_get_auto_animation_counter( ) |
| 219 | 208 | { |
| 220 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 221 | | return state->m_auto_animation_counter; |
| 209 | return m_auto_animation_counter; |
| 222 | 210 | } |
| 223 | 211 | |
| 224 | 212 | |
| r20971 | r20972 | |
| 236 | 224 | } |
| 237 | 225 | |
| 238 | 226 | |
| 239 | | static void create_auto_animation_timer( running_machine &machine ) |
| 227 | void neogeo_state::create_auto_animation_timer( ) |
| 240 | 228 | { |
| 241 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 242 | | state->m_auto_animation_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::auto_animation_timer_callback),state)); |
| 229 | m_auto_animation_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::auto_animation_timer_callback),this)); |
| 243 | 230 | } |
| 244 | 231 | |
| 245 | 232 | |
| 246 | | static void start_auto_animation_timer( running_machine &machine ) |
| 233 | void neogeo_state::start_auto_animation_timer( ) |
| 247 | 234 | { |
| 248 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 249 | | state->m_auto_animation_timer->adjust(machine.primary_screen->time_until_pos(NEOGEO_VSSTART)); |
| 235 | m_auto_animation_timer->adjust(machine().primary_screen->time_until_pos(NEOGEO_VSSTART)); |
| 250 | 236 | } |
| 251 | 237 | |
| 252 | 238 | |
| r20971 | r20972 | |
| 257 | 243 | * |
| 258 | 244 | *************************************/ |
| 259 | 245 | |
| 260 | | void neogeo_set_fixed_layer_source( running_machine &machine, UINT8 data ) |
| 246 | void neogeo_state::neogeo_set_fixed_layer_source( UINT8 data ) |
| 261 | 247 | { |
| 262 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 263 | | state->m_fixed_layer_source = data; |
| 248 | m_fixed_layer_source = data; |
| 264 | 249 | } |
| 265 | 250 | |
| 266 | 251 | |
| r20971 | r20972 | |
| 376 | 361 | }; |
| 377 | 362 | |
| 378 | 363 | |
| 379 | | INLINE int rows_to_height(int rows) |
| 364 | inline int neogeo_state::rows_to_height(int rows) |
| 380 | 365 | { |
| 381 | 366 | if ((rows == 0) || (rows > 0x20)) |
| 382 | 367 | rows = 0x20; |
| r20971 | r20972 | |
| 385 | 370 | } |
| 386 | 371 | |
| 387 | 372 | |
| 388 | | INLINE int sprite_on_scanline(int scanline, int y, int rows) |
| 373 | inline int neogeo_state::sprite_on_scanline(int scanline, int y, int rows) |
| 389 | 374 | { |
| 390 | 375 | /* check if the current scanline falls inside this sprite, |
| 391 | 376 | two possible scenerios, wrap around or not */ |
| r20971 | r20972 | |
| 396 | 381 | } |
| 397 | 382 | |
| 398 | 383 | |
| 399 | | static void draw_sprites( running_machine &machine, bitmap_rgb32 &bitmap, int scanline ) |
| 384 | void neogeo_state::draw_sprites( bitmap_rgb32 &bitmap, int scanline ) |
| 400 | 385 | { |
| 401 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 402 | 386 | int sprite_index; |
| 403 | 387 | int max_sprite_index; |
| 404 | 388 | |
| r20971 | r20972 | |
| 411 | 395 | |
| 412 | 396 | /* select the active list */ |
| 413 | 397 | if (scanline & 0x01) |
| 414 | | sprite_list = &state->m_videoram[0x8680]; |
| 398 | sprite_list = &m_videoram[0x8680]; |
| 415 | 399 | else |
| 416 | | sprite_list = &state->m_videoram[0x8600]; |
| 400 | sprite_list = &m_videoram[0x8600]; |
| 417 | 401 | |
| 418 | 402 | /* optimization -- find last non-zero entry and only draw that many +1 |
| 419 | 403 | sprite. This is not 100% correct as the hardware will keep drawing |
| r20971 | r20972 | |
| 431 | 415 | for (sprite_index = 0; sprite_index <= max_sprite_index; sprite_index++) |
| 432 | 416 | { |
| 433 | 417 | UINT16 sprite_number = sprite_list[sprite_index] & 0x01ff; |
| 434 | | UINT16 y_control = state->m_videoram[0x8200 | sprite_number]; |
| 435 | | UINT16 zoom_control = state->m_videoram[0x8000 | sprite_number]; |
| 418 | UINT16 y_control = m_videoram[0x8200 | sprite_number]; |
| 419 | UINT16 zoom_control = m_videoram[0x8000 | sprite_number]; |
| 436 | 420 | |
| 437 | 421 | /* if chained, go to next X coordinate and get new X zoom */ |
| 438 | 422 | if (y_control & 0x40) |
| r20971 | r20972 | |
| 444 | 428 | else |
| 445 | 429 | { |
| 446 | 430 | y = 0x200 - (y_control >> 7); |
| 447 | | x = state->m_videoram[0x8400 | sprite_number] >> 7; |
| 431 | x = m_videoram[0x8400 | sprite_number] >> 7; |
| 448 | 432 | zoom_y = zoom_control & 0xff; |
| 449 | 433 | zoom_x = (zoom_control >> 8) & 0x0f; |
| 450 | 434 | rows = y_control & 0x3f; |
| r20971 | r20972 | |
| 487 | 471 | } |
| 488 | 472 | } |
| 489 | 473 | |
| 490 | | sprite_y_and_tile = state->m_region_zoomy[(zoom_y << 8) | zoom_line]; |
| 474 | sprite_y_and_tile = m_region_zoomy[(zoom_y << 8) | zoom_line]; |
| 491 | 475 | sprite_y = sprite_y_and_tile & 0x0f; |
| 492 | 476 | tile = sprite_y_and_tile >> 4; |
| 493 | 477 | |
| r20971 | r20972 | |
| 498 | 482 | } |
| 499 | 483 | |
| 500 | 484 | attr_and_code_offs = (sprite_number << 6) | (tile << 1); |
| 501 | | attr = state->m_videoram[attr_and_code_offs + 1]; |
| 502 | | code = ((attr << 12) & 0x70000) | state->m_videoram[attr_and_code_offs]; |
| 485 | attr = m_videoram[attr_and_code_offs + 1]; |
| 486 | code = ((attr << 12) & 0x70000) | m_videoram[attr_and_code_offs]; |
| 503 | 487 | |
| 504 | 488 | /* substitute auto animation bits */ |
| 505 | | if (!state->m_auto_animation_disabled) |
| 489 | if (!m_auto_animation_disabled) |
| 506 | 490 | { |
| 507 | 491 | if (attr & 0x0008) |
| 508 | | code = (code & ~0x07) | (state->m_auto_animation_counter & 0x07); |
| 492 | code = (code & ~0x07) | (m_auto_animation_counter & 0x07); |
| 509 | 493 | else if (attr & 0x0004) |
| 510 | | code = (code & ~0x03) | (state->m_auto_animation_counter & 0x03); |
| 494 | code = (code & ~0x03) | (m_auto_animation_counter & 0x03); |
| 511 | 495 | } |
| 512 | 496 | |
| 513 | 497 | /* vertical flip? */ |
| r20971 | r20972 | |
| 517 | 501 | zoom_x_table = zoom_x_tables[zoom_x]; |
| 518 | 502 | |
| 519 | 503 | /* compute offset in gfx ROM and mask it to the number of bits available */ |
| 520 | | gfx = &state->m_sprite_gfx[((code << 8) | (sprite_y << 4)) & state->m_sprite_gfx_address_mask]; |
| 504 | gfx = &m_sprite_gfx[((code << 8) | (sprite_y << 4)) & m_sprite_gfx_address_mask]; |
| 521 | 505 | |
| 522 | | line_pens = &state->m_pens[attr >> 8 << 4]; |
| 506 | line_pens = &m_pens[attr >> 8 << 4]; |
| 523 | 507 | |
| 524 | 508 | /* horizontal flip? */ |
| 525 | 509 | if (attr & 0x0001) |
| r20971 | r20972 | |
| 585 | 569 | } |
| 586 | 570 | |
| 587 | 571 | |
| 588 | | static void parse_sprites( running_machine &machine, int scanline ) |
| 572 | void neogeo_state::parse_sprites( int scanline ) |
| 589 | 573 | { |
| 590 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 591 | 574 | UINT16 sprite_number; |
| 592 | 575 | int y = 0; |
| 593 | 576 | int rows = 0; |
| r20971 | r20972 | |
| 597 | 580 | |
| 598 | 581 | /* select the active list */ |
| 599 | 582 | if (scanline & 0x01) |
| 600 | | sprite_list = &state->m_videoram[0x8680]; |
| 583 | sprite_list = &m_videoram[0x8680]; |
| 601 | 584 | else |
| 602 | | sprite_list = &state->m_videoram[0x8600]; |
| 585 | sprite_list = &m_videoram[0x8600]; |
| 603 | 586 | |
| 604 | 587 | /* scan all sprites */ |
| 605 | 588 | for (sprite_number = 0; sprite_number < MAX_SPRITES_PER_SCREEN; sprite_number++) |
| 606 | 589 | { |
| 607 | | UINT16 y_control = state->m_videoram[0x8200 | sprite_number]; |
| 590 | UINT16 y_control = m_videoram[0x8200 | sprite_number]; |
| 608 | 591 | |
| 609 | 592 | /* if not chained, get Y position and height, otherwise use previous values */ |
| 610 | 593 | if (~y_control & 0x40) |
| r20971 | r20972 | |
| 646 | 629 | if (scanline != 0) |
| 647 | 630 | machine().primary_screen->update_partial(scanline - 1); |
| 648 | 631 | |
| 649 | | parse_sprites(machine(), scanline); |
| 632 | parse_sprites(scanline); |
| 650 | 633 | |
| 651 | 634 | /* let's come back at the beginning of the next line */ |
| 652 | 635 | scanline = (scanline + 1) % NEOGEO_VTOTAL; |
| r20971 | r20972 | |
| 655 | 638 | } |
| 656 | 639 | |
| 657 | 640 | |
| 658 | | static void create_sprite_line_timer( running_machine &machine ) |
| 641 | void neogeo_state::create_sprite_line_timer( ) |
| 659 | 642 | { |
| 660 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 661 | | state->m_sprite_line_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::sprite_line_timer_callback),state)); |
| 643 | m_sprite_line_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(neogeo_state::sprite_line_timer_callback),this)); |
| 662 | 644 | } |
| 663 | 645 | |
| 664 | 646 | |
| 665 | | static void start_sprite_line_timer( running_machine &machine ) |
| 647 | void neogeo_state::start_sprite_line_timer( ) |
| 666 | 648 | { |
| 667 | | neogeo_state *state = machine.driver_data<neogeo_state>(); |
| 668 | | state->m_sprite_line_timer->adjust(machine.primary_screen->time_until_pos(0)); |
| 649 | m_sprite_line_timer->adjust(machine().primary_screen->time_until_pos(0)); |
| 669 | 650 | } |
| 670 | 651 | |
| 671 | 652 | |
| r20971 | r20972 | |
| 733 | 714 | * |
| 734 | 715 | *************************************/ |
| 735 | 716 | |
| 736 | | static UINT16 get_video_control( running_machine &machine ) |
| 717 | UINT16 neogeo_state::get_video_control( ) |
| 737 | 718 | { |
| 738 | 719 | UINT16 ret; |
| 739 | 720 | UINT16 v_counter; |
| r20971 | r20972 | |
| 760 | 741 | */ |
| 761 | 742 | |
| 762 | 743 | /* the vertical counter chain goes from 0xf8 - 0x1ff */ |
| 763 | | v_counter = machine.primary_screen->vpos() + 0x100; |
| 744 | v_counter = machine().primary_screen->vpos() + 0x100; |
| 764 | 745 | |
| 765 | 746 | if (v_counter >= 0x200) |
| 766 | 747 | v_counter = v_counter - NEOGEO_VTOTAL; |
| 767 | 748 | |
| 768 | | ret = (v_counter << 7) | (neogeo_get_auto_animation_counter(machine) & 0x0007); |
| 749 | ret = (v_counter << 7) | (neogeo_get_auto_animation_counter() & 0x0007); |
| 769 | 750 | |
| 770 | | if (VERBOSE) logerror("%s: video_control read (%04x)\n", machine.describe_context(), ret); |
| 751 | if (VERBOSE) logerror("%s: video_control read (%04x)\n", machine().describe_context(), ret); |
| 771 | 752 | |
| 772 | 753 | return ret; |
| 773 | 754 | } |
| r20971 | r20972 | |
| 778 | 759 | /* this does much more than this, but I'm not sure exactly what */ |
| 779 | 760 | if (VERBOSE) logerror("%s: video control write %04x\n", machine().describe_context(), data); |
| 780 | 761 | |
| 781 | | set_auto_animation_speed(machine(), data >> 8); |
| 782 | | set_auto_animation_disabled(machine(), data & 0x0008); |
| 762 | set_auto_animation_speed(data >> 8); |
| 763 | set_auto_animation_disabled(data & 0x0008); |
| 783 | 764 | |
| 784 | 765 | neogeo_set_display_position_interrupt_control(data & 0x00f0); |
| 785 | 766 | } |
| r20971 | r20972 | |
| 798 | 779 | { |
| 799 | 780 | default: |
| 800 | 781 | case 0x00: |
| 801 | | case 0x01: ret = get_videoram_data(machine()); break; |
| 802 | | case 0x02: ret = get_videoram_modulo(machine()); break; |
| 803 | | case 0x03: ret = get_video_control(machine()); break; |
| 782 | case 0x01: ret = get_videoram_data(); break; |
| 783 | case 0x02: ret = get_videoram_modulo(); break; |
| 784 | case 0x03: ret = get_video_control(); break; |
| 804 | 785 | } |
| 805 | 786 | } |
| 806 | 787 | |
| r20971 | r20972 | |
| 819 | 800 | |
| 820 | 801 | switch (offset) |
| 821 | 802 | { |
| 822 | | case 0x00: set_videoram_offset(machine(), data); break; |
| 823 | | case 0x01: set_videoram_data(machine(), data); break; |
| 824 | | case 0x02: set_videoram_modulo(machine(), data); break; |
| 803 | case 0x00: set_videoram_offset(data); break; |
| 804 | case 0x01: set_videoram_data(data); break; |
| 805 | case 0x02: set_videoram_modulo(data); break; |
| 825 | 806 | case 0x03: set_video_control(data); break; |
| 826 | 807 | case 0x04: neogeo_set_display_counter_msb(data); break; |
| 827 | 808 | case 0x05: neogeo_set_display_counter_lsb(data); break; |
| r20971 | r20972 | |
| 853 | 834 | memset(m_pens, 0x00, NUM_PENS * sizeof(pen_t)); |
| 854 | 835 | memset(m_videoram, 0x00, 0x20000); |
| 855 | 836 | |
| 856 | | compute_rgb_weights(machine()); |
| 857 | | create_sprite_line_timer(machine()); |
| 858 | | create_auto_animation_timer(machine()); |
| 837 | compute_rgb_weights(); |
| 838 | create_sprite_line_timer(); |
| 839 | create_auto_animation_timer(); |
| 859 | 840 | optimize_sprite_data(); |
| 860 | 841 | |
| 861 | 842 | /* initialize values that are not modified on a reset */ |
| r20971 | r20972 | |
| 897 | 878 | |
| 898 | 879 | void neogeo_state::video_reset() |
| 899 | 880 | { |
| 900 | | start_sprite_line_timer(machine()); |
| 901 | | start_auto_animation_timer(machine()); |
| 881 | start_sprite_line_timer(); |
| 882 | start_auto_animation_timer(); |
| 902 | 883 | optimize_sprite_data(); |
| 903 | 884 | } |
| 904 | 885 | |
| r20971 | r20972 | |
| 915 | 896 | /* fill with background color first */ |
| 916 | 897 | bitmap.fill(m_pens[0x0fff], cliprect); |
| 917 | 898 | |
| 918 | | if (m_has_sprite_bus) draw_sprites(machine(), bitmap, cliprect.min_y); |
| 899 | if (m_has_sprite_bus) draw_sprites(bitmap, cliprect.min_y); |
| 919 | 900 | |
| 920 | 901 | if (m_has_text_bus) draw_fixed_layer(bitmap, cliprect.min_y); |
| 921 | 902 | |