trunk/src/mame/drivers/mcr.c
| r20931 | r20932 | |
| 2751 | 2751 | * |
| 2752 | 2752 | *************************************/ |
| 2753 | 2753 | |
| 2754 | | static void mcr_init(running_machine &machine, int cpuboard, int vidboard, int ssioboard) |
| 2754 | void mcr_state::mcr_init(int cpuboard, int vidboard, int ssioboard) |
| 2755 | 2755 | { |
| 2756 | 2756 | mcr_cpu_board = cpuboard; |
| 2757 | 2757 | mcr_sprite_board = vidboard; |
| r20931 | r20932 | |
| 2759 | 2759 | mcr12_sprite_xoffs = 0; |
| 2760 | 2760 | mcr12_sprite_xoffs_flip = 0; |
| 2761 | 2761 | |
| 2762 | | state_save_register_global(machine, input_mux); |
| 2763 | | state_save_register_global(machine, last_op4); |
| 2762 | state_save_register_global(machine(), input_mux); |
| 2763 | state_save_register_global(machine(), last_op4); |
| 2764 | 2764 | |
| 2765 | | midway_ssio_device *ssio = machine.device<midway_ssio_device>("ssio"); |
| 2765 | midway_ssio_device *ssio = machine().device<midway_ssio_device>("ssio"); |
| 2766 | 2766 | if (ssio != NULL) |
| 2767 | 2767 | { |
| 2768 | | mcr_state *state = machine.driver_data<mcr_state>(); |
| 2769 | | ssio->set_custom_output(0, 0xff, write8_delegate(FUNC(mcr_state::mcr_control_port_w), state)); |
| 2768 | ssio->set_custom_output(0, 0xff, write8_delegate(FUNC(mcr_state::mcr_control_port_w), this)); |
| 2770 | 2769 | } |
| 2771 | 2770 | } |
| 2772 | 2771 | |
| 2773 | 2772 | |
| 2774 | 2773 | DRIVER_INIT_MEMBER(mcr_state,solarfox) |
| 2775 | 2774 | { |
| 2776 | | mcr_init(machine(), 90009, 91399, 90908); |
| 2775 | mcr_init(90009, 91399, 90908); |
| 2777 | 2776 | mcr12_sprite_xoffs = 16; |
| 2778 | 2777 | |
| 2779 | 2778 | machine().device<midway_ssio_device>("ssio")->set_custom_input(0, 0x1c, read8_delegate(FUNC(mcr_state::solarfox_ip0_r),this)); |
| r20931 | r20932 | |
| 2783 | 2782 | |
| 2784 | 2783 | DRIVER_INIT_MEMBER(mcr_state,kick) |
| 2785 | 2784 | { |
| 2786 | | mcr_init(machine(), 90009, 91399, 90908); |
| 2785 | mcr_init(90009, 91399, 90908); |
| 2787 | 2786 | mcr12_sprite_xoffs_flip = 16; |
| 2788 | 2787 | |
| 2789 | 2788 | machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0xf0, read8_delegate(FUNC(mcr_state::kick_ip1_r),this)); |
| r20931 | r20932 | |
| 2792 | 2791 | |
| 2793 | 2792 | DRIVER_INIT_MEMBER(mcr_state,dpoker) |
| 2794 | 2793 | { |
| 2795 | | mcr_init(machine(), 90009, 91399, 90908); |
| 2794 | mcr_init(90009, 91399, 90908); |
| 2796 | 2795 | mcr12_sprite_xoffs_flip = 16; |
| 2797 | 2796 | |
| 2798 | 2797 | machine().device<midway_ssio_device>("ssio")->set_custom_input(0, 0x8e, read8_delegate(FUNC(mcr_state::dpoker_ip0_r),this)); |
| r20931 | r20932 | |
| 2820 | 2819 | |
| 2821 | 2820 | DRIVER_INIT_MEMBER(mcr_state,mcr_90010) |
| 2822 | 2821 | { |
| 2823 | | mcr_init(machine(), 90010, 91399, 90913); |
| 2822 | mcr_init(90010, 91399, 90913); |
| 2824 | 2823 | } |
| 2825 | 2824 | |
| 2826 | 2825 | |
| 2827 | 2826 | DRIVER_INIT_MEMBER(mcr_state,wacko) |
| 2828 | 2827 | { |
| 2829 | | mcr_init(machine(), 90010, 91399, 90913); |
| 2828 | mcr_init(90010, 91399, 90913); |
| 2830 | 2829 | |
| 2831 | 2830 | machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0xff, read8_delegate(FUNC(mcr_state::wacko_ip1_r),this)); |
| 2832 | 2831 | machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xff, read8_delegate(FUNC(mcr_state::wacko_ip2_r),this)); |
| r20931 | r20932 | |
| 2836 | 2835 | |
| 2837 | 2836 | DRIVER_INIT_MEMBER(mcr_state,twotiger) |
| 2838 | 2837 | { |
| 2839 | | mcr_init(machine(), 90010, 91399, 90913); |
| 2838 | mcr_init(90010, 91399, 90913); |
| 2840 | 2839 | |
| 2841 | 2840 | machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr_state::twotiger_op4_w),this)); |
| 2842 | 2841 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xe800, 0xefff, 0, 0x1000, read8_delegate(FUNC(mcr_state::twotiger_videoram_r),this), write8_delegate(FUNC(mcr_state::twotiger_videoram_w),this)); |
| r20931 | r20932 | |
| 2845 | 2844 | |
| 2846 | 2845 | DRIVER_INIT_MEMBER(mcr_state,kroozr) |
| 2847 | 2846 | { |
| 2848 | | mcr_init(machine(), 90010, 91399, 91483); |
| 2847 | mcr_init(90010, 91399, 91483); |
| 2849 | 2848 | |
| 2850 | 2849 | machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0x47, read8_delegate(FUNC(mcr_state::kroozr_ip1_r),this)); |
| 2851 | 2850 | machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0x34, write8_delegate(FUNC(mcr_state::kroozr_op4_w),this)); |
| r20931 | r20932 | |
| 2854 | 2853 | |
| 2855 | 2854 | DRIVER_INIT_MEMBER(mcr_state,journey) |
| 2856 | 2855 | { |
| 2857 | | mcr_init(machine(), 91475, 91464, 90913); |
| 2856 | mcr_init(91475, 91464, 90913); |
| 2858 | 2857 | |
| 2859 | 2858 | machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0x01, write8_delegate(FUNC(mcr_state::journey_op4_w),this)); |
| 2860 | 2859 | } |
| r20931 | r20932 | |
| 2862 | 2861 | |
| 2863 | 2862 | DRIVER_INIT_MEMBER(mcr_state,mcr_91490) |
| 2864 | 2863 | { |
| 2865 | | mcr_init(machine(), 91490, 91464, 90913); |
| 2864 | mcr_init(91490, 91464, 90913); |
| 2866 | 2865 | } |
| 2867 | 2866 | |
| 2868 | 2867 | |
| 2869 | 2868 | DRIVER_INIT_MEMBER(mcr_state,dotrone) |
| 2870 | 2869 | { |
| 2871 | | mcr_init(machine(), 91490, 91464, 91657); |
| 2870 | mcr_init(91490, 91464, 91657); |
| 2872 | 2871 | |
| 2873 | 2872 | machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr_state::dotron_op4_w),this)); |
| 2874 | 2873 | } |
| r20931 | r20932 | |
| 2876 | 2875 | |
| 2877 | 2876 | DRIVER_INIT_MEMBER(mcr_state,nflfoot) |
| 2878 | 2877 | { |
| 2879 | | mcr_init(machine(), 91490, 91464, 91657); |
| 2878 | mcr_init(91490, 91464, 91657); |
| 2880 | 2879 | |
| 2881 | 2880 | machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0x80, read8_delegate(FUNC(mcr_state::nflfoot_ip2_r),this)); |
| 2882 | 2881 | machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr_state::nflfoot_op4_w),this)); |
| r20931 | r20932 | |
| 2895 | 2894 | |
| 2896 | 2895 | DRIVER_INIT_MEMBER(mcr_state,demoderb) |
| 2897 | 2896 | { |
| 2898 | | mcr_init(machine(), 91490, 91464, 90913); |
| 2897 | mcr_init(91490, 91464, 90913); |
| 2899 | 2898 | |
| 2900 | 2899 | machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0xfc, read8_delegate(FUNC(mcr_state::demoderb_ip1_r),this)); |
| 2901 | 2900 | machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xfc, read8_delegate(FUNC(mcr_state::demoderb_ip2_r),this)); |
trunk/src/mame/drivers/mitchell.c
| r20931 | r20932 | |
| 2080 | 2080 | * |
| 2081 | 2081 | *************************************/ |
| 2082 | 2082 | |
| 2083 | | static void bootleg_decode( running_machine &machine ) |
| 2083 | void mitchell_state::bootleg_decode( ) |
| 2084 | 2084 | { |
| 2085 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 2086 | | space.set_decrypted_region(0x0000, 0x7fff, machine.root_device().memregion("maincpu")->base() + 0x50000); |
| 2087 | | machine.root_device().membank("bank1")->configure_decrypted_entries(0, 16, machine.root_device().memregion("maincpu")->base() + 0x60000, 0x4000); |
| 2085 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2086 | space.set_decrypted_region(0x0000, 0x7fff, machine().root_device().memregion("maincpu")->base() + 0x50000); |
| 2087 | machine().root_device().membank("bank1")->configure_decrypted_entries(0, 16, machine().root_device().memregion("maincpu")->base() + 0x60000, 0x4000); |
| 2088 | 2088 | } |
| 2089 | 2089 | |
| 2090 | 2090 | |
| 2091 | | static void configure_banks( running_machine &machine ) |
| 2091 | void mitchell_state::configure_banks( ) |
| 2092 | 2092 | { |
| 2093 | | machine.root_device().membank("bank1")->configure_entries(0, 16, machine.root_device().memregion("maincpu")->base() + 0x10000, 0x4000); |
| 2093 | machine().root_device().membank("bank1")->configure_entries(0, 16, machine().root_device().memregion("maincpu")->base() + 0x10000, 0x4000); |
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | 2096 | |
| r20931 | r20932 | |
| 2098 | 2098 | { |
| 2099 | 2099 | m_input_type = 0; |
| 2100 | 2100 | mgakuen2_decode(machine()); |
| 2101 | | configure_banks(machine()); |
| 2101 | configure_banks(); |
| 2102 | 2102 | } |
| 2103 | 2103 | DRIVER_INIT_MEMBER(mitchell_state,pang) |
| 2104 | 2104 | { |
| 2105 | 2105 | m_input_type = 0; |
| 2106 | 2106 | pang_decode(machine()); |
| 2107 | | configure_banks(machine()); |
| 2107 | configure_banks(); |
| 2108 | 2108 | } |
| 2109 | 2109 | DRIVER_INIT_MEMBER(mitchell_state,pangb) |
| 2110 | 2110 | { |
| 2111 | 2111 | m_input_type = 0; |
| 2112 | | bootleg_decode(machine()); |
| 2113 | | configure_banks(machine()); |
| 2112 | bootleg_decode(); |
| 2113 | configure_banks(); |
| 2114 | 2114 | if (m_nvram != NULL) |
| 2115 | 2115 | m_nvram->set_base(&m_dummy_nvram, sizeof(m_dummy_nvram)); /* for pangba */ |
| 2116 | 2116 | } |
| r20931 | r20932 | |
| 2118 | 2118 | { |
| 2119 | 2119 | m_input_type = 0; |
| 2120 | 2120 | cworld_decode(machine()); |
| 2121 | | configure_banks(machine()); |
| 2121 | configure_banks(); |
| 2122 | 2122 | } |
| 2123 | 2123 | DRIVER_INIT_MEMBER(mitchell_state,hatena) |
| 2124 | 2124 | { |
| 2125 | 2125 | m_input_type = 0; |
| 2126 | 2126 | hatena_decode(machine()); |
| 2127 | | configure_banks(machine()); |
| 2127 | configure_banks(); |
| 2128 | 2128 | } |
| 2129 | 2129 | DRIVER_INIT_MEMBER(mitchell_state,spang) |
| 2130 | 2130 | { |
| 2131 | 2131 | m_input_type = 3; |
| 2132 | 2132 | m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */ |
| 2133 | 2133 | spang_decode(machine()); |
| 2134 | | configure_banks(machine()); |
| 2134 | configure_banks(); |
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | DRIVER_INIT_MEMBER(mitchell_state,spangbl) |
| 2138 | 2138 | { |
| 2139 | 2139 | m_input_type = 3; |
| 2140 | 2140 | m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */ |
| 2141 | | bootleg_decode(machine()); |
| 2142 | | configure_banks(machine()); |
| 2141 | bootleg_decode(); |
| 2142 | configure_banks(); |
| 2143 | 2143 | } |
| 2144 | 2144 | |
| 2145 | 2145 | DRIVER_INIT_MEMBER(mitchell_state,spangj) |
| r20931 | r20932 | |
| 2147 | 2147 | m_input_type = 3; |
| 2148 | 2148 | m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */ |
| 2149 | 2149 | spangj_decode(machine()); |
| 2150 | | configure_banks(machine()); |
| 2150 | configure_banks(); |
| 2151 | 2151 | } |
| 2152 | 2152 | DRIVER_INIT_MEMBER(mitchell_state,sbbros) |
| 2153 | 2153 | { |
| 2154 | 2154 | m_input_type = 3; |
| 2155 | 2155 | m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */ |
| 2156 | 2156 | sbbros_decode(machine()); |
| 2157 | | configure_banks(machine()); |
| 2157 | configure_banks(); |
| 2158 | 2158 | } |
| 2159 | 2159 | DRIVER_INIT_MEMBER(mitchell_state,qtono1) |
| 2160 | 2160 | { |
| 2161 | 2161 | m_input_type = 0; |
| 2162 | 2162 | qtono1_decode(machine()); |
| 2163 | | configure_banks(machine()); |
| 2163 | configure_banks(); |
| 2164 | 2164 | } |
| 2165 | 2165 | DRIVER_INIT_MEMBER(mitchell_state,qsangoku) |
| 2166 | 2166 | { |
| 2167 | 2167 | m_input_type = 0; |
| 2168 | 2168 | qsangoku_decode(machine()); |
| 2169 | | configure_banks(machine()); |
| 2169 | configure_banks(); |
| 2170 | 2170 | } |
| 2171 | 2171 | DRIVER_INIT_MEMBER(mitchell_state,mgakuen) |
| 2172 | 2172 | { |
| 2173 | 2173 | m_input_type = 1; |
| 2174 | | configure_banks(machine()); |
| 2174 | configure_banks(); |
| 2175 | 2175 | machine().device("maincpu")->memory().space(AS_IO).install_read_port(0x03, 0x03, "DSW0"); |
| 2176 | 2176 | machine().device("maincpu")->memory().space(AS_IO).install_read_port(0x04, 0x04, "DSW1"); |
| 2177 | 2177 | } |
| r20931 | r20932 | |
| 2179 | 2179 | { |
| 2180 | 2180 | m_input_type = 1; |
| 2181 | 2181 | mgakuen2_decode(machine()); |
| 2182 | | configure_banks(machine()); |
| 2182 | configure_banks(); |
| 2183 | 2183 | } |
| 2184 | 2184 | DRIVER_INIT_MEMBER(mitchell_state,pkladies) |
| 2185 | 2185 | { |
| 2186 | 2186 | m_input_type = 1; |
| 2187 | 2187 | mgakuen2_decode(machine()); |
| 2188 | | configure_banks(machine()); |
| 2188 | configure_banks(); |
| 2189 | 2189 | } |
| 2190 | 2190 | DRIVER_INIT_MEMBER(mitchell_state,pkladiesbl) |
| 2191 | 2191 | { |
| 2192 | 2192 | m_input_type = 1; |
| 2193 | | bootleg_decode(machine()); |
| 2194 | | configure_banks(machine()); |
| 2193 | bootleg_decode(); |
| 2194 | configure_banks(); |
| 2195 | 2195 | } |
| 2196 | 2196 | DRIVER_INIT_MEMBER(mitchell_state,marukin) |
| 2197 | 2197 | { |
| 2198 | 2198 | m_input_type = 1; |
| 2199 | 2199 | marukin_decode(machine()); |
| 2200 | | configure_banks(machine()); |
| 2200 | configure_banks(); |
| 2201 | 2201 | } |
| 2202 | 2202 | DRIVER_INIT_MEMBER(mitchell_state,block) |
| 2203 | 2203 | { |
| 2204 | 2204 | m_input_type = 2; |
| 2205 | 2205 | m_nvram->set_base(&memregion("maincpu")->base()[0xff80], 0x80); /* NVRAM */ |
| 2206 | 2206 | block_decode(machine()); |
| 2207 | | configure_banks(machine()); |
| 2207 | configure_banks(); |
| 2208 | 2208 | } |
| 2209 | 2209 | DRIVER_INIT_MEMBER(mitchell_state,blockbl) |
| 2210 | 2210 | { |
| 2211 | 2211 | m_input_type = 2; |
| 2212 | 2212 | m_nvram->set_base(&memregion("maincpu")->base()[0xff80], 0x80); /* NVRAM */ |
| 2213 | | bootleg_decode(machine()); |
| 2214 | | configure_banks(machine()); |
| 2213 | bootleg_decode(); |
| 2214 | configure_banks(); |
| 2215 | 2215 | } |
| 2216 | 2216 | |
| 2217 | 2217 | DRIVER_INIT_MEMBER(mitchell_state,mstworld) |
| r20931 | r20932 | |
| 2257 | 2257 | } |
| 2258 | 2258 | auto_free(machine(), source); |
| 2259 | 2259 | |
| 2260 | | bootleg_decode(machine()); |
| 2261 | | configure_banks(machine()); |
| 2260 | bootleg_decode(); |
| 2261 | configure_banks(); |
| 2262 | 2262 | } |
| 2263 | 2263 | |
| 2264 | 2264 | |
trunk/src/mame/drivers/mcr3.c
| r20931 | r20932 | |
| 1523 | 1523 | * |
| 1524 | 1524 | *************************************/ |
| 1525 | 1525 | |
| 1526 | | static void mcr_common_init(running_machine &machine) |
| 1526 | void mcr3_state::mcr_common_init() |
| 1527 | 1527 | { |
| 1528 | | mcr3_state *state = machine.driver_data<mcr3_state>(); |
| 1529 | | |
| 1530 | | state_save_register_global(machine, state->m_input_mux); |
| 1531 | | state_save_register_global(machine, state->m_latched_input); |
| 1532 | | state_save_register_global(machine, state->m_last_op4); |
| 1528 | state_save_register_global(machine(), m_input_mux); |
| 1529 | state_save_register_global(machine(), m_latched_input); |
| 1530 | state_save_register_global(machine(), m_last_op4); |
| 1533 | 1531 | } |
| 1534 | 1532 | |
| 1535 | 1533 | |
| 1536 | 1534 | DRIVER_INIT_MEMBER(mcr3_state,demoderm) |
| 1537 | 1535 | { |
| 1538 | | mcr_common_init(machine()); |
| 1536 | mcr_common_init(); |
| 1539 | 1537 | machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x01, 0x01, read8_delegate(FUNC(mcr3_state::demoderm_ip1_r),this)); |
| 1540 | 1538 | machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x02, 0x02, read8_delegate(FUNC(mcr3_state::demoderm_ip2_r),this)); |
| 1541 | 1539 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::demoderm_op6_w),this)); |
| r20931 | r20932 | |
| 1544 | 1542 | |
| 1545 | 1543 | DRIVER_INIT_MEMBER(mcr3_state,sarge) |
| 1546 | 1544 | { |
| 1547 | | mcr_common_init(machine()); |
| 1545 | mcr_common_init(); |
| 1548 | 1546 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(midway_turbo_chip_squeak_device::write),m_turbo_chip_squeak.target())); |
| 1549 | 1547 | } |
| 1550 | 1548 | |
| 1551 | 1549 | |
| 1552 | 1550 | DRIVER_INIT_MEMBER(mcr3_state,maxrpm) |
| 1553 | 1551 | { |
| 1554 | | mcr_common_init(machine()); |
| 1552 | mcr_common_init(); |
| 1555 | 1553 | machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x01, 0x01, read8_delegate(FUNC(mcr3_state::maxrpm_ip1_r),this)); |
| 1556 | 1554 | machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x02, 0x02, read8_delegate(FUNC(mcr3_state::maxrpm_ip2_r),this)); |
| 1557 | 1555 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x05, 0x05, write8_delegate(FUNC(mcr3_state::maxrpm_op5_w),this)); |
| r20931 | r20932 | |
| 1567 | 1565 | |
| 1568 | 1566 | DRIVER_INIT_MEMBER(mcr3_state,rampage) |
| 1569 | 1567 | { |
| 1570 | | mcr_common_init(machine()); |
| 1568 | mcr_common_init(); |
| 1571 | 1569 | machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x04, 0x04, read8_delegate(FUNC(mcr3_state::rampage_ip4_r),this)); |
| 1572 | 1570 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::rampage_op6_w),this)); |
| 1573 | 1571 | } |
| r20931 | r20932 | |
| 1575 | 1573 | |
| 1576 | 1574 | DRIVER_INIT_MEMBER(mcr3_state,powerdrv) |
| 1577 | 1575 | { |
| 1578 | | mcr_common_init(machine()); |
| 1576 | mcr_common_init(); |
| 1579 | 1577 | machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x02, 0x02, read8_delegate(FUNC(mcr3_state::powerdrv_ip2_r),this)); |
| 1580 | 1578 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x05, 0x05, write8_delegate(FUNC(mcr3_state::powerdrv_op5_w),this)); |
| 1581 | 1579 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::powerdrv_op6_w),this)); |
| r20931 | r20932 | |
| 1584 | 1582 | |
| 1585 | 1583 | DRIVER_INIT_MEMBER(mcr3_state,stargrds) |
| 1586 | 1584 | { |
| 1587 | | mcr_common_init(machine()); |
| 1585 | mcr_common_init(); |
| 1588 | 1586 | machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x00, 0x00, read8_delegate(FUNC(mcr3_state::stargrds_ip0_r),this)); |
| 1589 | 1587 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x05, 0x05, write8_delegate(FUNC(mcr3_state::stargrds_op5_w),this)); |
| 1590 | 1588 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::stargrds_op6_w),this)); |
| r20931 | r20932 | |
| 1593 | 1591 | |
| 1594 | 1592 | DRIVER_INIT_MEMBER(mcr3_state,spyhunt) |
| 1595 | 1593 | { |
| 1596 | | mcr_common_init(machine()); |
| 1594 | mcr_common_init(); |
| 1597 | 1595 | machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0x60, read8_delegate(FUNC(mcr3_state::spyhunt_ip1_r),this)); |
| 1598 | 1596 | machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xff, read8_delegate(FUNC(mcr3_state::spyhunt_ip2_r),this)); |
| 1599 | 1597 | machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr3_state::spyhunt_op4_w),this)); |
| r20931 | r20932 | |
| 1605 | 1603 | |
| 1606 | 1604 | DRIVER_INIT_MEMBER(mcr3_state,crater) |
| 1607 | 1605 | { |
| 1608 | | mcr_common_init(machine()); |
| 1606 | mcr_common_init(); |
| 1609 | 1607 | |
| 1610 | 1608 | m_spyhunt_sprite_color_mask = 0x03; |
| 1611 | 1609 | m_spyhunt_scroll_offset = 96; |
| r20931 | r20932 | |
| 1614 | 1612 | |
| 1615 | 1613 | DRIVER_INIT_MEMBER(mcr3_state,turbotag) |
| 1616 | 1614 | { |
| 1617 | | mcr_common_init(machine()); |
| 1615 | mcr_common_init(); |
| 1618 | 1616 | machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0x60, read8_delegate(FUNC(mcr3_state::spyhunt_ip1_r),this)); |
| 1619 | 1617 | machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xff, read8_delegate(FUNC(mcr3_state::turbotag_ip2_r),this)); |
| 1620 | 1618 | machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr3_state::spyhunt_op4_w),this)); |
trunk/src/mame/drivers/m72.c
| r20931 | r20932 | |
| 412 | 412 | ***************************************************************************/ |
| 413 | 413 | |
| 414 | 414 | #if 0 |
| 415 | | static int find_sample(int num) |
| 415 | int m72_state::find_sample(int num) |
| 416 | 416 | { |
| 417 | | UINT8 *rom = machine.root_device().memregion("samples")->base(); |
| 418 | | int len = machine.root_device().memregion("samples")->bytes(); |
| 417 | UINT8 *rom = machine().root_device().memregion("samples")->base(); |
| 418 | int len = machine().root_device().memregion("samples")->bytes(); |
| 419 | 419 | int addr = 0; |
| 420 | 420 | |
| 421 | 421 | while (num--) |
| r20931 | r20932 | |
| 683 | 683 | |
| 684 | 684 | |
| 685 | 685 | |
| 686 | | static void copy_le(UINT16 *dest, const UINT8 *src, UINT8 bytes) |
| 686 | void m72_state::copy_le(UINT16 *dest, const UINT8 *src, UINT8 bytes) |
| 687 | 687 | { |
| 688 | 688 | int i; |
| 689 | 689 | |
| r20931 | r20932 | |
| 708 | 708 | copy_le(&m_protection_ram[0x0fe0],m_protection_crc,CRC_LEN); |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | | static void install_protection_handler(running_machine &machine, const UINT8 *code,const UINT8 *crc) |
| 711 | void m72_state::install_protection_handler(const UINT8 *code,const UINT8 *crc) |
| 712 | 712 | { |
| 713 | | m72_state *state = machine.driver_data<m72_state>(); |
| 714 | | state->m_protection_ram = auto_alloc_array(machine, UINT16, 0x1000/2); |
| 715 | | state->m_protection_code = code; |
| 716 | | state->m_protection_crc = crc; |
| 717 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xb0000, 0xb0fff, "bank1"); |
| 718 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xb0ffa, 0xb0ffb, read16_delegate(FUNC(m72_state::protection_r),state)); |
| 719 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xb0000, 0xb0fff, write16_delegate(FUNC(m72_state::protection_w),state)); |
| 720 | | state->membank("bank1")->set_base(state->m_protection_ram); |
| 713 | m_protection_ram = auto_alloc_array(machine(), UINT16, 0x1000/2); |
| 714 | m_protection_code = code; |
| 715 | m_protection_crc = crc; |
| 716 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xb0000, 0xb0fff, "bank1"); |
| 717 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xb0ffa, 0xb0ffb, read16_delegate(FUNC(m72_state::protection_r),this)); |
| 718 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xb0000, 0xb0fff, write16_delegate(FUNC(m72_state::protection_w),this)); |
| 719 | membank("bank1")->set_base(m_protection_ram); |
| 721 | 720 | } |
| 722 | 721 | |
| 723 | 722 | DRIVER_INIT_MEMBER(m72_state,bchopper) |
| 724 | 723 | { |
| 725 | | install_protection_handler(machine(), bchopper_code,bchopper_crc); |
| 724 | install_protection_handler(bchopper_code,bchopper_crc); |
| 726 | 725 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::bchopper_sample_trigger_w),this)); |
| 727 | 726 | } |
| 728 | 727 | |
| 729 | 728 | DRIVER_INIT_MEMBER(m72_state,mrheli) |
| 730 | 729 | { |
| 731 | | install_protection_handler(machine(), bchopper_code,mrheli_crc); |
| 730 | install_protection_handler(bchopper_code,mrheli_crc); |
| 732 | 731 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::bchopper_sample_trigger_w),this)); |
| 733 | 732 | } |
| 734 | 733 | |
| 735 | 734 | DRIVER_INIT_MEMBER(m72_state,nspirit) |
| 736 | 735 | { |
| 737 | | install_protection_handler(machine(), nspirit_code,nspirit_crc); |
| 736 | install_protection_handler(nspirit_code,nspirit_crc); |
| 738 | 737 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::nspirit_sample_trigger_w),this)); |
| 739 | 738 | } |
| 740 | 739 | |
| 741 | 740 | DRIVER_INIT_MEMBER(m72_state,imgfight) |
| 742 | 741 | { |
| 743 | | install_protection_handler(machine(), imgfight_code,imgfightj_crc); |
| 742 | install_protection_handler(imgfight_code,imgfightj_crc); |
| 744 | 743 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::imgfight_sample_trigger_w),this)); |
| 745 | 744 | } |
| 746 | 745 | |
| 747 | 746 | DRIVER_INIT_MEMBER(m72_state,loht) |
| 748 | 747 | { |
| 749 | | install_protection_handler(machine(), loht_code,loht_crc); |
| 748 | install_protection_handler(loht_code,loht_crc); |
| 750 | 749 | |
| 751 | 750 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::loht_sample_trigger_w),this)); |
| 752 | 751 | |
| r20931 | r20932 | |
| 756 | 755 | |
| 757 | 756 | DRIVER_INIT_MEMBER(m72_state,xmultiplm72) |
| 758 | 757 | { |
| 759 | | install_protection_handler(machine(), xmultiplm72_code,xmultiplm72_crc); |
| 758 | install_protection_handler(xmultiplm72_code,xmultiplm72_crc); |
| 760 | 759 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::xmultiplm72_sample_trigger_w),this)); |
| 761 | 760 | } |
| 762 | 761 | |
| 763 | 762 | DRIVER_INIT_MEMBER(m72_state,dbreedm72) |
| 764 | 763 | { |
| 765 | | install_protection_handler(machine(), dbreedm72_code,dbreedm72_crc); |
| 764 | install_protection_handler(dbreedm72_code,dbreedm72_crc); |
| 766 | 765 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::dbreedm72_sample_trigger_w),this)); |
| 767 | 766 | } |
| 768 | 767 | |
| 769 | 768 | DRIVER_INIT_MEMBER(m72_state,airduel) |
| 770 | 769 | { |
| 771 | | install_protection_handler(machine(), airduel_code,airduel_crc); |
| 770 | install_protection_handler(airduel_code,airduel_crc); |
| 772 | 771 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::airduel_sample_trigger_w),this)); |
| 773 | 772 | } |
| 774 | 773 | |
| 775 | 774 | DRIVER_INIT_MEMBER(m72_state,dkgenm72) |
| 776 | 775 | { |
| 777 | | install_protection_handler(machine(), dkgenm72_code,dkgenm72_crc); |
| 776 | install_protection_handler(dkgenm72_code,dkgenm72_crc); |
| 778 | 777 | machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::dkgenm72_sample_trigger_w),this)); |
| 779 | 778 | } |
| 780 | 779 | |
trunk/src/mame/machine/mexico86.c
| r20931 | r20932 | |
| 41 | 41 | |
| 42 | 42 | ***************************************************************************/ |
| 43 | 43 | |
| 44 | | static void mcu_simulate( running_machine &machine ) |
| 44 | void mexico86_state::mcu_simulate( ) |
| 45 | 45 | { |
| 46 | | mexico86_state *state = machine.driver_data<mexico86_state>(); |
| 47 | 46 | |
| 48 | | if (!state->m_mcu_initialised) |
| 47 | if (!m_mcu_initialised) |
| 49 | 48 | { |
| 50 | | if (state->m_protection_ram[0x01] == 0x00) |
| 49 | if (m_protection_ram[0x01] == 0x00) |
| 51 | 50 | { |
| 52 | 51 | logerror("initialising MCU\n"); |
| 53 | | state->m_protection_ram[0x04] = 0xfc; // coin inputs |
| 54 | | state->m_protection_ram[0x02] = 0xff; // player 1 |
| 55 | | state->m_protection_ram[0x03] = 0xff; // player 2 |
| 56 | | state->m_protection_ram[0x1b] = 0xff; // active player |
| 57 | | state->m_protection_ram[0x06] = 0xff; // must be FF otherwise PS4 ERROR |
| 58 | | state->m_protection_ram[0x07] = 0x03; // must be 03 otherwise PS4 ERROR |
| 59 | | state->m_protection_ram[0x00] = 0x00; |
| 60 | | state->m_mcu_initialised = 1; |
| 52 | m_protection_ram[0x04] = 0xfc; // coin inputs |
| 53 | m_protection_ram[0x02] = 0xff; // player 1 |
| 54 | m_protection_ram[0x03] = 0xff; // player 2 |
| 55 | m_protection_ram[0x1b] = 0xff; // active player |
| 56 | m_protection_ram[0x06] = 0xff; // must be FF otherwise PS4 ERROR |
| 57 | m_protection_ram[0x07] = 0x03; // must be 03 otherwise PS4 ERROR |
| 58 | m_protection_ram[0x00] = 0x00; |
| 59 | m_mcu_initialised = 1; |
| 61 | 60 | } |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | | if (state->m_mcu_initialised) |
| 63 | if (m_mcu_initialised) |
| 65 | 64 | { |
| 66 | 65 | int i; |
| 67 | 66 | int coin_curr; |
| 68 | 67 | |
| 69 | | coin_curr = ~machine.root_device().ioport("IN0")->read() & 1; |
| 70 | | if (coin_curr && !state->m_coin_last && state->m_protection_ram[0x01] < 9) |
| 68 | coin_curr = ~machine().root_device().ioport("IN0")->read() & 1; |
| 69 | if (coin_curr && !m_coin_last && m_protection_ram[0x01] < 9) |
| 71 | 70 | { |
| 72 | | state->m_protection_ram[0x01]++; // increase credits counter |
| 73 | | state->m_protection_ram[0x0a] = 0x01; // set flag (coin inserted sound is not played otherwise) |
| 71 | m_protection_ram[0x01]++; // increase credits counter |
| 72 | m_protection_ram[0x0a] = 0x01; // set flag (coin inserted sound is not played otherwise) |
| 74 | 73 | } |
| 75 | | state->m_coin_last = coin_curr; |
| 74 | m_coin_last = coin_curr; |
| 76 | 75 | |
| 77 | | state->m_protection_ram[0x04] = 0x3c; // coin inputs |
| 76 | m_protection_ram[0x04] = 0x3c; // coin inputs |
| 78 | 77 | |
| 79 | | state->m_protection_ram[0x02] = BITSWAP8(machine.root_device().ioport("IN1")->read(), 7,6,5,4,2,3,1,0); // player 1 |
| 80 | | state->m_protection_ram[0x03] = BITSWAP8(machine.root_device().ioport("IN2")->read(), 7,6,5,4,2,3,1,0); // player 2 |
| 78 | m_protection_ram[0x02] = BITSWAP8(machine().root_device().ioport("IN1")->read(), 7,6,5,4,2,3,1,0); // player 1 |
| 79 | m_protection_ram[0x03] = BITSWAP8(machine().root_device().ioport("IN2")->read(), 7,6,5,4,2,3,1,0); // player 2 |
| 81 | 80 | |
| 82 | | if (state->m_protection_ram[0x19] == 0xaa) // player 2 active |
| 83 | | state->m_protection_ram[0x1b] = state->m_protection_ram[0x03]; |
| 81 | if (m_protection_ram[0x19] == 0xaa) // player 2 active |
| 82 | m_protection_ram[0x1b] = m_protection_ram[0x03]; |
| 84 | 83 | else |
| 85 | | state->m_protection_ram[0x1b] = state->m_protection_ram[0x02]; |
| 84 | m_protection_ram[0x1b] = m_protection_ram[0x02]; |
| 86 | 85 | |
| 87 | 86 | |
| 88 | 87 | for (i = 0; i < 0x10; i += 2) |
| 89 | | state->m_protection_ram[i + 0xb1] = state->m_protection_ram[i + 0xb0]; |
| 88 | m_protection_ram[i + 0xb1] = m_protection_ram[i + 0xb0]; |
| 90 | 89 | |
| 91 | 90 | for (i = 0; i < 0x0a; i++) |
| 92 | | state->m_protection_ram[i + 0xc0] = state->m_protection_ram[i + 0x90] + 1; |
| 91 | m_protection_ram[i + 0xc0] = m_protection_ram[i + 0x90] + 1; |
| 93 | 92 | |
| 94 | | if (state->m_protection_ram[0xd1] == 0xff) |
| 93 | if (m_protection_ram[0xd1] == 0xff) |
| 95 | 94 | { |
| 96 | | if (state->m_protection_ram[0xd0] > 0 && state->m_protection_ram[0xd0] < 4) |
| 95 | if (m_protection_ram[0xd0] > 0 && m_protection_ram[0xd0] < 4) |
| 97 | 96 | { |
| 98 | | state->m_protection_ram[0xd2] = 0x81; |
| 99 | | state->m_protection_ram[0xd0] = 0xff; |
| 97 | m_protection_ram[0xd2] = 0x81; |
| 98 | m_protection_ram[0xd0] = 0xff; |
| 100 | 99 | } |
| 101 | 100 | } |
| 102 | 101 | |
| 103 | | if (state->m_protection_ram[0xe0] > 0 && state->m_protection_ram[0xe0] < 4) |
| 102 | if (m_protection_ram[0xe0] > 0 && m_protection_ram[0xe0] < 4) |
| 104 | 103 | { |
| 105 | 104 | static const UINT8 answers[3][16] = |
| 106 | 105 | { |
| r20931 | r20932 | |
| 108 | 107 | { 0x00,0x04,0x08,0x0C,0x10,0x14,0x18,0x1C,0x20,0x31,0x2B,0x35,0x00,0x00,0x00,0x00 }, |
| 109 | 108 | { 0x00,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x03,0x0A,0x0B,0x14,0x00,0x00,0x00,0x00 }, |
| 110 | 109 | }; |
| 111 | | int table = state->m_protection_ram[0xe0] - 1; |
| 110 | int table = m_protection_ram[0xe0] - 1; |
| 112 | 111 | |
| 113 | 112 | for (i = 1; i < 0x10; i++) |
| 114 | | state->m_protection_ram[0xe0 + i] = answers[table][i]; |
| 115 | | state->m_protection_ram[0xe0] = 0xff; |
| 113 | m_protection_ram[0xe0 + i] = answers[table][i]; |
| 114 | m_protection_ram[0xe0] = 0xff; |
| 116 | 115 | } |
| 117 | 116 | |
| 118 | | if (state->m_protection_ram[0xf0] > 0 && state->m_protection_ram[0xf0] < 4) |
| 117 | if (m_protection_ram[0xf0] > 0 && m_protection_ram[0xf0] < 4) |
| 119 | 118 | { |
| 120 | | state->m_protection_ram[0xf1] = 0xb3; |
| 121 | | state->m_protection_ram[0xf0] = 0xff; |
| 119 | m_protection_ram[0xf1] = 0xb3; |
| 120 | m_protection_ram[0xf0] = 0xff; |
| 122 | 121 | } |
| 123 | 122 | |
| 124 | 123 | |
| r20931 | r20932 | |
| 126 | 125 | // this should be equivalent to the obfuscated kiki_clogic() below |
| 127 | 126 | { |
| 128 | 127 | static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00}; |
| 129 | | UINT16 sy = state->m_protection_ram[0xa0] + ((0x18) >> 1); |
| 130 | | UINT16 sx = state->m_protection_ram[0xa1] + ((0x18) >> 1); |
| 128 | UINT16 sy = m_protection_ram[0xa0] + ((0x18) >> 1); |
| 129 | UINT16 sx = m_protection_ram[0xa1] + ((0x18) >> 1); |
| 131 | 130 | |
| 132 | 131 | for (i = 0; i < 0x38; i += 8) |
| 133 | 132 | { |
| 134 | | UINT8 hw = db[state->m_protection_ram[0x20 + i] & 0xf]; |
| 133 | UINT8 hw = db[m_protection_ram[0x20 + i] & 0xf]; |
| 135 | 134 | |
| 136 | 135 | if (hw) |
| 137 | 136 | { |
| 138 | | UINT16 xdiff = sx - ((UINT16)state->m_protection_ram[0x20 + i + 6] << 8 | state->m_protection_ram[0x20 + i + 7]); |
| 137 | UINT16 xdiff = sx - ((UINT16)m_protection_ram[0x20 + i + 6] << 8 | m_protection_ram[0x20 + i + 7]); |
| 139 | 138 | if (xdiff < hw) |
| 140 | 139 | { |
| 141 | | UINT16 ydiff = sy - ((UINT16)state->m_protection_ram[0x20 + i + 4] << 8 | state->m_protection_ram[0x20 + i + 5]); |
| 140 | UINT16 ydiff = sy - ((UINT16)m_protection_ram[0x20 + i + 4] << 8 | m_protection_ram[0x20 + i + 5]); |
| 142 | 141 | if (ydiff < hw) |
| 143 | | state->m_protection_ram[0xa2] = 1; // we have a collision |
| 142 | m_protection_ram[0xa2] = 1; // we have a collision |
| 144 | 143 | } |
| 145 | 144 | } |
| 146 | 145 | } |
| r20931 | r20932 | |
| 152 | 151 | INTERRUPT_GEN_MEMBER(mexico86_state::kikikai_interrupt) |
| 153 | 152 | { |
| 154 | 153 | if (m_mcu_running) |
| 155 | | mcu_simulate(machine()); |
| 154 | mcu_simulate(); |
| 156 | 155 | |
| 157 | 156 | device.execute().set_input_line_vector(0, m_protection_ram[0]); |
| 158 | 157 | device.execute().set_input_line(0, HOLD_LINE); |
| r20931 | r20932 | |
| 171 | 170 | #define DCWIDTH 0 |
| 172 | 171 | #define DCHEIGHT 0 |
| 173 | 172 | |
| 174 | | static void kiki_clogic(running_machine &machine, int address, int latch) |
| 173 | void mexico86_state::kiki_clogic(int address, int latch) |
| 175 | 174 | { |
| 176 | | mexico86_state *state = machine.driver_data<mexico86_state>(); |
| 177 | 175 | static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00}; |
| 178 | 176 | int sy, sx, hw, i, qptr, diff1, diff2; |
| 179 | 177 | |
| 180 | | if (address != KIKI_CL_TRIGGER) // state->m_queue latched data |
| 178 | if (address != KIKI_CL_TRIGGER) // m_queue latched data |
| 181 | 179 | { |
| 182 | | state->m_queue[state->m_qfront++] = latch; |
| 183 | | state->m_qfront &= 0x3f; |
| 180 | m_queue[m_qfront++] = latch; |
| 181 | m_qfront &= 0x3f; |
| 184 | 182 | } |
| 185 | | else if (state->m_qstate ^= 1) // scan state->m_queue |
| 183 | else if (m_qstate ^= 1) // scan m_queue |
| 186 | 184 | { |
| 187 | | sy = state->m_queue[(state->m_qfront-0x3a)&0x3f] + ((0x18-DCHEIGHT)>>1); |
| 188 | | sx = state->m_queue[(state->m_qfront-0x39)&0x3f] + ((0x18-DCWIDTH)>>1); |
| 185 | sy = m_queue[(m_qfront-0x3a)&0x3f] + ((0x18-DCHEIGHT)>>1); |
| 186 | sx = m_queue[(m_qfront-0x39)&0x3f] + ((0x18-DCWIDTH)>>1); |
| 189 | 187 | |
| 190 | 188 | for (i=0x38; i; i-=8) |
| 191 | 189 | { |
| 192 | | qptr = state->m_qfront - i; |
| 193 | | if (!(hw = db[state->m_queue[qptr&0x3f]&0xf])) continue; |
| 190 | qptr = m_qfront - i; |
| 191 | if (!(hw = db[m_queue[qptr&0x3f]&0xf])) continue; |
| 194 | 192 | |
| 195 | | diff1 = sx - (short)(state->m_queue[(qptr+6)&0x3f]<<8|state->m_queue[(qptr+7)&0x3f]) + DCWIDTH; |
| 193 | diff1 = sx - (short)(m_queue[(qptr+6)&0x3f]<<8|m_queue[(qptr+7)&0x3f]) + DCWIDTH; |
| 196 | 194 | diff2 = diff1 - (hw + DCWIDTH); |
| 197 | 195 | if ((diff1^diff2)<0) |
| 198 | 196 | { |
| 199 | | diff1 = sy - (short)(state->m_queue[(qptr+4)&0x3f]<<8|state->m_queue[(qptr+5)&0x3f]) + DCHEIGHT; |
| 197 | diff1 = sy - (short)(m_queue[(qptr+4)&0x3f]<<8|m_queue[(qptr+5)&0x3f]) + DCHEIGHT; |
| 200 | 198 | diff2 = diff1 - (hw + DCHEIGHT); |
| 201 | 199 | if ((diff1^diff2)<0) |
| 202 | | state->m_protection_ram[KIKI_CL_OUT] = 1; // we have a collision |
| 200 | m_protection_ram[KIKI_CL_OUT] = 1; // we have a collision |
| 203 | 201 | } |
| 204 | 202 | } |
| 205 | 203 | } |
trunk/src/mame/machine/mcr68.c
| r20931 | r20932 | |
| 12 | 12 | #define VERBOSE 0 |
| 13 | 13 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 14 | 14 | |
| 15 | | |
| 16 | 15 | /************************************* |
| 17 | 16 | * |
| 18 | | * Function prototypes |
| 19 | | * |
| 20 | | *************************************/ |
| 21 | | |
| 22 | | static void subtract_from_counter(running_machine &machine, int counter, int count); |
| 23 | | |
| 24 | | /************************************* |
| 25 | | * |
| 26 | 17 | * 6821 PIA declarations |
| 27 | 18 | * |
| 28 | 19 | *************************************/ |
| r20931 | r20932 | |
| 131 | 122 | } |
| 132 | 123 | |
| 133 | 124 | |
| 134 | | static void mcr68_common_init(running_machine &machine) |
| 125 | void mcr68_state::mcr68_common_init() |
| 135 | 126 | { |
| 136 | | mcr68_state *state = machine.driver_data<mcr68_state>(); |
| 137 | 127 | int i; |
| 138 | 128 | |
| 139 | 129 | /* reset the 6840's */ |
| 140 | | state->m_m6840_counter_periods[0] = attotime::from_hz(30); /* clocked by /VBLANK */ |
| 141 | | state->m_m6840_counter_periods[1] = attotime::never; /* grounded */ |
| 142 | | state->m_m6840_counter_periods[2] = attotime::from_hz(512 * 30); /* clocked by /HSYNC */ |
| 130 | m_m6840_counter_periods[0] = attotime::from_hz(30); /* clocked by /VBLANK */ |
| 131 | m_m6840_counter_periods[1] = attotime::never; /* grounded */ |
| 132 | m_m6840_counter_periods[2] = attotime::from_hz(512 * 30); /* clocked by /HSYNC */ |
| 143 | 133 | |
| 144 | | state->m_m6840_status = 0x00; |
| 145 | | state->m_m6840_status_read_since_int = 0x00; |
| 146 | | state->m_m6840_msb_buffer = state->m_m6840_lsb_buffer = 0; |
| 134 | m_m6840_status = 0x00; |
| 135 | m_m6840_status_read_since_int = 0x00; |
| 136 | m_m6840_msb_buffer = m_m6840_lsb_buffer = 0; |
| 147 | 137 | for (i = 0; i < 3; i++) |
| 148 | 138 | { |
| 149 | | struct counter_state *m6840 = &state->m_m6840_state[i]; |
| 139 | struct counter_state *m6840 = &m_m6840_state[i]; |
| 150 | 140 | |
| 151 | 141 | m6840->control = 0x00; |
| 152 | 142 | m6840->latch = 0xffff; |
| 153 | 143 | m6840->count = 0xffff; |
| 154 | 144 | m6840->timer->enable(false); |
| 155 | 145 | m6840->timer_active = 0; |
| 156 | | m6840->period = state->m_m6840_counter_periods[i]; |
| 146 | m6840->period = m_m6840_counter_periods[i]; |
| 157 | 147 | } |
| 158 | 148 | |
| 159 | 149 | /* initialize the clock */ |
| 160 | | state->m_m6840_internal_counter_period = attotime::from_hz(machine.device("maincpu")->unscaled_clock() / 10); |
| 150 | m_m6840_internal_counter_period = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10); |
| 161 | 151 | } |
| 162 | 152 | |
| 163 | 153 | |
| 164 | 154 | MACHINE_RESET_MEMBER(mcr68_state,mcr68) |
| 165 | 155 | { |
| 166 | 156 | /* for the most part all MCR/68k games are the same */ |
| 167 | | mcr68_common_init(machine()); |
| 157 | mcr68_common_init(); |
| 168 | 158 | m_v493_callback = timer_expired_delegate(FUNC(mcr68_state::mcr68_493_callback),this); |
| 169 | 159 | |
| 170 | 160 | /* vectors are 1 and 2 */ |
| r20931 | r20932 | |
| 182 | 172 | MACHINE_RESET_MEMBER(mcr68_state,zwackery) |
| 183 | 173 | { |
| 184 | 174 | /* for the most part all MCR/68k games are the same */ |
| 185 | | mcr68_common_init(machine()); |
| 175 | mcr68_common_init(); |
| 186 | 176 | m_v493_callback = timer_expired_delegate(FUNC(mcr68_state::zwackery_493_callback),this); |
| 187 | 177 | |
| 188 | 178 | /* vectors are 5 and 6 */ |
| r20931 | r20932 | |
| 202 | 192 | { |
| 203 | 193 | /* update the 6840 VBLANK clock */ |
| 204 | 194 | if (!m_m6840_state[0].timer_active) |
| 205 | | subtract_from_counter(machine(), 0, 1); |
| 195 | subtract_from_counter(0, 1); |
| 206 | 196 | |
| 207 | 197 | logerror("--- VBLANK ---\n"); |
| 208 | 198 | |
| r20931 | r20932 | |
| 220 | 210 | * |
| 221 | 211 | *************************************/ |
| 222 | 212 | |
| 223 | | static void update_mcr68_interrupts(running_machine &machine) |
| 213 | void mcr68_state::update_mcr68_interrupts() |
| 224 | 214 | { |
| 225 | | mcr68_state *state = machine.driver_data<mcr68_state>(); |
| 226 | | machine.device("maincpu")->execute().set_input_line(state->m_v493_irq_vector, state->m_v493_irq_state ? ASSERT_LINE : CLEAR_LINE); |
| 227 | | machine.device("maincpu")->execute().set_input_line(state->m_m6840_irq_vector, state->m_m6840_irq_state ? ASSERT_LINE : CLEAR_LINE); |
| 215 | machine().device("maincpu")->execute().set_input_line(m_v493_irq_vector, m_v493_irq_state ? ASSERT_LINE : CLEAR_LINE); |
| 216 | machine().device("maincpu")->execute().set_input_line(m_m6840_irq_vector, m_m6840_irq_state ? ASSERT_LINE : CLEAR_LINE); |
| 228 | 217 | } |
| 229 | 218 | |
| 230 | 219 | |
| 231 | 220 | TIMER_CALLBACK_MEMBER(mcr68_state::mcr68_493_off_callback) |
| 232 | 221 | { |
| 233 | 222 | m_v493_irq_state = 0; |
| 234 | | update_mcr68_interrupts(machine()); |
| 223 | update_mcr68_interrupts(); |
| 235 | 224 | } |
| 236 | 225 | |
| 237 | 226 | |
| 238 | 227 | TIMER_CALLBACK_MEMBER(mcr68_state::mcr68_493_callback) |
| 239 | 228 | { |
| 240 | 229 | m_v493_irq_state = 1; |
| 241 | | update_mcr68_interrupts(machine()); |
| 230 | update_mcr68_interrupts(); |
| 242 | 231 | machine().scheduler().timer_set(machine().primary_screen->scan_period(), timer_expired_delegate(FUNC(mcr68_state::mcr68_493_off_callback),this)); |
| 243 | 232 | logerror("--- (INT1) ---\n"); |
| 244 | 233 | } |
| r20931 | r20932 | |
| 279 | 268 | { |
| 280 | 269 | pia6821_device *pia = machine().device<pia6821_device>("pia0"); |
| 281 | 270 | m_v493_irq_state = pia->irq_a_state() | pia->irq_b_state(); |
| 282 | | update_mcr68_interrupts(machine()); |
| 271 | update_mcr68_interrupts(); |
| 283 | 272 | } |
| 284 | 273 | |
| 285 | 274 | |
| r20931 | r20932 | |
| 306 | 295 | * |
| 307 | 296 | *************************************/ |
| 308 | 297 | |
| 309 | | INLINE void update_interrupts(running_machine &machine) |
| 298 | inline void mcr68_state::update_interrupts() |
| 310 | 299 | { |
| 311 | | mcr68_state *state = machine.driver_data<mcr68_state>(); |
| 312 | | state->m_m6840_status &= ~0x80; |
| 300 | m_m6840_status &= ~0x80; |
| 313 | 301 | |
| 314 | | if ((state->m_m6840_status & 0x01) && (state->m_m6840_state[0].control & 0x40)) state->m_m6840_status |= 0x80; |
| 315 | | if ((state->m_m6840_status & 0x02) && (state->m_m6840_state[1].control & 0x40)) state->m_m6840_status |= 0x80; |
| 316 | | if ((state->m_m6840_status & 0x04) && (state->m_m6840_state[2].control & 0x40)) state->m_m6840_status |= 0x80; |
| 302 | if ((m_m6840_status & 0x01) && (m_m6840_state[0].control & 0x40)) m_m6840_status |= 0x80; |
| 303 | if ((m_m6840_status & 0x02) && (m_m6840_state[1].control & 0x40)) m_m6840_status |= 0x80; |
| 304 | if ((m_m6840_status & 0x04) && (m_m6840_state[2].control & 0x40)) m_m6840_status |= 0x80; |
| 317 | 305 | |
| 318 | | state->m_m6840_irq_state = state->m_m6840_status >> 7; |
| 319 | | update_mcr68_interrupts(machine); |
| 306 | m_m6840_irq_state = m_m6840_status >> 7; |
| 307 | update_mcr68_interrupts(); |
| 320 | 308 | } |
| 321 | 309 | |
| 322 | 310 | |
| 323 | | static void subtract_from_counter(running_machine &machine, int counter, int count) |
| 311 | void mcr68_state::subtract_from_counter(int counter, int count) |
| 324 | 312 | { |
| 325 | | mcr68_state *state = machine.driver_data<mcr68_state>(); |
| 326 | | struct counter_state *m6840 = &state->m_m6840_state[counter]; |
| 313 | struct counter_state *m6840 = &m_m6840_state[counter]; |
| 327 | 314 | |
| 328 | 315 | /* dual-byte mode */ |
| 329 | 316 | if (m6840->control & 0x04) |
| r20931 | r20932 | |
| 344 | 331 | /* if MSB goes less than zero, we've expired */ |
| 345 | 332 | if (msb < 0) |
| 346 | 333 | { |
| 347 | | state->m_m6840_status |= 1 << counter; |
| 348 | | state->m_m6840_status_read_since_int &= ~(1 << counter); |
| 349 | | update_interrupts(machine); |
| 334 | m_m6840_status |= 1 << counter; |
| 335 | m_m6840_status_read_since_int &= ~(1 << counter); |
| 336 | update_interrupts(); |
| 350 | 337 | msb = (m6840->latch >> 8) + 1; |
| 351 | 338 | LOG(("** Counter %d fired\n", counter)); |
| 352 | 339 | } |
| r20931 | r20932 | |
| 371 | 358 | word += m6840->latch + 1; |
| 372 | 359 | |
| 373 | 360 | /* we've expired */ |
| 374 | | state->m_m6840_status |= 1 << counter; |
| 375 | | state->m_m6840_status_read_since_int &= ~(1 << counter); |
| 376 | | update_interrupts(machine); |
| 361 | m_m6840_status |= 1 << counter; |
| 362 | m_m6840_status_read_since_int &= ~(1 << counter); |
| 363 | update_interrupts(); |
| 377 | 364 | LOG(("** Counter %d fired\n", counter)); |
| 378 | 365 | } |
| 379 | 366 | |
| r20931 | r20932 | |
| 393 | 380 | m6840->timer_active = 0; |
| 394 | 381 | |
| 395 | 382 | /* subtract it all from the counter; this will generate an interrupt */ |
| 396 | | subtract_from_counter(machine(), counter, count); |
| 383 | subtract_from_counter(counter, count); |
| 397 | 384 | } |
| 398 | 385 | |
| 399 | 386 | |
| r20931 | r20932 | |
| 508 | 495 | } |
| 509 | 496 | |
| 510 | 497 | m_m6840_status = 0; |
| 511 | | update_interrupts(machine()); |
| 498 | update_interrupts(); |
| 512 | 499 | } |
| 513 | 500 | |
| 514 | 501 | /* changing the clock source? (needed for Zwackery) */ |
| r20931 | r20932 | |
| 534 | 521 | |
| 535 | 522 | /* clear the interrupt */ |
| 536 | 523 | m_m6840_status &= ~(1 << counter); |
| 537 | | update_interrupts(machine()); |
| 524 | update_interrupts(); |
| 538 | 525 | |
| 539 | 526 | /* reload the count if in an appropriate mode */ |
| 540 | 527 | if (!(m6840->control & 0x10)) |
| r20931 | r20932 | |
| 568 | 555 | /* clear the interrupt if the status has been read */ |
| 569 | 556 | if (m_m6840_status_read_since_int & (1 << counter)) |
| 570 | 557 | m_m6840_status &= ~(1 << counter); |
| 571 | | update_interrupts(machine()); |
| 558 | update_interrupts(); |
| 572 | 559 | |
| 573 | 560 | m_m6840_lsb_buffer = result & 0xff; |
| 574 | 561 | |
trunk/src/mame/video/mcr68.c
| r20931 | r20932 | |
| 195 | 195 | * |
| 196 | 196 | *************************************/ |
| 197 | 197 | |
| 198 | | static void mcr68_update_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 198 | void mcr68_state::mcr68_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 199 | 199 | { |
| 200 | | mcr68_state *state = machine.driver_data<mcr68_state>(); |
| 201 | | rectangle sprite_clip = machine.primary_screen->visible_area(); |
| 202 | | UINT16 *spriteram = state->m_spriteram; |
| 200 | rectangle sprite_clip = machine().primary_screen->visible_area(); |
| 201 | UINT16 *spriteram = m_spriteram; |
| 203 | 202 | int offs; |
| 204 | 203 | |
| 205 | 204 | /* adjust for clipping */ |
| 206 | | sprite_clip.min_x += state->m_sprite_clip; |
| 207 | | sprite_clip.max_x -= state->m_sprite_clip; |
| 205 | sprite_clip.min_x += m_sprite_clip; |
| 206 | sprite_clip.max_x -= m_sprite_clip; |
| 208 | 207 | sprite_clip &= cliprect; |
| 209 | 208 | |
| 210 | | machine.priority_bitmap.fill(1, sprite_clip); |
| 209 | machine().priority_bitmap.fill(1, sprite_clip); |
| 211 | 210 | |
| 212 | 211 | /* loop over sprite RAM */ |
| 213 | | for (offs = state->m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4) |
| 212 | for (offs = m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4) |
| 214 | 213 | { |
| 215 | 214 | int code, color, flipx, flipy, x, y, flags; |
| 216 | 215 | |
| r20931 | r20932 | |
| 229 | 228 | color = ~flags & 0x03; |
| 230 | 229 | flipx = flags & 0x10; |
| 231 | 230 | flipy = flags & 0x20; |
| 232 | | x = LOW_BYTE(spriteram[offs + 3]) * 2 + state->m_sprite_xoffset; |
| 231 | x = LOW_BYTE(spriteram[offs + 3]) * 2 + m_sprite_xoffset; |
| 233 | 232 | y = (241 - LOW_BYTE(spriteram[offs])) * 2; |
| 234 | 233 | |
| 235 | 234 | /* allow sprites to clip off the left side */ |
| r20931 | r20932 | |
| 239 | 238 | The color 8 is used to cover over other sprites. */ |
| 240 | 239 | |
| 241 | 240 | /* first draw the sprite, visible */ |
| 242 | | pdrawgfx_transmask(bitmap, sprite_clip, machine.gfx[1], code, color, flipx, flipy, x, y, |
| 243 | | machine.priority_bitmap, 0x00, 0x0101); |
| 241 | pdrawgfx_transmask(bitmap, sprite_clip, machine().gfx[1], code, color, flipx, flipy, x, y, |
| 242 | machine().priority_bitmap, 0x00, 0x0101); |
| 244 | 243 | |
| 245 | 244 | /* then draw the mask, behind the background but obscuring following sprites */ |
| 246 | | pdrawgfx_transmask(bitmap, sprite_clip, machine.gfx[1], code, color, flipx, flipy, x, y, |
| 247 | | machine.priority_bitmap, 0x02, 0xfeff); |
| 245 | pdrawgfx_transmask(bitmap, sprite_clip, machine().gfx[1], code, color, flipx, flipy, x, y, |
| 246 | machine().priority_bitmap, 0x02, 0xfeff); |
| 248 | 247 | } |
| 249 | 248 | } |
| 250 | 249 | |
| 251 | 250 | |
| 252 | | static void zwackery_update_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 251 | void mcr68_state::zwackery_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority) |
| 253 | 252 | { |
| 254 | | mcr68_state *state = machine.driver_data<mcr68_state>(); |
| 255 | | UINT16 *spriteram = state->m_spriteram; |
| 253 | UINT16 *spriteram = m_spriteram; |
| 256 | 254 | int offs; |
| 257 | 255 | |
| 258 | | machine.priority_bitmap.fill(1, cliprect); |
| 256 | machine().priority_bitmap.fill(1, cliprect); |
| 259 | 257 | |
| 260 | 258 | /* loop over sprite RAM */ |
| 261 | | for (offs = state->m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4) |
| 259 | for (offs = m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4) |
| 262 | 260 | { |
| 263 | 261 | int code, color, flipx, flipy, x, y, flags; |
| 264 | 262 | |
| r20931 | r20932 | |
| 297 | 295 | The color 8 is used to cover over other sprites. */ |
| 298 | 296 | |
| 299 | 297 | /* first draw the sprite, visible */ |
| 300 | | pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, x, y, |
| 301 | | machine.priority_bitmap, 0x00, 0x0101); |
| 298 | pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, x, y, |
| 299 | machine().priority_bitmap, 0x00, 0x0101); |
| 302 | 300 | |
| 303 | 301 | /* then draw the mask, behind the background but obscuring following sprites */ |
| 304 | | pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, x, y, |
| 305 | | machine.priority_bitmap, 0x02, 0xfeff); |
| 302 | pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, x, y, |
| 303 | machine().priority_bitmap, 0x02, 0xfeff); |
| 306 | 304 | } |
| 307 | 305 | } |
| 308 | 306 | |
| r20931 | r20932 | |
| 320 | 318 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0); |
| 321 | 319 | |
| 322 | 320 | /* draw the low-priority sprites */ |
| 323 | | mcr68_update_sprites(machine(), bitmap, cliprect, 0); |
| 321 | mcr68_update_sprites(bitmap, cliprect, 0); |
| 324 | 322 | |
| 325 | 323 | /* redraw tiles with priority over sprites */ |
| 326 | 324 | m_bg_tilemap->draw(bitmap, cliprect, 1, 0); |
| 327 | 325 | |
| 328 | 326 | /* draw the high-priority sprites */ |
| 329 | | mcr68_update_sprites(machine(), bitmap, cliprect, 1); |
| 327 | mcr68_update_sprites(bitmap, cliprect, 1); |
| 330 | 328 | return 0; |
| 331 | 329 | } |
| 332 | 330 | |
| r20931 | r20932 | |
| 337 | 335 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 338 | 336 | |
| 339 | 337 | /* draw the low-priority sprites */ |
| 340 | | zwackery_update_sprites(machine(), bitmap, cliprect, 0); |
| 338 | zwackery_update_sprites(bitmap, cliprect, 0); |
| 341 | 339 | |
| 342 | 340 | /* redraw tiles with priority over sprites */ |
| 343 | 341 | m_fg_tilemap->draw(bitmap, cliprect, 1, 0); |
| 344 | 342 | |
| 345 | 343 | /* draw the high-priority sprites */ |
| 346 | | zwackery_update_sprites(machine(), bitmap, cliprect, 1); |
| 344 | zwackery_update_sprites(bitmap, cliprect, 1); |
| 347 | 345 | return 0; |
| 348 | 346 | } |
trunk/src/mame/video/m62.c
| r20931 | r20932 | |
| 180 | 180 | }; |
| 181 | 181 | |
| 182 | 182 | |
| 183 | | static void m62_amplify_contrast(palette_t *palette, UINT32 numcolors) |
| 183 | void m62_state::m62_amplify_contrast(palette_t *palette, UINT32 numcolors) |
| 184 | 184 | { |
| 185 | 185 | // m62 palette is very dark, so amplify default contrast |
| 186 | 186 | UINT32 i, ymax=1; |
| r20931 | r20932 | |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | |
| 286 | | static void register_savestate( running_machine &machine ) |
| 286 | void m62_state::register_savestate( ) |
| 287 | 287 | { |
| 288 | | m62_state *state = machine.driver_data<m62_state>(); |
| 289 | 288 | |
| 290 | | state->save_item(NAME(state->m_flipscreen)); |
| 291 | | state->save_item(NAME(state->m_m62_background_hscroll)); |
| 292 | | state->save_item(NAME(state->m_m62_background_vscroll)); |
| 289 | save_item(NAME(m_flipscreen)); |
| 290 | save_item(NAME(m_m62_background_hscroll)); |
| 291 | save_item(NAME(m_m62_background_vscroll)); |
| 293 | 292 | |
| 294 | | state->save_item(NAME(state->m_kidniki_background_bank)); |
| 295 | | state->save_item(NAME(state->m_kidniki_text_vscroll)); |
| 296 | | state->save_item(NAME(state->m_ldrun3_topbottom_mask)); |
| 297 | | state->save_item(NAME(state->m_spelunkr_palbank)); |
| 293 | save_item(NAME(m_kidniki_background_bank)); |
| 294 | save_item(NAME(m_kidniki_text_vscroll)); |
| 295 | save_item(NAME(m_ldrun3_topbottom_mask)); |
| 296 | save_item(NAME(m_spelunkr_palbank)); |
| 298 | 297 | } |
| 299 | 298 | |
| 300 | 299 | |
| r20931 | r20932 | |
| 346 | 345 | } |
| 347 | 346 | |
| 348 | 347 | |
| 349 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int colormask, int prioritymask, int priority ) |
| 348 | void m62_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int colormask, int prioritymask, int priority ) |
| 350 | 349 | { |
| 351 | | m62_state *state = machine.driver_data<m62_state>(); |
| 352 | 350 | int offs; |
| 353 | 351 | |
| 354 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 8) |
| 352 | for (offs = 0; offs < m_spriteram.bytes(); offs += 8) |
| 355 | 353 | { |
| 356 | 354 | int i, incr, code, col, flipx, flipy, sx, sy; |
| 357 | 355 | |
| 358 | | if ((state->m_spriteram[offs] & prioritymask) == priority) |
| 356 | if ((m_spriteram[offs] & prioritymask) == priority) |
| 359 | 357 | { |
| 360 | | code = state->m_spriteram[offs + 4] + ((state->m_spriteram[offs + 5] & 0x07) << 8); |
| 361 | | col = state->m_spriteram[offs + 0] & colormask; |
| 362 | | sx = 256 * (state->m_spriteram[offs + 7] & 1) + state->m_spriteram[offs + 6], |
| 363 | | sy = 256 + 128 - 15 - (256 * (state->m_spriteram[offs + 3] & 1) + state->m_spriteram[offs + 2]), |
| 364 | | flipx = state->m_spriteram[offs + 5] & 0x40; |
| 365 | | flipy = state->m_spriteram[offs + 5] & 0x80; |
| 358 | code = m_spriteram[offs + 4] + ((m_spriteram[offs + 5] & 0x07) << 8); |
| 359 | col = m_spriteram[offs + 0] & colormask; |
| 360 | sx = 256 * (m_spriteram[offs + 7] & 1) + m_spriteram[offs + 6], |
| 361 | sy = 256 + 128 - 15 - (256 * (m_spriteram[offs + 3] & 1) + m_spriteram[offs + 2]), |
| 362 | flipx = m_spriteram[offs + 5] & 0x40; |
| 363 | flipy = m_spriteram[offs + 5] & 0x80; |
| 366 | 364 | |
| 367 | | i = state->m_sprite_height_prom[(code >> 5) & 0x1f]; |
| 365 | i = m_sprite_height_prom[(code >> 5) & 0x1f]; |
| 368 | 366 | if (i == 1) /* double height */ |
| 369 | 367 | { |
| 370 | 368 | code &= ~1; |
| r20931 | r20932 | |
| 377 | 375 | sy -= 3*16; |
| 378 | 376 | } |
| 379 | 377 | |
| 380 | | if (state->m_flipscreen) |
| 378 | if (m_flipscreen) |
| 381 | 379 | { |
| 382 | 380 | sx = 496 - sx; |
| 383 | 381 | sy = 242 - i*16 - sy; /* sprites are slightly misplaced by the hardware */ |
| r20931 | r20932 | |
| 394 | 392 | |
| 395 | 393 | do |
| 396 | 394 | { |
| 397 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 395 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 398 | 396 | code + i * incr,col, |
| 399 | 397 | flipx,flipy, |
| 400 | 398 | sx,sy + 16 * i,0); |
| r20931 | r20932 | |
| 405 | 403 | } |
| 406 | 404 | } |
| 407 | 405 | |
| 408 | | static void m62_start( running_machine &machine, tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 ) |
| 406 | void m62_state::m62_start( tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 ) |
| 409 | 407 | { |
| 410 | | m62_state *state = machine.driver_data<m62_state>(); |
| 411 | | state->m_bg_tilemap = &machine.tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS, x1, y1, x2, y2); |
| 408 | m_bg_tilemap = &machine().tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS, x1, y1, x2, y2); |
| 412 | 409 | |
| 413 | | register_savestate(machine); |
| 410 | register_savestate(); |
| 414 | 411 | |
| 415 | 412 | if (rows != 0) |
| 416 | | state->m_bg_tilemap->set_scroll_rows(rows); |
| 413 | m_bg_tilemap->set_scroll_rows(rows); |
| 417 | 414 | |
| 418 | 415 | if (cols != 0) |
| 419 | | state->m_bg_tilemap->set_scroll_cols(cols); |
| 416 | m_bg_tilemap->set_scroll_cols(cols); |
| 420 | 417 | } |
| 421 | 418 | |
| 422 | | static void m62_textlayer( running_machine &machine, tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 ) |
| 419 | void m62_state::m62_textlayer( tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 ) |
| 423 | 420 | { |
| 424 | | m62_state *state = machine.driver_data<m62_state>(); |
| 425 | | state->m_fg_tilemap = &machine.tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS, x1, y1, x2, y2); |
| 421 | m_fg_tilemap = &machine().tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS, x1, y1, x2, y2); |
| 426 | 422 | |
| 427 | 423 | if (rows != 0) |
| 428 | | state->m_fg_tilemap->set_scroll_rows(rows); |
| 424 | m_fg_tilemap->set_scroll_rows(rows); |
| 429 | 425 | |
| 430 | 426 | if (cols != 0) |
| 431 | | state->m_fg_tilemap->set_scroll_cols(cols); |
| 427 | m_fg_tilemap->set_scroll_cols(cols); |
| 432 | 428 | } |
| 433 | 429 | |
| 434 | 430 | WRITE8_MEMBER(m62_state::kungfum_tileram_w) |
| r20931 | r20932 | |
| 460 | 456 | |
| 461 | 457 | VIDEO_START_MEMBER(m62_state,kungfum) |
| 462 | 458 | { |
| 463 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_kungfum_bg_tile_info),this), 32, 0, 8, 8, 64, 32); |
| 459 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_kungfum_bg_tile_info),this), 32, 0, 8, 8, 64, 32); |
| 464 | 460 | } |
| 465 | 461 | |
| 466 | 462 | UINT32 m62_state::screen_update_kungfum(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r20931 | r20932 | |
| 475 | 471 | m_bg_tilemap->set_scrollx(i, m_m62_background_hscroll); |
| 476 | 472 | } |
| 477 | 473 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 478 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 474 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 479 | 475 | m_bg_tilemap->draw(bitmap, cliprect, 1, 0); |
| 480 | 476 | return 0; |
| 481 | 477 | } |
| r20931 | r20932 | |
| 502 | 498 | |
| 503 | 499 | void m62_state::video_start() |
| 504 | 500 | { |
| 505 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_ldrun_bg_tile_info),this), 1, 1, 8, 8, 64, 32); |
| 501 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_ldrun_bg_tile_info),this), 1, 1, 8, 8, 64, 32); |
| 506 | 502 | m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */ |
| 507 | 503 | m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */ |
| 508 | 504 | } |
| r20931 | r20932 | |
| 513 | 509 | m_bg_tilemap->set_scrolly(0, m_m62_background_vscroll); |
| 514 | 510 | |
| 515 | 511 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 516 | | draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x00); |
| 512 | draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x00); |
| 517 | 513 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0); |
| 518 | | draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x10); |
| 514 | draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x10); |
| 519 | 515 | return 0; |
| 520 | 516 | } |
| 521 | 517 | |
| r20931 | r20932 | |
| 540 | 536 | |
| 541 | 537 | VIDEO_START_MEMBER(m62_state,ldrun2) |
| 542 | 538 | { |
| 543 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_ldrun2_bg_tile_info),this), 1, 1, 8, 8, 64, 32); |
| 539 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_ldrun2_bg_tile_info),this), 1, 1, 8, 8, 64, 32); |
| 544 | 540 | m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */ |
| 545 | 541 | m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */ |
| 546 | 542 | } |
| r20931 | r20932 | |
| 602 | 598 | |
| 603 | 599 | VIDEO_START_MEMBER(m62_state,battroad) |
| 604 | 600 | { |
| 605 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_battroad_bg_tile_info),this), 1, 1, 8, 8, 64, 32); |
| 606 | | m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_battroad_fg_tile_info),this), 1, 1, 8, 8, 32, 32); |
| 601 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_battroad_bg_tile_info),this), 1, 1, 8, 8, 64, 32); |
| 602 | m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_battroad_fg_tile_info),this), 1, 1, 8, 8, 32, 32); |
| 607 | 603 | m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */ |
| 608 | 604 | m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */ |
| 609 | 605 | } |
| r20931 | r20932 | |
| 617 | 613 | m_fg_tilemap->set_transparent_pen(0); |
| 618 | 614 | |
| 619 | 615 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 620 | | draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x00); |
| 616 | draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x00); |
| 621 | 617 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0); |
| 622 | | draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x10); |
| 618 | draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x10); |
| 623 | 619 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 624 | 620 | return 0; |
| 625 | 621 | } |
| r20931 | r20932 | |
| 638 | 634 | |
| 639 | 635 | VIDEO_START_MEMBER(m62_state,ldrun4) |
| 640 | 636 | { |
| 641 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_ldrun4_bg_tile_info),this), 1, 0, 8, 8, 64, 32); |
| 637 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_ldrun4_bg_tile_info),this), 1, 0, 8, 8, 64, 32); |
| 642 | 638 | } |
| 643 | 639 | |
| 644 | 640 | UINT32 m62_state::screen_update_ldrun4(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r20931 | r20932 | |
| 646 | 642 | m_bg_tilemap->set_scrollx(0, m_m62_background_hscroll - 2); |
| 647 | 643 | |
| 648 | 644 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 649 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 645 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 650 | 646 | return 0; |
| 651 | 647 | } |
| 652 | 648 | |
| r20931 | r20932 | |
| 677 | 673 | |
| 678 | 674 | VIDEO_START_MEMBER(m62_state,lotlot) |
| 679 | 675 | { |
| 680 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_bg_tile_info),this), 1, 1, 12, 10, 32, 64); |
| 681 | | m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_fg_tile_info),this), 1, 1, 12, 10, 32, 64); |
| 676 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_bg_tile_info),this), 1, 1, 12, 10, 32, 64); |
| 677 | m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_fg_tile_info),this), 1, 1, 12, 10, 32, 64); |
| 682 | 678 | } |
| 683 | 679 | |
| 684 | 680 | UINT32 m62_state::screen_update_lotlot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r20931 | r20932 | |
| 691 | 687 | |
| 692 | 688 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 693 | 689 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 694 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 690 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 695 | 691 | return 0; |
| 696 | 692 | } |
| 697 | 693 | |
| r20931 | r20932 | |
| 740 | 736 | m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */ |
| 741 | 737 | m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */ |
| 742 | 738 | |
| 743 | | register_savestate(machine()); |
| 739 | register_savestate(); |
| 744 | 740 | |
| 745 | | m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_kidniki_fg_tile_info),this), 1, 1, 12, 8, 32, 64); |
| 741 | m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_kidniki_fg_tile_info),this), 1, 1, 12, 8, 32, 64); |
| 746 | 742 | } |
| 747 | 743 | |
| 748 | 744 | UINT32 m62_state::screen_update_kidniki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r20931 | r20932 | |
| 753 | 749 | m_fg_tilemap->set_transparent_pen(0); |
| 754 | 750 | |
| 755 | 751 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 756 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 752 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 757 | 753 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0); |
| 758 | 754 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 759 | 755 | return 0; |
| r20931 | r20932 | |
| 791 | 787 | |
| 792 | 788 | VIDEO_START_MEMBER(m62_state,spelunkr) |
| 793 | 789 | { |
| 794 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_bg_tile_info),this), 1, 1, 8, 8, 64, 64); |
| 795 | | m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32); |
| 790 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_bg_tile_info),this), 1, 1, 8, 8, 64, 64); |
| 791 | m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32); |
| 796 | 792 | } |
| 797 | 793 | |
| 798 | 794 | UINT32 m62_state::screen_update_spelunkr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r20931 | r20932 | |
| 804 | 800 | m_fg_tilemap->set_transparent_pen(0); |
| 805 | 801 | |
| 806 | 802 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 807 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 803 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 808 | 804 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 809 | 805 | return 0; |
| 810 | 806 | } |
| r20931 | r20932 | |
| 833 | 829 | |
| 834 | 830 | VIDEO_START_MEMBER(m62_state,spelunk2) |
| 835 | 831 | { |
| 836 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunk2_bg_tile_info),this), 1, 1, 8, 8, 64, 64); |
| 837 | | m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32); |
| 832 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_spelunk2_bg_tile_info),this), 1, 1, 8, 8, 64, 64); |
| 833 | m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32); |
| 838 | 834 | } |
| 839 | 835 | |
| 840 | 836 | UINT32 m62_state::screen_update_spelunk2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r20931 | r20932 | |
| 846 | 842 | m_fg_tilemap->set_transparent_pen(0); |
| 847 | 843 | |
| 848 | 844 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 849 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 845 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 850 | 846 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 851 | 847 | return 0; |
| 852 | 848 | } |
| r20931 | r20932 | |
| 876 | 872 | |
| 877 | 873 | VIDEO_START_MEMBER(m62_state,youjyudn) |
| 878 | 874 | { |
| 879 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_bg_tile_info),this), 1, 0, 8, 16, 64, 16); |
| 880 | | m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_fg_tile_info),this), 1, 1, 12, 8, 32, 32); |
| 875 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_bg_tile_info),this), 1, 0, 8, 16, 64, 16); |
| 876 | m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_fg_tile_info),this), 1, 1, 12, 8, 32, 32); |
| 881 | 877 | m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */ |
| 882 | 878 | m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */ |
| 883 | 879 | } |
| r20931 | r20932 | |
| 890 | 886 | m_fg_tilemap->set_transparent_pen(0); |
| 891 | 887 | |
| 892 | 888 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 893 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 889 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 894 | 890 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0); |
| 895 | 891 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 896 | 892 | return 0; |
| r20931 | r20932 | |
| 918 | 914 | |
| 919 | 915 | VIDEO_START_MEMBER(m62_state,horizon) |
| 920 | 916 | { |
| 921 | | m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_horizon_bg_tile_info),this), 32, 0, 8, 8, 64, 32); |
| 917 | m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_horizon_bg_tile_info),this), 32, 0, 8, 8, 64, 32); |
| 922 | 918 | m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */ |
| 923 | 919 | m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */ |
| 924 | 920 | } |
| r20931 | r20932 | |
| 931 | 927 | m_bg_tilemap->set_scrollx(i, m_scrollram[i << 1] | (m_scrollram[(i << 1) | 1] << 8)); |
| 932 | 928 | } |
| 933 | 929 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 934 | | draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 930 | draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00); |
| 935 | 931 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0); |
| 936 | 932 | return 0; |
| 937 | 933 | } |
trunk/src/mame/video/megasys1.c
| r20931 | r20932 | |
| 194 | 194 | #include "emu.h" |
| 195 | 195 | #include "includes/megasys1.h" |
| 196 | 196 | |
| 197 | | static void create_tilemaps(running_machine &machine); |
| 198 | | |
| 199 | | |
| 200 | 197 | #ifdef MAME_DEBUG |
| 201 | 198 | |
| 202 | 199 | #define SHOW_WRITE_ERROR(_format_,_offset_,_data_)\ |
| r20931 | r20932 | |
| 231 | 228 | m_buffer2_objectram = auto_alloc_array(machine(), UINT16, 0x2000); |
| 232 | 229 | m_buffer2_spriteram16 = auto_alloc_array(machine(), UINT16, 0x2000); |
| 233 | 230 | |
| 234 | | create_tilemaps(machine()); |
| 231 | create_tilemaps(); |
| 235 | 232 | m_tmap[0] = m_tilemap[0][0][0]; |
| 236 | 233 | m_tmap[1] = m_tilemap[1][0][0]; |
| 237 | 234 | m_tmap[2] = m_tilemap[2][0][0]; |
| r20931 | r20932 | |
| 290 | 287 | #define TILES_PER_PAGE_Y (0x20) |
| 291 | 288 | #define TILES_PER_PAGE (TILES_PER_PAGE_X * TILES_PER_PAGE_Y) |
| 292 | 289 | |
| 293 | | INLINE void scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which) |
| 290 | inline void megasys1_state::scrollram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int which) |
| 294 | 291 | { |
| 295 | | megasys1_state *state = space.machine().driver_data<megasys1_state>(); |
| 296 | | COMBINE_DATA(&state->m_scrollram[which][offset]); |
| 297 | | if (offset < 0x40000/2 && state->m_tmap[which]) |
| 292 | COMBINE_DATA(&m_scrollram[which][offset]); |
| 293 | if (offset < 0x40000/2 && m_tmap[which]) |
| 298 | 294 | { |
| 299 | | if (state->m_scroll_flag[which] & 0x10) /* tiles are 8x8 */ |
| 295 | if (m_scroll_flag[which] & 0x10) /* tiles are 8x8 */ |
| 300 | 296 | { |
| 301 | | state->m_tmap[which]->mark_tile_dirty(offset ); |
| 297 | m_tmap[which]->mark_tile_dirty(offset ); |
| 302 | 298 | } |
| 303 | 299 | else |
| 304 | 300 | { |
| 305 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 0); |
| 306 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 1); |
| 307 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 2); |
| 308 | | state->m_tmap[which]->mark_tile_dirty(offset*4 + 3); |
| 301 | m_tmap[which]->mark_tile_dirty(offset*4 + 0); |
| 302 | m_tmap[which]->mark_tile_dirty(offset*4 + 1); |
| 303 | m_tmap[which]->mark_tile_dirty(offset*4 + 2); |
| 304 | m_tmap[which]->mark_tile_dirty(offset*4 + 3); |
| 309 | 305 | } |
| 310 | 306 | } |
| 311 | 307 | } |
| 312 | 308 | |
| 313 | | WRITE16_MEMBER(megasys1_state::megasys1_scrollram_0_w){ scrollram_w(space, offset, data, mem_mask, 0); } |
| 314 | | WRITE16_MEMBER(megasys1_state::megasys1_scrollram_1_w){ scrollram_w(space, offset, data, mem_mask, 1); } |
| 315 | | WRITE16_MEMBER(megasys1_state::megasys1_scrollram_2_w){ scrollram_w(space, offset, data, mem_mask, 2); } |
| 309 | WRITE16_MEMBER(megasys1_state::megasys1_scrollram_0_w){ scrollram_w(offset, data, mem_mask, 0); } |
| 310 | WRITE16_MEMBER(megasys1_state::megasys1_scrollram_1_w){ scrollram_w(offset, data, mem_mask, 1); } |
| 311 | WRITE16_MEMBER(megasys1_state::megasys1_scrollram_2_w){ scrollram_w(offset, data, mem_mask, 2); } |
| 316 | 312 | |
| 317 | 313 | |
| 318 | 314 | |
| r20931 | r20932 | |
| 362 | 358 | SET_TILE_INFO_MEMBER(tmap, (code & 0xfff) * m_16x16_scroll_factor[tmap] + (tile_index & 3), code >> (16 - m_bits_per_color_code), 0); |
| 363 | 359 | } |
| 364 | 360 | |
| 365 | | static void create_tilemaps(running_machine &machine) |
| 361 | void megasys1_state::create_tilemaps() |
| 366 | 362 | { |
| 367 | | megasys1_state *state = machine.driver_data<megasys1_state>(); |
| 368 | 363 | int layer, i; |
| 369 | 364 | |
| 370 | 365 | for (layer = 0; layer < 3; layer++) |
| 371 | 366 | { |
| 372 | 367 | /* 16x16 tilemaps */ |
| 373 | | state->m_tilemap[layer][0][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state), |
| 368 | m_tilemap[layer][0][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this), |
| 374 | 369 | 8,8, TILES_PER_PAGE_X * 16, TILES_PER_PAGE_Y * 2); |
| 375 | | state->m_tilemap[layer][0][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state), |
| 370 | m_tilemap[layer][0][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this), |
| 376 | 371 | 8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 4); |
| 377 | | state->m_tilemap[layer][0][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state), |
| 372 | m_tilemap[layer][0][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this), |
| 378 | 373 | 8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 8); |
| 379 | | state->m_tilemap[layer][0][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state), |
| 374 | m_tilemap[layer][0][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this), |
| 380 | 375 | 8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 16); |
| 381 | 376 | |
| 382 | 377 | /* 8x8 tilemaps */ |
| 383 | | state->m_tilemap[layer][1][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state), |
| 378 | m_tilemap[layer][1][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this), |
| 384 | 379 | 8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 1); |
| 385 | | state->m_tilemap[layer][1][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state), |
| 380 | m_tilemap[layer][1][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this), |
| 386 | 381 | 8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2); |
| 387 | | state->m_tilemap[layer][1][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state), |
| 382 | m_tilemap[layer][1][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this), |
| 388 | 383 | 8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2); |
| 389 | | state->m_tilemap[layer][1][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state), |
| 384 | m_tilemap[layer][1][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this), |
| 390 | 385 | 8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 4); |
| 391 | 386 | |
| 392 | 387 | /* set user data and transparency */ |
| 393 | 388 | for (i = 0; i < 8; i++) |
| 394 | 389 | { |
| 395 | | state->m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer); |
| 396 | | state->m_tilemap[layer][i/4][i%4]->set_transparent_pen(15); |
| 390 | m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer); |
| 391 | m_tilemap[layer][i/4][i%4]->set_transparent_pen(15); |
| 397 | 392 | } |
| 398 | 393 | } |
| 399 | 394 | } |
| r20931 | r20932 | |
| 560 | 555 | 0C Y position |
| 561 | 556 | 0E Code */ |
| 562 | 557 | |
| 563 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 558 | void megasys1_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 564 | 559 | { |
| 565 | | megasys1_state *state = machine.driver_data<megasys1_state>(); |
| 566 | 560 | int color,code,sx,sy,flipx,flipy,attr,sprite,offs,color_mask; |
| 567 | 561 | |
| 568 | 562 | /* objram: 0x100*4 entries spritedata: 0x80 entries */ |
| 569 | 563 | |
| 570 | 564 | /* sprite order is from first in Sprite Data RAM (frontmost) to last */ |
| 571 | 565 | |
| 572 | | if (state->m_hardware_type_z == 0) /* standard sprite hardware */ |
| 566 | if (m_hardware_type_z == 0) /* standard sprite hardware */ |
| 573 | 567 | { |
| 574 | | color_mask = (state->m_sprite_flag & 0x100) ? 0x07 : 0x0f; |
| 568 | color_mask = (m_sprite_flag & 0x100) ? 0x07 : 0x0f; |
| 575 | 569 | |
| 576 | 570 | for (offs = (0x800-8)/2;offs >= 0;offs -= 8/2) |
| 577 | 571 | { |
| 578 | 572 | for (sprite = 0; sprite < 4 ; sprite ++) |
| 579 | 573 | { |
| 580 | | UINT16 *objectdata = &state->m_buffer2_objectram[offs + (0x800/2) * sprite]; |
| 581 | | UINT16 *spritedata = &state->m_buffer2_spriteram16[ (objectdata[ 0 ] & 0x7f) * 0x10/2]; |
| 574 | UINT16 *objectdata = &m_buffer2_objectram[offs + (0x800/2) * sprite]; |
| 575 | UINT16 *spritedata = &m_buffer2_spriteram16[ (objectdata[ 0 ] & 0x7f) * 0x10/2]; |
| 582 | 576 | |
| 583 | 577 | attr = spritedata[ 8/2 ]; |
| 584 | 578 | if (((attr & 0xc0)>>6) != sprite) continue; // flipping |
| r20931 | r20932 | |
| 593 | 587 | flipx = attr & 0x40; |
| 594 | 588 | flipy = attr & 0x80; |
| 595 | 589 | |
| 596 | | if (state->m_screen_flag & 1) |
| 590 | if (m_screen_flag & 1) |
| 597 | 591 | { |
| 598 | 592 | flipx = !flipx; flipy = !flipy; |
| 599 | 593 | sx = 240-sx; sy = 240-sy; |
| r20931 | r20932 | |
| 604 | 598 | color = (attr & color_mask); |
| 605 | 599 | |
| 606 | 600 | pdrawgfx_transpen(bitmap,cliprect, |
| 607 | | machine.gfx[3], |
| 608 | | (code & 0xfff ) + ((state->m_sprite_bank & 1) << 12), |
| 601 | machine().gfx[3], |
| 602 | (code & 0xfff ) + ((m_sprite_bank & 1) << 12), |
| 609 | 603 | color, |
| 610 | 604 | flipx, flipy, |
| 611 | 605 | sx, sy, |
| 612 | | machine.priority_bitmap, |
| 606 | machine().priority_bitmap, |
| 613 | 607 | (attr & 0x08) ? 0x0c : 0x0a,15); |
| 614 | 608 | } /* sprite */ |
| 615 | 609 | } /* offs */ |
| 616 | 610 | } /* non Z hw */ |
| 617 | 611 | else |
| 618 | 612 | { |
| 619 | | UINT16 *spriteram16 = state->m_spriteram; |
| 613 | UINT16 *spriteram16 = m_spriteram; |
| 620 | 614 | |
| 621 | 615 | /* MS1-Z just draws Sprite Data, and in reverse order */ |
| 622 | 616 | |
| r20931 | r20932 | |
| 638 | 632 | flipx = attr & 0x40; |
| 639 | 633 | flipy = attr & 0x80; |
| 640 | 634 | |
| 641 | | if (state->m_screen_flag & 1) |
| 635 | if (m_screen_flag & 1) |
| 642 | 636 | { |
| 643 | 637 | flipx = !flipx; flipy = !flipy; |
| 644 | 638 | sx = 240-sx; sy = 240-sy; |
| 645 | 639 | } |
| 646 | 640 | |
| 647 | 641 | pdrawgfx_transpen(bitmap,cliprect, |
| 648 | | machine.gfx[2], |
| 642 | machine().gfx[2], |
| 649 | 643 | code, |
| 650 | 644 | color, |
| 651 | 645 | flipx, flipy, |
| 652 | 646 | sx, sy, |
| 653 | | machine.priority_bitmap, |
| 647 | machine().priority_bitmap, |
| 654 | 648 | (attr & 0x08) ? 0x0c : 0x0a,15); |
| 655 | 649 | } /* sprite */ |
| 656 | 650 | } /* Z hw */ |
| r20931 | r20932 | |
| 1008 | 1002 | } |
| 1009 | 1003 | |
| 1010 | 1004 | if (active_layers & 0x08) |
| 1011 | | draw_sprites(machine(),bitmap,cliprect); |
| 1005 | draw_sprites(bitmap,cliprect); |
| 1012 | 1006 | return 0; |
| 1013 | 1007 | } |
| 1014 | 1008 | |
trunk/src/mame/video/m72.c
| r20931 | r20932 | |
| 8 | 8 | |
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | | INLINE void m72_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum) |
| 11 | inline void m72_state::m72_get_tile_info(tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum) |
| 12 | 12 | { |
| 13 | 13 | int code,attr,color,pri; |
| 14 | 14 | |
| r20931 | r20932 | |
| 23 | 23 | else pri = 0; |
| 24 | 24 | /* color & 0x10 is used in bchopper and hharry, more priority? */ |
| 25 | 25 | |
| 26 | | SET_TILE_INFO( |
| 26 | SET_TILE_INFO_MEMBER( |
| 27 | 27 | gfxnum, |
| 28 | 28 | code + ((attr & 0x3f) << 8), |
| 29 | 29 | color & 0x0f, |
| r20931 | r20932 | |
| 31 | 31 | tileinfo.group = pri; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | | INLINE void rtype2_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum) |
| 34 | inline void m72_state::rtype2_get_tile_info(tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum) |
| 35 | 35 | { |
| 36 | 36 | int code,attr,color,pri; |
| 37 | 37 | |
| r20931 | r20932 | |
| 48 | 48 | /* (vram[tile_index+2] & 0x10) is used by majtitle on the green, but it's not clear for what */ |
| 49 | 49 | /* (vram[tile_index+3] & 0xfe) are used as well */ |
| 50 | 50 | |
| 51 | | SET_TILE_INFO( |
| 51 | SET_TILE_INFO_MEMBER( |
| 52 | 52 | gfxnum, |
| 53 | 53 | code, |
| 54 | 54 | color & 0x0f, |
| r20931 | r20932 | |
| 59 | 59 | |
| 60 | 60 | TILE_GET_INFO_MEMBER(m72_state::m72_get_bg_tile_info) |
| 61 | 61 | { |
| 62 | | m72_get_tile_info(machine(),tileinfo,tile_index,m_videoram2,2); |
| 62 | m72_get_tile_info(tileinfo,tile_index,m_videoram2,2); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | TILE_GET_INFO_MEMBER(m72_state::m72_get_fg_tile_info) |
| 66 | 66 | { |
| 67 | | m72_get_tile_info(machine(),tileinfo,tile_index,m_videoram1,1); |
| 67 | m72_get_tile_info(tileinfo,tile_index,m_videoram1,1); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | TILE_GET_INFO_MEMBER(m72_state::hharry_get_bg_tile_info) |
| 71 | 71 | { |
| 72 | | m72_get_tile_info(machine(),tileinfo,tile_index,m_videoram2,1); |
| 72 | m72_get_tile_info(tileinfo,tile_index,m_videoram2,1); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | TILE_GET_INFO_MEMBER(m72_state::rtype2_get_bg_tile_info) |
| 76 | 76 | { |
| 77 | | rtype2_get_tile_info(machine(),tileinfo,tile_index,m_videoram2,1); |
| 77 | rtype2_get_tile_info(tileinfo,tile_index,m_videoram2,1); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | TILE_GET_INFO_MEMBER(m72_state::rtype2_get_fg_tile_info) |
| 81 | 81 | { |
| 82 | | rtype2_get_tile_info(machine(),tileinfo,tile_index,m_videoram1,1); |
| 82 | rtype2_get_tile_info(tileinfo,tile_index,m_videoram1,1); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
| r20931 | r20932 | |
| 96 | 96 | |
| 97 | 97 | ***************************************************************************/ |
| 98 | 98 | |
| 99 | | static void register_savestate(running_machine &machine) |
| 99 | void m72_state::register_savestate() |
| 100 | 100 | { |
| 101 | | m72_state *state = machine.driver_data<m72_state>(); |
| 102 | | state->save_item(NAME(state->m_raster_irq_position)); |
| 103 | | state->save_item(NAME(state->m_video_off)); |
| 104 | | state->save_item(NAME(state->m_scrollx1)); |
| 105 | | state->save_item(NAME(state->m_scrolly1)); |
| 106 | | state->save_item(NAME(state->m_scrollx2)); |
| 107 | | state->save_item(NAME(state->m_scrolly2)); |
| 108 | | state->save_pointer(NAME(state->m_buffered_spriteram), state->m_spriteram.bytes()/2); |
| 101 | save_item(NAME(m_raster_irq_position)); |
| 102 | save_item(NAME(m_video_off)); |
| 103 | save_item(NAME(m_scrollx1)); |
| 104 | save_item(NAME(m_scrolly1)); |
| 105 | save_item(NAME(m_scrollx2)); |
| 106 | save_item(NAME(m_scrolly2)); |
| 107 | save_pointer(NAME(m_buffered_spriteram), m_spriteram.bytes()/2); |
| 109 | 108 | } |
| 110 | 109 | |
| 111 | 110 | |
| r20931 | r20932 | |
| 136 | 135 | m_bg_tilemap->set_scrolldx(0,0); |
| 137 | 136 | m_bg_tilemap->set_scrolldy(-128,-128); |
| 138 | 137 | |
| 139 | | register_savestate(machine()); |
| 138 | register_savestate(); |
| 140 | 139 | } |
| 141 | 140 | |
| 142 | 141 | VIDEO_START_MEMBER(m72_state,xmultipl) |
| r20931 | r20932 | |
| 171 | 170 | m_bg_tilemap->set_scrolldx(4,0); |
| 172 | 171 | m_bg_tilemap->set_scrolldy(-128,16); |
| 173 | 172 | |
| 174 | | register_savestate(machine()); |
| 173 | register_savestate(); |
| 175 | 174 | } |
| 176 | 175 | |
| 177 | 176 | VIDEO_START_MEMBER(m72_state,poundfor) |
| r20931 | r20932 | |
| 221 | 220 | m_bg_tilemap->set_scrolldx(4,0); |
| 222 | 221 | m_bg_tilemap->set_scrolldy(-128,-128); |
| 223 | 222 | |
| 224 | | register_savestate(machine()); |
| 223 | register_savestate(); |
| 225 | 224 | } |
| 226 | 225 | |
| 227 | 226 | VIDEO_START_MEMBER(m72_state,hharry) |
| r20931 | r20932 | |
| 247 | 246 | m_bg_tilemap->set_scrolldx(6,0); |
| 248 | 247 | m_bg_tilemap->set_scrolldy(-128,16); |
| 249 | 248 | |
| 250 | | register_savestate(machine()); |
| 249 | register_savestate(); |
| 251 | 250 | } |
| 252 | 251 | |
| 253 | 252 | |
| r20931 | r20932 | |
| 273 | 272 | return m_generic_paletteram2_16[offset] | 0xffe0; /* only D0-D4 are connected */ |
| 274 | 273 | } |
| 275 | 274 | |
| 276 | | INLINE void changecolor(running_machine &machine,int color,int r,int g,int b) |
| 275 | inline void m72_state::changecolor(int color,int r,int g,int b) |
| 277 | 276 | { |
| 278 | | palette_set_color_rgb(machine,color,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 277 | palette_set_color_rgb(machine(),color,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 279 | 278 | } |
| 280 | 279 | |
| 281 | 280 | WRITE16_MEMBER(m72_state::m72_palette1_w) |
| r20931 | r20932 | |
| 285 | 284 | |
| 286 | 285 | COMBINE_DATA(&m_generic_paletteram_16[offset]); |
| 287 | 286 | offset &= 0x0ff; |
| 288 | | changecolor(machine(), |
| 289 | | offset, |
| 287 | changecolor(offset, |
| 290 | 288 | m_generic_paletteram_16[offset + 0x000], |
| 291 | 289 | m_generic_paletteram_16[offset + 0x200], |
| 292 | 290 | m_generic_paletteram_16[offset + 0x400]); |
| r20931 | r20932 | |
| 299 | 297 | |
| 300 | 298 | COMBINE_DATA(&m_generic_paletteram2_16[offset]); |
| 301 | 299 | offset &= 0x0ff; |
| 302 | | changecolor(machine(), |
| 303 | | offset + 256, |
| 300 | changecolor(offset + 256, |
| 304 | 301 | m_generic_paletteram2_16[offset + 0x000], |
| 305 | 302 | m_generic_paletteram2_16[offset + 0x200], |
| 306 | 303 | m_generic_paletteram2_16[offset + 0x400]); |
| r20931 | r20932 | |
| 415 | 412 | |
| 416 | 413 | ***************************************************************************/ |
| 417 | 414 | |
| 418 | | static void m72_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 415 | void m72_state::m72_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 419 | 416 | { |
| 420 | | m72_state *state = machine.driver_data<m72_state>(); |
| 421 | | UINT16 *spriteram = state->m_buffered_spriteram; |
| 417 | UINT16 *spriteram = m_buffered_spriteram; |
| 422 | 418 | int offs; |
| 423 | 419 | |
| 424 | 420 | offs = 0; |
| 425 | | while (offs < state->m_spriteram.bytes()/2) |
| 421 | while (offs < m_spriteram.bytes()/2) |
| 426 | 422 | { |
| 427 | 423 | int code,color,sx,sy,flipx,flipy,w,h,x,y; |
| 428 | 424 | |
| r20931 | r20932 | |
| 438 | 434 | h = 1 << ((spriteram[offs+2] & 0x3000) >> 12); |
| 439 | 435 | sy -= 16 * h; |
| 440 | 436 | |
| 441 | | if (state->flip_screen()) |
| 437 | if (flip_screen()) |
| 442 | 438 | { |
| 443 | 439 | sx = 512 - 16*w - sx; |
| 444 | 440 | sy = 284 - 16*h - sy; |
| r20931 | r20932 | |
| 457 | 453 | if (flipy) c += h-1-y; |
| 458 | 454 | else c += y; |
| 459 | 455 | |
| 460 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 456 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 461 | 457 | c, |
| 462 | 458 | color, |
| 463 | 459 | flipx,flipy, |
| r20931 | r20932 | |
| 469 | 465 | } |
| 470 | 466 | } |
| 471 | 467 | |
| 472 | | static void majtitle_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 468 | void m72_state::majtitle_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 473 | 469 | { |
| 474 | | m72_state *state = machine.driver_data<m72_state>(); |
| 475 | | UINT16 *spriteram16_2 = state->m_spriteram2; |
| 470 | UINT16 *spriteram16_2 = m_spriteram2; |
| 476 | 471 | int offs; |
| 477 | 472 | |
| 478 | | for (offs = 0;offs < state->m_spriteram.bytes();offs += 4) |
| 473 | for (offs = 0;offs < m_spriteram.bytes();offs += 4) |
| 479 | 474 | { |
| 480 | 475 | int code,color,sx,sy,flipx,flipy,w,h,x,y; |
| 481 | 476 | |
| r20931 | r20932 | |
| 491 | 486 | h = 1 << ((spriteram16_2[offs+2] & 0x3000) >> 12); |
| 492 | 487 | sy -= 16 * h; |
| 493 | 488 | |
| 494 | | if (state->flip_screen()) |
| 489 | if (flip_screen()) |
| 495 | 490 | { |
| 496 | 491 | sx = 512 - 16*w - sx; |
| 497 | 492 | sy = 256 - 16*h - sy; |
| r20931 | r20932 | |
| 510 | 505 | if (flipy) c += h-1-y; |
| 511 | 506 | else c += y; |
| 512 | 507 | |
| 513 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[2], |
| 508 | drawgfx_transpen(bitmap,cliprect,machine().gfx[2], |
| 514 | 509 | c, |
| 515 | 510 | color, |
| 516 | 511 | flipx,flipy, |
| r20931 | r20932 | |
| 536 | 531 | |
| 537 | 532 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0); |
| 538 | 533 | m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0); |
| 539 | | m72_draw_sprites(machine(), bitmap,cliprect); |
| 534 | m72_draw_sprites(bitmap,cliprect); |
| 540 | 535 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0); |
| 541 | 536 | m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0); |
| 542 | 537 | return 0; |
| r20931 | r20932 | |
| 572 | 567 | |
| 573 | 568 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0); |
| 574 | 569 | m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0); |
| 575 | | majtitle_draw_sprites(machine(), bitmap,cliprect); |
| 576 | | m72_draw_sprites(machine(), bitmap,cliprect); |
| 570 | majtitle_draw_sprites(bitmap,cliprect); |
| 571 | m72_draw_sprites(bitmap,cliprect); |
| 577 | 572 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0); |
| 578 | 573 | m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0); |
| 579 | 574 | return 0; |
trunk/src/mame/video/m90.c
| r20931 | r20932 | |
| 30 | 30 | #include "includes/m90.h" |
| 31 | 31 | |
| 32 | 32 | |
| 33 | | INLINE void get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,int layer,int page_mask) |
| 33 | inline void m90_state::get_tile_info(tile_data &tileinfo,int tile_index,int layer,int page_mask) |
| 34 | 34 | { |
| 35 | | m90_state *state = machine.driver_data<m90_state>(); |
| 36 | 35 | int tile,color; |
| 37 | | tile_index = 2*tile_index + ((state->m_video_control_data[5+layer] & page_mask) * 0x2000); |
| 36 | tile_index = 2*tile_index + ((m_video_control_data[5+layer] & page_mask) * 0x2000); |
| 38 | 37 | |
| 39 | | tile=state->m_video_data[tile_index]; |
| 40 | | color=state->m_video_data[tile_index+1]; |
| 41 | | SET_TILE_INFO( |
| 38 | tile=m_video_data[tile_index]; |
| 39 | color=m_video_data[tile_index+1]; |
| 40 | SET_TILE_INFO_MEMBER( |
| 42 | 41 | 0, |
| 43 | 42 | tile, |
| 44 | 43 | color&0xf, |
| r20931 | r20932 | |
| 46 | 45 | tileinfo.category = (color & 0x30) ? 1 : 0; |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | | INLINE void bomblord_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,int layer) |
| 48 | inline void m90_state::bomblord_get_tile_info(tile_data &tileinfo,int tile_index,int layer) |
| 50 | 49 | { |
| 51 | | m90_state *state = machine.driver_data<m90_state>(); |
| 52 | 50 | int tile,color; |
| 53 | 51 | tile_index = 2*tile_index + (layer * 0x2000); |
| 54 | 52 | |
| 55 | | tile=state->m_video_data[tile_index]; |
| 56 | | color=state->m_video_data[tile_index+1]; |
| 57 | | SET_TILE_INFO( |
| 53 | tile=m_video_data[tile_index]; |
| 54 | color=m_video_data[tile_index+1]; |
| 55 | SET_TILE_INFO_MEMBER( |
| 58 | 56 | 0, |
| 59 | 57 | tile, |
| 60 | 58 | color&0xf, |
| r20931 | r20932 | |
| 62 | 60 | tileinfo.category = (color & 0x30) ? 1 : 0; |
| 63 | 61 | } |
| 64 | 62 | |
| 65 | | INLINE void dynablsb_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,int layer) |
| 63 | inline void m90_state::dynablsb_get_tile_info(tile_data &tileinfo,int tile_index,int layer) |
| 66 | 64 | { |
| 67 | | m90_state *state = machine.driver_data<m90_state>(); |
| 68 | 65 | int tile,color; |
| 69 | 66 | tile_index = 2*tile_index + (layer * 0x2000); |
| 70 | 67 | |
| 71 | | tile=state->m_video_data[tile_index]; |
| 72 | | color=state->m_video_data[tile_index+1]; |
| 73 | | SET_TILE_INFO( |
| 68 | tile=m_video_data[tile_index]; |
| 69 | color=m_video_data[tile_index+1]; |
| 70 | SET_TILE_INFO_MEMBER( |
| 74 | 71 | 0, |
| 75 | 72 | tile, |
| 76 | 73 | color&0xf, |
| r20931 | r20932 | |
| 78 | 75 | tileinfo.category = (color & 0x30) ? 1 : 0; |
| 79 | 76 | } |
| 80 | 77 | |
| 81 | | TILE_GET_INFO_MEMBER(m90_state::get_pf1_tile_info){ get_tile_info(machine(),tileinfo,tile_index,0,0x3); } |
| 82 | | TILE_GET_INFO_MEMBER(m90_state::get_pf1w_tile_info){ get_tile_info(machine(),tileinfo,tile_index,0,0x2); } |
| 83 | | TILE_GET_INFO_MEMBER(m90_state::get_pf2_tile_info){ get_tile_info(machine(),tileinfo,tile_index,1,0x3); } |
| 84 | | TILE_GET_INFO_MEMBER(m90_state::get_pf2w_tile_info){ get_tile_info(machine(),tileinfo,tile_index,1,0x2); } |
| 78 | TILE_GET_INFO_MEMBER(m90_state::get_pf1_tile_info){ get_tile_info(tileinfo,tile_index,0,0x3); } |
| 79 | TILE_GET_INFO_MEMBER(m90_state::get_pf1w_tile_info){ get_tile_info(tileinfo,tile_index,0,0x2); } |
| 80 | TILE_GET_INFO_MEMBER(m90_state::get_pf2_tile_info){ get_tile_info(tileinfo,tile_index,1,0x3); } |
| 81 | TILE_GET_INFO_MEMBER(m90_state::get_pf2w_tile_info){ get_tile_info(tileinfo,tile_index,1,0x2); } |
| 85 | 82 | |
| 86 | | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,0); } |
| 87 | | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1w_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,0); } |
| 88 | | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,2); } |
| 89 | | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2w_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,2); } |
| 83 | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,0); } |
| 84 | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1w_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,0); } |
| 85 | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,2); } |
| 86 | TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2w_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,2); } |
| 90 | 87 | |
| 91 | | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,0); } |
| 92 | | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1w_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,0); } |
| 93 | | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,2); } |
| 94 | | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2w_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,2); } |
| 88 | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,0); } |
| 89 | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1w_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,0); } |
| 90 | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,2); } |
| 91 | TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2w_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,2); } |
| 95 | 92 | |
| 96 | 93 | void m90_state::video_start() |
| 97 | 94 | { |
| r20931 | r20932 | |
| 136 | 133 | state_save_register_global_array(machine(), m_video_control_data); |
| 137 | 134 | } |
| 138 | 135 | |
| 139 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 136 | void m90_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 140 | 137 | { |
| 141 | | m90_state *state = machine.driver_data<m90_state>(); |
| 142 | | UINT16 *spriteram = state->m_video_data + 0xee00/2;; |
| 138 | UINT16 *spriteram = m_video_data + 0xee00/2;; |
| 143 | 139 | int offs; |
| 144 | 140 | |
| 145 | 141 | for (offs = 0x1f2/2; offs >= 0; offs -= 3) |
| r20931 | r20932 | |
| 163 | 159 | |
| 164 | 160 | for (i = 0;i < y_multi;i++) |
| 165 | 161 | |
| 166 | | if (state->m_video_control_data[7] & 0x01) |
| 167 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 162 | if (m_video_control_data[7] & 0x01) |
| 163 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 168 | 164 | sprite + (fy ? y_multi-1 - i : i), |
| 169 | 165 | colour, |
| 170 | 166 | fx,fy, |
| 171 | 167 | x,y+i*16, |
| 172 | | machine.priority_bitmap, |
| 168 | machine().priority_bitmap, |
| 173 | 169 | (colour & 0x08) ? 0x00 : 0x02,0); |
| 174 | | else if (state->m_video_control_data[7] & 0x02) |
| 175 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 170 | else if (m_video_control_data[7] & 0x02) |
| 171 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 176 | 172 | sprite + (fy ? y_multi-1 - i : i), |
| 177 | 173 | colour, |
| 178 | 174 | fx,fy, |
| 179 | 175 | x,y+i*16, |
| 180 | | machine.priority_bitmap, |
| 176 | machine().priority_bitmap, |
| 181 | 177 | ((colour & 0x0c)==0x0c) ? 0x00 : 0x02,0); |
| 182 | 178 | else |
| 183 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 179 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 184 | 180 | sprite + (fy ? y_multi-1 - i : i), |
| 185 | 181 | colour, |
| 186 | 182 | fx,fy, |
| 187 | 183 | x,y+i*16, |
| 188 | | machine.priority_bitmap, |
| 184 | machine().priority_bitmap, |
| 189 | 185 | 0x02,0); |
| 190 | 186 | } |
| 191 | 187 | } |
| 192 | 188 | |
| 193 | | static void bomblord_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 189 | void m90_state::bomblord_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 194 | 190 | { |
| 195 | | m90_state *state = machine.driver_data<m90_state>(); |
| 196 | | UINT16 *spriteram16 = state->m_spriteram; |
| 191 | UINT16 *spriteram16 = m_spriteram; |
| 197 | 192 | int offs = 0, last_sprite = 0; |
| 198 | 193 | int x,y,sprite,colour,fx,fy; |
| 199 | 194 | |
| 200 | 195 | |
| 201 | | while ((offs < state->m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0x8000)) |
| 196 | while ((offs < m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0x8000)) |
| 202 | 197 | { |
| 203 | 198 | last_sprite = offs; |
| 204 | 199 | offs += 4; |
| r20931 | r20932 | |
| 220 | 215 | fx = (spriteram16[offs+3] >> 8) & 0x02; |
| 221 | 216 | fy = (spriteram16[offs+2] >> 8) & 0x80; |
| 222 | 217 | |
| 223 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 218 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 224 | 219 | sprite, |
| 225 | 220 | colour, |
| 226 | 221 | fx,fy, |
| 227 | 222 | x,y, |
| 228 | | machine.priority_bitmap, |
| 223 | machine().priority_bitmap, |
| 229 | 224 | (colour & 0x08) ? 0x00 : 0x02,0); |
| 230 | 225 | } |
| 231 | 226 | } |
| 232 | 227 | |
| 233 | | static void dynablsb_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 228 | void m90_state::dynablsb_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 234 | 229 | { |
| 235 | | m90_state *state = machine.driver_data<m90_state>(); |
| 236 | | UINT16 *spriteram16 = state->m_spriteram; |
| 230 | UINT16 *spriteram16 = m_spriteram; |
| 237 | 231 | int offs = 0, last_sprite = 0; |
| 238 | 232 | int x,y,sprite,colour,fx,fy; |
| 239 | 233 | |
| 240 | | while ((offs < state->m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0xffff)) |
| 234 | while ((offs < m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0xffff)) |
| 241 | 235 | { |
| 242 | 236 | last_sprite = offs; |
| 243 | 237 | offs += 4; |
| r20931 | r20932 | |
| 259 | 253 | fx = (spriteram16[offs+3] >> 8) & 0x02; |
| 260 | 254 | fy = (spriteram16[offs+2] >> 8) & 0x80; |
| 261 | 255 | |
| 262 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 256 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 263 | 257 | sprite, |
| 264 | 258 | colour, |
| 265 | 259 | fx,fy, |
| 266 | 260 | x,y, |
| 267 | | machine.priority_bitmap, |
| 261 | machine().priority_bitmap, |
| 268 | 262 | (colour & 0x08) ? 0x00 : 0x02,0); |
| 269 | 263 | } |
| 270 | 264 | } |
| r20931 | r20932 | |
| 274 | 268 | COMBINE_DATA(&m_video_control_data[offset]); |
| 275 | 269 | } |
| 276 | 270 | |
| 277 | | static void markdirty(tilemap_t *tmap,int page,offs_t offset) |
| 271 | void m90_state::markdirty(tilemap_t *tmap,int page,offs_t offset) |
| 278 | 272 | { |
| 279 | 273 | offset -= page * 0x2000; |
| 280 | 274 | |
| r20931 | r20932 | |
| 447 | 441 | } |
| 448 | 442 | } |
| 449 | 443 | |
| 450 | | draw_sprites(machine(),bitmap,cliprect); |
| 444 | draw_sprites(bitmap,cliprect); |
| 451 | 445 | |
| 452 | 446 | } else { |
| 453 | 447 | bitmap.fill(get_black_pen(machine()), cliprect); |
| r20931 | r20932 | |
| 503 | 497 | m_pf1_layer->draw(bitmap, cliprect, 1,1); |
| 504 | 498 | } |
| 505 | 499 | |
| 506 | | bomblord_draw_sprites(machine(),bitmap,cliprect); |
| 500 | bomblord_draw_sprites(bitmap,cliprect); |
| 507 | 501 | |
| 508 | 502 | return 0; |
| 509 | 503 | } |
| r20931 | r20932 | |
| 545 | 539 | m_pf2_layer->draw(bitmap, cliprect, 1,1); |
| 546 | 540 | } |
| 547 | 541 | |
| 548 | | dynablsb_draw_sprites(machine(),bitmap,cliprect); |
| 542 | dynablsb_draw_sprites(bitmap,cliprect); |
| 549 | 543 | |
| 550 | 544 | return 0; |
| 551 | 545 | } |
trunk/src/mame/video/m107.c
| r20931 | r20932 | |
| 146 | 146 | |
| 147 | 147 | /*****************************************************************************/ |
| 148 | 148 | |
| 149 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 149 | void m107_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 150 | 150 | { |
| 151 | | m107_state *state = machine.driver_data<m107_state>(); |
| 152 | | UINT16 *spriteram = state->m_buffered_spriteram; |
| 151 | UINT16 *spriteram = m_buffered_spriteram; |
| 153 | 152 | int offs; |
| 154 | | UINT8 *rom = state->memregion("user1")->base(); |
| 153 | UINT8 *rom = memregion("user1")->base(); |
| 155 | 154 | |
| 156 | 155 | for (offs = 0;offs < 0x800;offs += 4) |
| 157 | 156 | { |
| r20931 | r20932 | |
| 176 | 175 | fy=(spriteram[offs+2]>>8)&0x2; |
| 177 | 176 | y_multi=(spriteram[offs+0]>>11)&0x3; |
| 178 | 177 | |
| 179 | | if (state->m_spritesystem == 0) |
| 178 | if (m_spritesystem == 0) |
| 180 | 179 | { |
| 181 | 180 | y_multi=1 << y_multi; /* 1, 2, 4 or 8 */ |
| 182 | 181 | |
| r20931 | r20932 | |
| 185 | 184 | |
| 186 | 185 | for (i=0; i<y_multi; i++) |
| 187 | 186 | { |
| 188 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 187 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 189 | 188 | sprite + s_ptr, |
| 190 | 189 | colour, |
| 191 | 190 | fx,fy, |
| 192 | 191 | x,y-i*16, |
| 193 | | machine.priority_bitmap,pri_mask,0); |
| 192 | machine().priority_bitmap,pri_mask,0); |
| 194 | 193 | |
| 195 | 194 | /* wrap-around y */ |
| 196 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 195 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 197 | 196 | sprite + s_ptr, |
| 198 | 197 | colour, |
| 199 | 198 | fx,fy, |
| 200 | 199 | x,(y-i*16) - 0x200, |
| 201 | | machine.priority_bitmap,pri_mask,0); |
| 200 | machine().priority_bitmap,pri_mask,0); |
| 202 | 201 | |
| 203 | 202 | if (fy) s_ptr++; else s_ptr--; |
| 204 | 203 | } |
| r20931 | r20932 | |
| 242 | 241 | if (!ffy) sprite+=y_multi-1; |
| 243 | 242 | for (i=0; i<y_multi; i++) |
| 244 | 243 | { |
| 245 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 244 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 246 | 245 | sprite+(ffy?i:-i), |
| 247 | 246 | colour, |
| 248 | 247 | ffx,ffy, |
| 249 | 248 | (x+xdisp)&0x1ff,(y-ydisp-16*i)&0x1ff, |
| 250 | | machine.priority_bitmap,pri_mask,0); |
| 249 | machine().priority_bitmap,pri_mask,0); |
| 251 | 250 | |
| 252 | 251 | /* wrap-around y */ |
| 253 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 252 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 254 | 253 | sprite+(ffy?i:-i), |
| 255 | 254 | colour, |
| 256 | 255 | ffx,ffy, |
| 257 | 256 | (x+xdisp)&0x1ff,((y-ydisp-16*i)&0x1ff)-0x200, |
| 258 | | machine.priority_bitmap,pri_mask,0); |
| 257 | machine().priority_bitmap,pri_mask,0); |
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 260 | if (rom[rom_offs+1]&0x80) break; /* end of block */ |
| r20931 | r20932 | |
| 269 | 268 | |
| 270 | 269 | /*****************************************************************************/ |
| 271 | 270 | |
| 272 | | static void m107_update_scroll_positions(running_machine &machine) |
| 271 | void m107_state::m107_update_scroll_positions() |
| 273 | 272 | { |
| 274 | | m107_state *state = machine.driver_data<m107_state>(); |
| 275 | 273 | int laynum; |
| 276 | 274 | int i; |
| 277 | 275 | |
| r20931 | r20932 | |
| 283 | 281 | |
| 284 | 282 | for (laynum = 0; laynum < 4; laynum++) |
| 285 | 283 | { |
| 286 | | pf_layer_info *layer = &state->m_pf_layer[laynum]; |
| 284 | pf_layer_info *layer = &m_pf_layer[laynum]; |
| 287 | 285 | |
| 288 | | int scrolly = state->m_control[0 + 2 * laynum]; |
| 289 | | int scrollx = state->m_control[1 + 2 * laynum]; |
| 286 | int scrolly = m_control[0 + 2 * laynum]; |
| 287 | int scrollx = m_control[1 + 2 * laynum]; |
| 290 | 288 | |
| 291 | | if (state->m_control[0x08 + laynum] & 0x01) //used by World PK Soccer goal scrolling and Fire Barrel sea wave effect (stage 2) / canyon parallax effect (stage 6) |
| 289 | if (m_control[0x08 + laynum] & 0x01) //used by World PK Soccer goal scrolling and Fire Barrel sea wave effect (stage 2) / canyon parallax effect (stage 6) |
| 292 | 290 | { |
| 293 | | const UINT16 *scrolldata = state->m_vram_data + (0xe000 + 0x200 * laynum) / 2; |
| 291 | const UINT16 *scrolldata = m_vram_data + (0xe000 + 0x200 * laynum) / 2; |
| 294 | 292 | |
| 295 | 293 | layer->tmap->set_scroll_rows(512); |
| 296 | 294 | for (i = 0; i < 512; i++) |
| r20931 | r20932 | |
| 309 | 307 | |
| 310 | 308 | /*****************************************************************************/ |
| 311 | 309 | |
| 312 | | static void m107_tilemap_draw(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int laynum, int category,int opaque) |
| 310 | void m107_state::m107_tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int laynum, int category,int opaque) |
| 313 | 311 | { |
| 314 | | m107_state *state = machine.driver_data<m107_state>(); |
| 315 | 312 | int line; |
| 316 | 313 | rectangle clip; |
| 317 | | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 314 | const rectangle &visarea = machine().primary_screen->visible_area(); |
| 318 | 315 | clip = visarea; |
| 319 | 316 | |
| 320 | | if (state->m_control[0x08 + laynum] & 0x02) |
| 317 | if (m_control[0x08 + laynum] & 0x02) |
| 321 | 318 | { |
| 322 | 319 | for (line = cliprect.min_y; line <= cliprect.max_y;line++) |
| 323 | 320 | { |
| 324 | | const UINT16 *scrolldata = state->m_vram_data + (0xe800 + 0x200 * laynum) / 2; |
| 321 | const UINT16 *scrolldata = m_vram_data + (0xe800 + 0x200 * laynum) / 2; |
| 325 | 322 | clip.min_y = clip.max_y = line; |
| 326 | 323 | |
| 327 | | state->m_pf_layer[laynum].tmap->set_scrollx(0, state->m_control[1 + 2 * laynum]); |
| 328 | | state->m_pf_layer[laynum].tmap->set_scrolly(0, (state->m_control[0 + 2 * laynum] + scrolldata[line])); |
| 324 | m_pf_layer[laynum].tmap->set_scrollx(0, m_control[1 + 2 * laynum]); |
| 325 | m_pf_layer[laynum].tmap->set_scrolly(0, (m_control[0 + 2 * laynum] + scrolldata[line])); |
| 329 | 326 | |
| 330 | | state->m_pf_layer[laynum].tmap->draw(bitmap, clip, category | opaque, category); |
| 327 | m_pf_layer[laynum].tmap->draw(bitmap, clip, category | opaque, category); |
| 331 | 328 | } |
| 332 | 329 | } |
| 333 | 330 | else |
| 334 | | state->m_pf_layer[laynum].tmap->draw(bitmap, cliprect, category | opaque, category); |
| 331 | m_pf_layer[laynum].tmap->draw(bitmap, cliprect, category | opaque, category); |
| 335 | 332 | } |
| 336 | 333 | |
| 337 | 334 | |
| 338 | | static void m107_screenrefresh(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 335 | void m107_state::m107_screenrefresh(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 339 | 336 | { |
| 340 | | m107_state *state = machine.driver_data<m107_state>(); |
| 341 | | machine.priority_bitmap.fill(0, cliprect); |
| 337 | machine().priority_bitmap.fill(0, cliprect); |
| 342 | 338 | |
| 343 | | if ((~state->m_control[0x0b] >> 7) & 1) |
| 339 | if ((~m_control[0x0b] >> 7) & 1) |
| 344 | 340 | { |
| 345 | | m107_tilemap_draw(machine, bitmap, cliprect, 3, 0,0); |
| 346 | | m107_tilemap_draw(machine, bitmap, cliprect, 3, 1,0); |
| 341 | m107_tilemap_draw(bitmap, cliprect, 3, 0,0); |
| 342 | m107_tilemap_draw(bitmap, cliprect, 3, 1,0); |
| 347 | 343 | } |
| 348 | 344 | else |
| 349 | 345 | bitmap.fill(0, cliprect); |
| 350 | 346 | |
| 351 | 347 | /* note: the opaque flag is used if layer 3 is disabled, noticeable in World PK Soccer title and gameplay screens */ |
| 352 | | m107_tilemap_draw(machine, bitmap, cliprect, 2, 0,(((state->m_control[0x0b] >> 7) & 1) ? TILEMAP_DRAW_OPAQUE : 0)); |
| 353 | | m107_tilemap_draw(machine, bitmap, cliprect, 1, 0,0); |
| 354 | | m107_tilemap_draw(machine, bitmap, cliprect, 0, 0,0); |
| 355 | | m107_tilemap_draw(machine, bitmap, cliprect, 2, 1,0); |
| 356 | | m107_tilemap_draw(machine, bitmap, cliprect, 1, 1,0); |
| 357 | | m107_tilemap_draw(machine, bitmap, cliprect, 0, 1,0); |
| 348 | m107_tilemap_draw(bitmap, cliprect, 2, 0,(((m_control[0x0b] >> 7) & 1) ? TILEMAP_DRAW_OPAQUE : 0)); |
| 349 | m107_tilemap_draw(bitmap, cliprect, 1, 0,0); |
| 350 | m107_tilemap_draw(bitmap, cliprect, 0, 0,0); |
| 351 | m107_tilemap_draw(bitmap, cliprect, 2, 1,0); |
| 352 | m107_tilemap_draw(bitmap, cliprect, 1, 1,0); |
| 353 | m107_tilemap_draw(bitmap, cliprect, 0, 1,0); |
| 358 | 354 | |
| 359 | | if(state->m_sprite_display) |
| 360 | | draw_sprites(machine, bitmap, cliprect); |
| 355 | if(m_sprite_display) |
| 356 | draw_sprites(bitmap, cliprect); |
| 361 | 357 | |
| 362 | 358 | /* This hardware probably has more priority values - but I haven't found |
| 363 | 359 | any used yet */ |
| r20931 | r20932 | |
| 382 | 378 | |
| 383 | 379 | UINT32 m107_state::screen_update_m107(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 384 | 380 | { |
| 385 | | m107_update_scroll_positions(machine()); |
| 386 | | m107_screenrefresh(machine(), bitmap, cliprect); |
| 381 | m107_update_scroll_positions(); |
| 382 | m107_screenrefresh(bitmap, cliprect); |
| 387 | 383 | return 0; |
| 388 | 384 | } |
trunk/src/mame/video/m92.c
| r20931 | r20932 | |
| 48 | 48 | { |
| 49 | 49 | m_sprite_buffer_busy = 1; |
| 50 | 50 | if (m_game_kludge!=2) /* Major Title 2 doesn't like this interrupt!? */ |
| 51 | | m92_sprite_interrupt(machine()); |
| 51 | m92_sprite_interrupt(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | WRITE16_MEMBER(m92_state::m92_spritecontrol_w) |
| r20931 | r20932 | |
| 308 | 308 | |
| 309 | 309 | /*****************************************************************************/ |
| 310 | 310 | |
| 311 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 311 | void m92_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 312 | 312 | { |
| 313 | | m92_state *state = machine.driver_data<m92_state>(); |
| 314 | | UINT16 *source = state->m_spriteram->buffer(); |
| 313 | UINT16 *source = m_spriteram->buffer(); |
| 315 | 314 | int offs, layer; |
| 316 | 315 | |
| 317 | 316 | for (layer = 0; layer < 8; layer++) |
| 318 | 317 | { |
| 319 | | for (offs = 0; offs < state->m_sprite_list; ) |
| 318 | for (offs = 0; offs < m_sprite_list; ) |
| 320 | 319 | { |
| 321 | 320 | int x = source[offs+3] & 0x1ff; |
| 322 | 321 | int y = source[offs+0] & 0x1ff; |
| r20931 | r20932 | |
| 345 | 344 | |
| 346 | 345 | for (row = 0; row < numrows; row++) |
| 347 | 346 | { |
| 348 | | if (state->flip_screen()) |
| 347 | if (flip_screen()) |
| 349 | 348 | { |
| 350 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 349 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 351 | 350 | code + s_ptr, color, !flipx, !flipy, |
| 352 | 351 | 464 - x, 240 - (y - row * 16), |
| 353 | | machine.priority_bitmap, pri, 0); |
| 352 | machine().priority_bitmap, pri, 0); |
| 354 | 353 | |
| 355 | 354 | // wrap around x |
| 356 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 355 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 357 | 356 | code + s_ptr, color, !flipx, !flipy, |
| 358 | 357 | 464 - x + 512, 240 - (y - row * 16), |
| 359 | | machine.priority_bitmap, pri, 0); |
| 358 | machine().priority_bitmap, pri, 0); |
| 360 | 359 | } |
| 361 | 360 | else |
| 362 | 361 | { |
| 363 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 362 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 364 | 363 | code + s_ptr, color, flipx, flipy, |
| 365 | 364 | x, y - row * 16, |
| 366 | | machine.priority_bitmap, pri, 0); |
| 365 | machine().priority_bitmap, pri, 0); |
| 367 | 366 | |
| 368 | 367 | // wrap around x |
| 369 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 368 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 370 | 369 | code + s_ptr, color, flipx, flipy, |
| 371 | 370 | x - 512, y - row * 16, |
| 372 | | machine.priority_bitmap, pri, 0); |
| 371 | machine().priority_bitmap, pri, 0); |
| 373 | 372 | } |
| 374 | 373 | if (flipy) s_ptr++; |
| 375 | 374 | else s_ptr--; |
| r20931 | r20932 | |
| 382 | 381 | } |
| 383 | 382 | |
| 384 | 383 | // This needs a lot of work... |
| 385 | | static void ppan_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 384 | void m92_state::ppan_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 386 | 385 | { |
| 387 | | m92_state *state = machine.driver_data<m92_state>(); |
| 388 | | UINT16 *source = state->m_spriteram->live(); // sprite buffer control is never triggered |
| 386 | UINT16 *source = m_spriteram->live(); // sprite buffer control is never triggered |
| 389 | 387 | int offs, layer; |
| 390 | 388 | |
| 391 | 389 | for (layer = 0; layer < 8; layer++) |
| 392 | 390 | { |
| 393 | | for (offs = 0; offs < state->m_sprite_list; ) |
| 391 | for (offs = 0; offs < m_sprite_list; ) |
| 394 | 392 | { |
| 395 | 393 | int x = source[offs+3] & 0x1ff; |
| 396 | 394 | int y = source[offs+0] & 0x1ff; |
| r20931 | r20932 | |
| 420 | 418 | |
| 421 | 419 | for (row = 0; row < numrows; row++) |
| 422 | 420 | { |
| 423 | | if (state->flip_screen()) |
| 421 | if (flip_screen()) |
| 424 | 422 | { |
| 425 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 423 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 426 | 424 | code + s_ptr, color, !flipx, !flipy, |
| 427 | 425 | 464 - x, 240 - (y - row * 16), |
| 428 | | machine.priority_bitmap, pri, 0); |
| 426 | machine().priority_bitmap, pri, 0); |
| 429 | 427 | |
| 430 | 428 | // wrap around x |
| 431 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 429 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 432 | 430 | code + s_ptr, color, !flipx, !flipy, |
| 433 | 431 | 464 - x + 512, 240 - (y - row * 16), |
| 434 | | machine.priority_bitmap, pri, 0); |
| 432 | machine().priority_bitmap, pri, 0); |
| 435 | 433 | } |
| 436 | 434 | else |
| 437 | 435 | { |
| 438 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 436 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 439 | 437 | code + s_ptr, color, flipx, flipy, |
| 440 | 438 | x, y - row * 16, |
| 441 | | machine.priority_bitmap, pri, 0); |
| 439 | machine().priority_bitmap, pri, 0); |
| 442 | 440 | |
| 443 | 441 | // wrap around x |
| 444 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 442 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 445 | 443 | code + s_ptr, color, flipx, flipy, |
| 446 | 444 | x - 512, y - row * 16, |
| 447 | | machine.priority_bitmap, pri, 0); |
| 445 | machine().priority_bitmap, pri, 0); |
| 448 | 446 | } |
| 449 | 447 | if (flipy) s_ptr++; |
| 450 | 448 | else s_ptr--; |
| r20931 | r20932 | |
| 458 | 456 | |
| 459 | 457 | /*****************************************************************************/ |
| 460 | 458 | |
| 461 | | static void m92_update_scroll_positions(running_machine &machine) |
| 459 | void m92_state::m92_update_scroll_positions() |
| 462 | 460 | { |
| 463 | | m92_state *state = machine.driver_data<m92_state>(); |
| 464 | 461 | int laynum; |
| 465 | 462 | int i; |
| 466 | 463 | |
| r20931 | r20932 | |
| 477 | 474 | |
| 478 | 475 | for (laynum = 0; laynum < 3; laynum++) |
| 479 | 476 | { |
| 480 | | pf_layer_info *layer = &state->m_pf_layer[laynum]; |
| 477 | pf_layer_info *layer = &m_pf_layer[laynum]; |
| 481 | 478 | |
| 482 | | if (state->m_pf_master_control[laynum] & 0x40) |
| 479 | if (m_pf_master_control[laynum] & 0x40) |
| 483 | 480 | { |
| 484 | | const UINT16 *scrolldata = state->m_vram_data + (0xf400 + 0x400 * laynum) / 2; |
| 481 | const UINT16 *scrolldata = m_vram_data + (0xf400 + 0x400 * laynum) / 2; |
| 485 | 482 | |
| 486 | 483 | layer->tmap->set_scroll_rows(512); |
| 487 | 484 | layer->wide_tmap->set_scroll_rows(512); |
| r20931 | r20932 | |
| 506 | 503 | |
| 507 | 504 | /*****************************************************************************/ |
| 508 | 505 | |
| 509 | | static void m92_draw_tiles(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 506 | void m92_state::m92_draw_tiles(bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 510 | 507 | { |
| 511 | | m92_state *state = machine.driver_data<m92_state>(); |
| 512 | 508 | |
| 513 | | if ((~state->m_pf_master_control[2] >> 4) & 1) |
| 509 | if ((~m_pf_master_control[2] >> 4) & 1) |
| 514 | 510 | { |
| 515 | | state->m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 516 | | state->m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 517 | | state->m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 518 | | state->m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 511 | m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 512 | m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 513 | m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 514 | m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 519 | 515 | } |
| 520 | 516 | |
| 521 | | state->m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 522 | | state->m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 523 | | state->m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 524 | | state->m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 517 | m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 518 | m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 519 | m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 520 | m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 525 | 521 | |
| 526 | | state->m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 527 | | state->m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 528 | | state->m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 529 | | state->m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 522 | m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 523 | m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); |
| 524 | m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 525 | m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); |
| 530 | 526 | } |
| 531 | 527 | |
| 532 | 528 | |
| r20931 | r20932 | |
| 534 | 530 | { |
| 535 | 531 | machine().priority_bitmap.fill(0, cliprect); |
| 536 | 532 | bitmap.fill(0, cliprect); |
| 537 | | m92_update_scroll_positions(machine()); |
| 538 | | m92_draw_tiles(machine(), bitmap, cliprect); |
| 533 | m92_update_scroll_positions(); |
| 534 | m92_draw_tiles(bitmap, cliprect); |
| 539 | 535 | |
| 540 | | draw_sprites(machine(), bitmap, cliprect); |
| 536 | draw_sprites(bitmap, cliprect); |
| 541 | 537 | |
| 542 | 538 | /* Flipscreen appears hardwired to the dipswitch - strange */ |
| 543 | 539 | if (machine().root_device().ioport("DSW")->read() & 0x100) |
| r20931 | r20932 | |
| 551 | 547 | { |
| 552 | 548 | machine().priority_bitmap.fill(0, cliprect); |
| 553 | 549 | bitmap.fill(0, cliprect); |
| 554 | | m92_update_scroll_positions(machine()); |
| 555 | | m92_draw_tiles(machine(), bitmap, cliprect); |
| 550 | m92_update_scroll_positions(); |
| 551 | m92_draw_tiles(bitmap, cliprect); |
| 556 | 552 | |
| 557 | | ppan_draw_sprites(machine(), bitmap, cliprect); |
| 553 | ppan_draw_sprites(bitmap, cliprect); |
| 558 | 554 | |
| 559 | 555 | /* Flipscreen appears hardwired to the dipswitch - strange */ |
| 560 | 556 | if (machine().root_device().ioport("DSW")->read() & 0x100) |
trunk/src/mame/video/mcr.c
| r20931 | r20932 | |
| 130 | 130 | * |
| 131 | 131 | *************************************/ |
| 132 | 132 | |
| 133 | | static void mcr_set_color(running_machine &machine, int index, int data) |
| 133 | void mcr_state::mcr_set_color(int index, int data) |
| 134 | 134 | { |
| 135 | | palette_set_color_rgb(machine, index, pal3bit(data >> 6), pal3bit(data >> 0), pal3bit(data >> 3)); |
| 135 | palette_set_color_rgb(machine(), index, pal3bit(data >> 6), pal3bit(data >> 0), pal3bit(data >> 3)); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
| 139 | | static void journey_set_color(running_machine &machine, int index, int data) |
| 139 | void mcr_state::journey_set_color(int index, int data) |
| 140 | 140 | { |
| 141 | 141 | /* 3 bits each, RGB */ |
| 142 | 142 | int r = (data >> 6) & 7; |
| r20931 | r20932 | |
| 149 | 149 | b = (b << 5) | (b << 1); |
| 150 | 150 | |
| 151 | 151 | /* set the BG color */ |
| 152 | | palette_set_color(machine, index, MAKE_RGB(r, g, b)); |
| 152 | palette_set_color(machine(), index, MAKE_RGB(r, g, b)); |
| 153 | 153 | |
| 154 | 154 | /* if this is an odd entry in the upper palette bank, the hardware */ |
| 155 | 155 | /* hard-codes a low 1 bit -- this is used for better grayscales */ |
| r20931 | r20932 | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /* set the FG color */ |
| 164 | | palette_set_color(machine, index + 64, MAKE_RGB(r, g, b)); |
| 164 | palette_set_color(machine(), index + 64, MAKE_RGB(r, g, b)); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
| r20931 | r20932 | |
| 169 | 169 | { |
| 170 | 170 | m_generic_paletteram_8[offset] = data; |
| 171 | 171 | offset &= 0x7f; |
| 172 | | mcr_set_color(machine(), (offset / 2) & 0x3f, data | ((offset & 1) << 8)); |
| 172 | mcr_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8)); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| r20931 | r20932 | |
| 198 | 198 | if ((offset & 0x780) == 0x780) |
| 199 | 199 | { |
| 200 | 200 | if (mcr_cpu_board != 91475) |
| 201 | | mcr_set_color(machine(), (offset / 2) & 0x3f, data | ((offset & 1) << 8)); |
| 201 | mcr_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8)); |
| 202 | 202 | else |
| 203 | | journey_set_color(machine(), (offset / 2) & 0x3f, data | ((offset & 1) << 8)); |
| 203 | journey_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8)); |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| r20931 | r20932 | |
| 224 | 224 | |
| 225 | 225 | /* palette RAM is mapped into the upper 0x80 bytes here */ |
| 226 | 226 | if ((effoffs & 0x780) == 0x780) |
| 227 | | mcr_set_color(machine(), ((offset & 0x400) >> 5) | ((offset >> 1) & 0x1f), data | ((offset & 1) << 8)); |
| 227 | mcr_set_color(((offset & 0x400) >> 5) | ((offset >> 1) & 0x1f), data | ((offset & 1) << 8)); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
| r20931 | r20932 | |
| 247 | 247 | * |
| 248 | 248 | *************************************/ |
| 249 | 249 | |
| 250 | | static void render_sprites_91399(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 250 | void mcr_state::render_sprites_91399(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 251 | 251 | { |
| 252 | | mcr_state *state = machine.driver_data<mcr_state>(); |
| 253 | | UINT8 *spriteram = state->m_spriteram; |
| 254 | | gfx_element *gfx = machine.gfx[1]; |
| 252 | UINT8 *spriteram = m_spriteram; |
| 253 | gfx_element *gfx = machine().gfx[1]; |
| 255 | 254 | int offs; |
| 256 | 255 | |
| 257 | 256 | /* render the sprites into the bitmap, ORing together */ |
| 258 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4) |
| 257 | for (offs = 0; offs < m_spriteram.bytes(); offs += 4) |
| 259 | 258 | { |
| 260 | 259 | int code, x, y, sx, sy, hflip, vflip; |
| 261 | 260 | |
| r20931 | r20932 | |
| 287 | 286 | { |
| 288 | 287 | const UINT8 *src = gfx->get_data(code) + gfx->rowbytes() * (y ^ vflip); |
| 289 | 288 | UINT16 *dst = &bitmap.pix16(sy); |
| 290 | | UINT8 *pri = &machine.priority_bitmap.pix8(sy); |
| 289 | UINT8 *pri = &machine().priority_bitmap.pix8(sy); |
| 291 | 290 | |
| 292 | 291 | /* loop over columns */ |
| 293 | 292 | for (x = 0; x < 32; x++) |
| r20931 | r20932 | |
| 320 | 319 | * |
| 321 | 320 | *************************************/ |
| 322 | 321 | |
| 323 | | static void render_sprites_91464(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int sprmask, int colormask) |
| 322 | void mcr_state::render_sprites_91464(bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int sprmask, int colormask) |
| 324 | 323 | { |
| 325 | | mcr_state *state = machine.driver_data<mcr_state>(); |
| 326 | | UINT8 *spriteram = state->m_spriteram; |
| 327 | | gfx_element *gfx = machine.gfx[1]; |
| 324 | UINT8 *spriteram = m_spriteram; |
| 325 | gfx_element *gfx = machine().gfx[1]; |
| 328 | 326 | int offs; |
| 329 | 327 | |
| 330 | 328 | /* render the sprites into the bitmap, working from topmost to bottommost */ |
| 331 | | for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 329 | for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 332 | 330 | { |
| 333 | 331 | int code, color, x, y, sx, sy, hflip, vflip; |
| 334 | 332 | |
| r20931 | r20932 | |
| 359 | 357 | { |
| 360 | 358 | const UINT8 *src = gfx->get_data(code) + gfx->rowbytes() * (y ^ vflip); |
| 361 | 359 | UINT16 *dst = &bitmap.pix16(sy); |
| 362 | | UINT8 *pri = &machine.priority_bitmap.pix8(sy); |
| 360 | UINT8 *pri = &machine().priority_bitmap.pix8(sy); |
| 363 | 361 | |
| 364 | 362 | /* loop over columns */ |
| 365 | 363 | for (x = 0; x < 32; x++) |
| r20931 | r20932 | |
| 411 | 409 | switch (mcr_sprite_board) |
| 412 | 410 | { |
| 413 | 411 | case 91399: |
| 414 | | render_sprites_91399(machine(), bitmap, cliprect); |
| 412 | render_sprites_91399(bitmap, cliprect); |
| 415 | 413 | break; |
| 416 | 414 | |
| 417 | 415 | case 91464: |
| 418 | 416 | if (mcr_cpu_board == 91442) |
| 419 | | render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x00); |
| 417 | render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00); |
| 420 | 418 | else if (mcr_cpu_board == 91475) |
| 421 | | render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x40); |
| 419 | render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x40); |
| 422 | 420 | else if (mcr_cpu_board == 91490) |
| 423 | | render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x00); |
| 421 | render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00); |
| 424 | 422 | else if (mcr_cpu_board == 91721) |
| 425 | | render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x00); |
| 423 | render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00); |
| 426 | 424 | break; |
| 427 | 425 | } |
| 428 | 426 | return 0; |
trunk/src/mame/video/mermaid.c
| r20931 | r20932 | |
| 178 | 178 | machine().primary_screen->register_screen_bitmap(m_helper2); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 181 | void mermaid_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 182 | 182 | { |
| 183 | 183 | const rectangle spritevisiblearea(0 * 8, 26 * 8 - 1, 2 * 8, 30 * 8 - 1); |
| 184 | 184 | const rectangle flip_spritevisiblearea(6 * 8, 31 * 8 - 1, 2 * 8, 30 * 8 - 1); |
| 185 | 185 | |
| 186 | | mermaid_state *state = machine.driver_data<mermaid_state>(); |
| 187 | | UINT8 *spriteram = state->m_spriteram; |
| 186 | UINT8 *spriteram = m_spriteram; |
| 188 | 187 | int offs; |
| 189 | 188 | |
| 190 | | for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 189 | for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 191 | 190 | { |
| 192 | 191 | int attr = spriteram[offs + 2]; |
| 193 | 192 | int bank = (attr & 0x30) >> 4; |
| r20931 | r20932 | |
| 200 | 199 | |
| 201 | 200 | if (sx >= 0xf0) sx -= 256; |
| 202 | 201 | |
| 203 | | code |= state->m_rougien_gfxbank1 * 0x2800; |
| 204 | | code |= state->m_rougien_gfxbank2 * 0x2400; |
| 202 | code |= m_rougien_gfxbank1 * 0x2800; |
| 203 | code |= m_rougien_gfxbank2 * 0x2400; |
| 205 | 204 | |
| 206 | | if (state->flip_screen_x()) |
| 205 | if (flip_screen_x()) |
| 207 | 206 | { |
| 208 | 207 | flipx = !flipx; |
| 209 | 208 | sx = 240 - sx; |
| 210 | 209 | } |
| 211 | 210 | |
| 212 | | if (state->flip_screen_y()) |
| 211 | if (flip_screen_y()) |
| 213 | 212 | { |
| 214 | 213 | flipy = !flipy; |
| 215 | 214 | sy = 240 - sy; |
| 216 | 215 | } |
| 217 | 216 | |
| 218 | | drawgfx_transpen(bitmap, (state->flip_screen_x() ? flip_spritevisiblearea : spritevisiblearea), |
| 219 | | machine.gfx[1], code, color, flipx, flipy, sx, sy, 0); |
| 217 | drawgfx_transpen(bitmap, (flip_screen_x() ? flip_spritevisiblearea : spritevisiblearea), |
| 218 | machine().gfx[1], code, color, flipx, flipy, sx, sy, 0); |
| 220 | 219 | } |
| 221 | 220 | } |
| 222 | 221 | |
| r20931 | r20932 | |
| 224 | 223 | { |
| 225 | 224 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 226 | 225 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 227 | | draw_sprites(machine(), bitmap, cliprect); |
| 226 | draw_sprites(bitmap, cliprect); |
| 228 | 227 | return 0; |
| 229 | 228 | } |
| 230 | 229 | |
| 231 | | static UINT8 collision_check( running_machine &machine, rectangle& rect ) |
| 230 | UINT8 mermaid_state::collision_check( rectangle& rect ) |
| 232 | 231 | { |
| 233 | | mermaid_state *state = machine.driver_data<mermaid_state>(); |
| 234 | 232 | UINT8 data = 0; |
| 235 | 233 | |
| 236 | 234 | int x; |
| r20931 | r20932 | |
| 239 | 237 | for (y = rect.min_y; y <= rect.max_y; y++) |
| 240 | 238 | for (x = rect.min_x; x <= rect.max_x; x++) |
| 241 | 239 | { |
| 242 | | UINT16 a = colortable_entry_get_value(machine.colortable, state->m_helper.pix16(y, x)) & 0x3f; |
| 243 | | UINT16 b = colortable_entry_get_value(machine.colortable, state->m_helper2.pix16(y, x)) & 0x3f; |
| 240 | UINT16 a = colortable_entry_get_value(machine().colortable, m_helper.pix16(y, x)) & 0x3f; |
| 241 | UINT16 b = colortable_entry_get_value(machine().colortable, m_helper2.pix16(y, x)) & 0x3f; |
| 244 | 242 | |
| 245 | 243 | if (b) |
| 246 | 244 | if (a) |
| r20931 | r20932 | |
| 314 | 312 | |
| 315 | 313 | drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0); |
| 316 | 314 | |
| 317 | | m_coll_bit2 |= collision_check(machine(), rect); |
| 315 | m_coll_bit2 |= collision_check(rect); |
| 318 | 316 | |
| 319 | 317 | // check collision sprite - foreground |
| 320 | 318 | |
| r20931 | r20932 | |
| 325 | 323 | |
| 326 | 324 | drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0); |
| 327 | 325 | |
| 328 | | m_coll_bit1 |= collision_check(machine(), rect); |
| 326 | m_coll_bit1 |= collision_check(rect); |
| 329 | 327 | |
| 330 | 328 | // check collision sprite - sprite |
| 331 | 329 | |
| r20931 | r20932 | |
| 366 | 364 | |
| 367 | 365 | drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0); |
| 368 | 366 | |
| 369 | | m_coll_bit0 |= collision_check(machine(), rect); |
| 367 | m_coll_bit0 |= collision_check(rect); |
| 370 | 368 | } |
| 371 | 369 | |
| 372 | 370 | // check for bit 3 (sprite-sprite) |
| r20931 | r20932 | |
| 447 | 445 | |
| 448 | 446 | drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0); |
| 449 | 447 | |
| 450 | | m_coll_bit3 |= collision_check(machine(), rect); |
| 448 | m_coll_bit3 |= collision_check(rect); |
| 451 | 449 | } |
| 452 | 450 | |
| 453 | 451 | // check for bit 6 |
| r20931 | r20932 | |
| 528 | 526 | |
| 529 | 527 | drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0); |
| 530 | 528 | |
| 531 | | m_coll_bit6 |= collision_check(machine(), rect); |
| 529 | m_coll_bit6 |= collision_check(rect); |
| 532 | 530 | } |
| 533 | 531 | } |
| 534 | 532 | } |
trunk/src/mame/video/ms32.c
| r20931 | r20932 | |
| 119 | 119 | /********** PALETTE WRITES **********/ |
| 120 | 120 | |
| 121 | 121 | |
| 122 | | static void update_color(running_machine &machine, int color) |
| 122 | void ms32_state::update_color(int color) |
| 123 | 123 | { |
| 124 | | ms32_state *state = machine.driver_data<ms32_state>(); |
| 125 | 124 | int r,g,b; |
| 126 | 125 | |
| 127 | 126 | /* I'm not sure how the brightness should be applied, currently I'm only |
| r20931 | r20932 | |
| 130 | 129 | */ |
| 131 | 130 | if (~color & 0x4000) |
| 132 | 131 | { |
| 133 | | r = ((state->m_palram_16[color*2] & 0xff00) >>8 ) * state->m_brt_r / 0x100; |
| 134 | | g = ((state->m_palram_16[color*2] & 0x00ff) >>0 ) * state->m_brt_g / 0x100; |
| 135 | | b = ((state->m_palram_16[color*2+1] & 0x00ff) >>0 ) * state->m_brt_b / 0x100; |
| 132 | r = ((m_palram_16[color*2] & 0xff00) >>8 ) * m_brt_r / 0x100; |
| 133 | g = ((m_palram_16[color*2] & 0x00ff) >>0 ) * m_brt_g / 0x100; |
| 134 | b = ((m_palram_16[color*2+1] & 0x00ff) >>0 ) * m_brt_b / 0x100; |
| 136 | 135 | } |
| 137 | 136 | else |
| 138 | 137 | { |
| 139 | | r = ((state->m_palram_16[color*2] & 0xff00) >>8 ); |
| 140 | | g = ((state->m_palram_16[color*2] & 0x00ff) >>0 ); |
| 141 | | b = ((state->m_palram_16[color*2+1] & 0x00ff) >>0 ); |
| 138 | r = ((m_palram_16[color*2] & 0xff00) >>8 ); |
| 139 | g = ((m_palram_16[color*2] & 0x00ff) >>0 ); |
| 140 | b = ((m_palram_16[color*2+1] & 0x00ff) >>0 ); |
| 142 | 141 | } |
| 143 | 142 | |
| 144 | | palette_set_color(machine,color,MAKE_RGB(r,g,b)); |
| 143 | palette_set_color(machine(),color,MAKE_RGB(r,g,b)); |
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | WRITE32_MEMBER(ms32_state::ms32_brightness_w) |
| r20931 | r20932 | |
| 194 | 193 | |
| 195 | 194 | |
| 196 | 195 | /* SPRITES based on tetrisp2 for now, readd priority bits later */ |
| 197 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_pri, const rectangle &cliprect, UINT16 *sprram_top, size_t sprram_size, int gfxnum, int reverseorder) |
| 196 | void ms32_state::draw_sprites(bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_pri, const rectangle &cliprect, UINT16 *sprram_top, size_t sprram_size, int gfxnum, int reverseorder) |
| 198 | 197 | { |
| 199 | 198 | int tx, ty, sx, sy, flipx, flipy; |
| 200 | 199 | int xsize, ysize; |
| 201 | 200 | int code, attr, color, size; |
| 202 | 201 | int pri; |
| 203 | 202 | int xzoom, yzoom; |
| 204 | | gfx_element *gfx = machine.gfx[gfxnum]; |
| 203 | gfx_element *gfx = machine().gfx[gfxnum]; |
| 205 | 204 | |
| 206 | 205 | UINT16 *source = sprram_top; |
| 207 | 206 | UINT16 *finish = sprram_top + (sprram_size - 0x10) / 2; |
| r20931 | r20932 | |
| 264 | 263 | } |
| 265 | 264 | |
| 266 | 265 | |
| 267 | | static void draw_roz(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,int priority) |
| 266 | void ms32_state::draw_roz(bitmap_ind16 &bitmap, const rectangle &cliprect,int priority) |
| 268 | 267 | { |
| 269 | | ms32_state *state = machine.driver_data<ms32_state>(); |
| 270 | 268 | /* TODO: registers 0x40/4 / 0x44/4 and 0x50/4 / 0x54/4 are used, meaning unknown */ |
| 271 | 269 | |
| 272 | | if (state->m_roz_ctrl[0x5c/4] & 1) /* "super" mode */ |
| 270 | if (m_roz_ctrl[0x5c/4] & 1) /* "super" mode */ |
| 273 | 271 | { |
| 274 | 272 | rectangle my_clip; |
| 275 | 273 | int y,maxy; |
| r20931 | r20932 | |
| 282 | 280 | |
| 283 | 281 | while (y <= maxy) |
| 284 | 282 | { |
| 285 | | UINT16 *lineaddr = state->m_lineram_16 + 8 * (y & 0xff); |
| 283 | UINT16 *lineaddr = m_lineram_16 + 8 * (y & 0xff); |
| 286 | 284 | |
| 287 | 285 | int start2x = (lineaddr[0x00/4] & 0xffff) | ((lineaddr[0x04/4] & 3) << 16); |
| 288 | 286 | int start2y = (lineaddr[0x08/4] & 0xffff) | ((lineaddr[0x0c/4] & 3) << 16); |
| 289 | 287 | int incxx = (lineaddr[0x10/4] & 0xffff) | ((lineaddr[0x14/4] & 1) << 16); |
| 290 | 288 | int incxy = (lineaddr[0x18/4] & 0xffff) | ((lineaddr[0x1c/4] & 1) << 16); |
| 291 | | int startx = (state->m_roz_ctrl[0x00/4] & 0xffff) | ((state->m_roz_ctrl[0x04/4] & 3) << 16); |
| 292 | | int starty = (state->m_roz_ctrl[0x08/4] & 0xffff) | ((state->m_roz_ctrl[0x0c/4] & 3) << 16); |
| 293 | | int offsx = state->m_roz_ctrl[0x30/4]; |
| 294 | | int offsy = state->m_roz_ctrl[0x34/4]; |
| 289 | int startx = (m_roz_ctrl[0x00/4] & 0xffff) | ((m_roz_ctrl[0x04/4] & 3) << 16); |
| 290 | int starty = (m_roz_ctrl[0x08/4] & 0xffff) | ((m_roz_ctrl[0x0c/4] & 3) << 16); |
| 291 | int offsx = m_roz_ctrl[0x30/4]; |
| 292 | int offsy = m_roz_ctrl[0x34/4]; |
| 295 | 293 | |
| 296 | 294 | my_clip.min_y = my_clip.max_y = y; |
| 297 | 295 | |
| 298 | | offsx += (state->m_roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 299 | | offsy += (state->m_roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 296 | offsx += (m_roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 297 | offsy += (m_roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 300 | 298 | |
| 301 | 299 | /* extend sign */ |
| 302 | 300 | if (start2x & 0x20000) start2x |= ~0x3ffff; |
| r20931 | r20932 | |
| 306 | 304 | if (incxx & 0x10000) incxx |= ~0x1ffff; |
| 307 | 305 | if (incxy & 0x10000) incxy |= ~0x1ffff; |
| 308 | 306 | |
| 309 | | state->m_roz_tilemap->draw_roz(bitmap, my_clip, |
| 307 | m_roz_tilemap->draw_roz(bitmap, my_clip, |
| 310 | 308 | (start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16, |
| 311 | 309 | incxx<<8, incxy<<8, 0, 0, |
| 312 | 310 | 1, // Wrap |
| r20931 | r20932 | |
| 317 | 315 | } |
| 318 | 316 | else /* "simple" mode */ |
| 319 | 317 | { |
| 320 | | int startx = (state->m_roz_ctrl[0x00/4] & 0xffff) | ((state->m_roz_ctrl[0x04/4] & 3) << 16); |
| 321 | | int starty = (state->m_roz_ctrl[0x08/4] & 0xffff) | ((state->m_roz_ctrl[0x0c/4] & 3) << 16); |
| 322 | | int incxx = (state->m_roz_ctrl[0x10/4] & 0xffff) | ((state->m_roz_ctrl[0x14/4] & 1) << 16); |
| 323 | | int incxy = (state->m_roz_ctrl[0x18/4] & 0xffff) | ((state->m_roz_ctrl[0x1c/4] & 1) << 16); |
| 324 | | int incyy = (state->m_roz_ctrl[0x20/4] & 0xffff) | ((state->m_roz_ctrl[0x24/4] & 1) << 16); |
| 325 | | int incyx = (state->m_roz_ctrl[0x28/4] & 0xffff) | ((state->m_roz_ctrl[0x2c/4] & 1) << 16); |
| 326 | | int offsx = state->m_roz_ctrl[0x30/4]; |
| 327 | | int offsy = state->m_roz_ctrl[0x34/4]; |
| 318 | int startx = (m_roz_ctrl[0x00/4] & 0xffff) | ((m_roz_ctrl[0x04/4] & 3) << 16); |
| 319 | int starty = (m_roz_ctrl[0x08/4] & 0xffff) | ((m_roz_ctrl[0x0c/4] & 3) << 16); |
| 320 | int incxx = (m_roz_ctrl[0x10/4] & 0xffff) | ((m_roz_ctrl[0x14/4] & 1) << 16); |
| 321 | int incxy = (m_roz_ctrl[0x18/4] & 0xffff) | ((m_roz_ctrl[0x1c/4] & 1) << 16); |
| 322 | int incyy = (m_roz_ctrl[0x20/4] & 0xffff) | ((m_roz_ctrl[0x24/4] & 1) << 16); |
| 323 | int incyx = (m_roz_ctrl[0x28/4] & 0xffff) | ((m_roz_ctrl[0x2c/4] & 1) << 16); |
| 324 | int offsx = m_roz_ctrl[0x30/4]; |
| 325 | int offsy = m_roz_ctrl[0x34/4]; |
| 328 | 326 | |
| 329 | | offsx += (state->m_roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 330 | | offsy += (state->m_roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 327 | offsx += (m_roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 328 | offsy += (m_roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1... |
| 331 | 329 | |
| 332 | 330 | /* extend sign */ |
| 333 | 331 | if (startx & 0x20000) startx |= ~0x3ffff; |
| r20931 | r20932 | |
| 337 | 335 | if (incyy & 0x10000) incyy |= ~0x1ffff; |
| 338 | 336 | if (incyx & 0x10000) incyx |= ~0x1ffff; |
| 339 | 337 | |
| 340 | | state->m_roz_tilemap->draw_roz(bitmap, cliprect, |
| 338 | m_roz_tilemap->draw_roz(bitmap, cliprect, |
| 341 | 339 | (startx+offsx)<<16, (starty+offsy)<<16, |
| 342 | 340 | incxx<<8, incxy<<8, incyx<<8, incyy<<8, |
| 343 | 341 | 1, // Wrap |
| r20931 | r20932 | |
| 365 | 363 | int i; |
| 366 | 364 | |
| 367 | 365 | for (i = 0;i < 0x10000;i++) // colors 0x3000-0x3fff are not used |
| 368 | | update_color(machine(), i); |
| 366 | update_color(i); |
| 369 | 367 | |
| 370 | 368 | scrollx = m_tx_scroll[0x00/4] + m_tx_scroll[0x08/4] + 0x18; |
| 371 | 369 | scrolly = m_tx_scroll[0x0c/4] + m_tx_scroll[0x14/4]; |
| r20931 | r20932 | |
| 392 | 390 | m_temp_bitmap_sprites.fill(0, cliprect); |
| 393 | 391 | m_temp_bitmap_sprites_pri.fill(0, cliprect); |
| 394 | 392 | |
| 395 | | draw_sprites(machine(), m_temp_bitmap_sprites, m_temp_bitmap_sprites_pri, cliprect, m_sprram_16, 0x20000, 0, m_reverse_sprite_order); |
| 393 | draw_sprites(m_temp_bitmap_sprites, m_temp_bitmap_sprites_pri, cliprect, m_sprram_16, 0x20000, 0, m_reverse_sprite_order); |
| 396 | 394 | |
| 397 | 395 | |
| 398 | 396 | |
| r20931 | r20932 | |
| 415 | 413 | rot_pri++; |
| 416 | 414 | |
| 417 | 415 | if (rot_pri == 0) |
| 418 | | draw_roz(machine(), m_temp_bitmap_tilemaps, cliprect, 1 << 1); |
| 416 | draw_roz(m_temp_bitmap_tilemaps, cliprect, 1 << 1); |
| 419 | 417 | else if (scr_pri == 0) |
| 420 | 418 | if (m_tilemaplayoutcontrol&1) |
| 421 | 419 | { |
| r20931 | r20932 | |
| 429 | 427 | m_tx_tilemap->draw(m_temp_bitmap_tilemaps, cliprect, 0, 1 << 2); |
| 430 | 428 | |
| 431 | 429 | if (rot_pri == 1) |
| 432 | | draw_roz(machine(), m_temp_bitmap_tilemaps, cliprect, 1 << 1); |
| 430 | draw_roz(m_temp_bitmap_tilemaps, cliprect, 1 << 1); |
| 433 | 431 | else if (scr_pri == 1) |
| 434 | 432 | if (m_tilemaplayoutcontrol&1) |
| 435 | 433 | { |
| r20931 | r20932 | |
| 443 | 441 | m_tx_tilemap->draw(m_temp_bitmap_tilemaps, cliprect, 0, 1 << 2); |
| 444 | 442 | |
| 445 | 443 | if (rot_pri == 2) |
| 446 | | draw_roz(machine(), m_temp_bitmap_tilemaps, cliprect, 1 << 1); |
| 444 | draw_roz(m_temp_bitmap_tilemaps, cliprect, 1 << 1); |
| 447 | 445 | else if (scr_pri == 2) |
| 448 | 446 | if (m_tilemaplayoutcontrol&1) |
| 449 | 447 | { |
trunk/src/mame/video/mcr3.c
| r20931 | r20932 | |
| 194 | 194 | * |
| 195 | 195 | *************************************/ |
| 196 | 196 | |
| 197 | | static void mcr3_update_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int code_xor, int dx, int dy) |
| 197 | void mcr3_state::mcr3_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int code_xor, int dx, int dy) |
| 198 | 198 | { |
| 199 | | mcr3_state *state = machine.driver_data<mcr3_state>(); |
| 200 | | UINT8 *spriteram = state->m_spriteram; |
| 199 | UINT8 *spriteram = m_spriteram; |
| 201 | 200 | int offs; |
| 202 | 201 | |
| 203 | | machine.priority_bitmap.fill(1, cliprect); |
| 202 | machine().priority_bitmap.fill(1, cliprect); |
| 204 | 203 | |
| 205 | 204 | /* loop over sprite RAM */ |
| 206 | | for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 205 | for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 207 | 206 | { |
| 208 | 207 | int code, color, flipx, flipy, sx, sy, flags; |
| 209 | 208 | |
| r20931 | r20932 | |
| 241 | 240 | if (!mcr_cocktail_flip) |
| 242 | 241 | { |
| 243 | 242 | /* first draw the sprite, visible */ |
| 244 | | pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, sx, sy, |
| 245 | | machine.priority_bitmap, 0x00, 0x0101); |
| 243 | pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, sx, sy, |
| 244 | machine().priority_bitmap, 0x00, 0x0101); |
| 246 | 245 | |
| 247 | 246 | /* then draw the mask, behind the background but obscuring following sprites */ |
| 248 | | pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, sx, sy, |
| 249 | | machine.priority_bitmap, 0x02, 0xfeff); |
| 247 | pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, sx, sy, |
| 248 | machine().priority_bitmap, 0x02, 0xfeff); |
| 250 | 249 | } |
| 251 | 250 | else |
| 252 | 251 | { |
| 253 | 252 | /* first draw the sprite, visible */ |
| 254 | | pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy, |
| 255 | | machine.priority_bitmap, 0x00, 0x0101); |
| 253 | pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy, |
| 254 | machine().priority_bitmap, 0x00, 0x0101); |
| 256 | 255 | |
| 257 | 256 | /* then draw the mask, behind the background but obscuring following sprites */ |
| 258 | | pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy, |
| 259 | | machine.priority_bitmap, 0x02, 0xfeff); |
| 257 | pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy, |
| 258 | machine().priority_bitmap, 0x02, 0xfeff); |
| 260 | 259 | } |
| 261 | 260 | } |
| 262 | 261 | } |
| r20931 | r20932 | |
| 278 | 277 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 279 | 278 | |
| 280 | 279 | /* draw the sprites */ |
| 281 | | mcr3_update_sprites(machine(), bitmap, cliprect, 0x03, 0, 0, 0); |
| 280 | mcr3_update_sprites(bitmap, cliprect, 0x03, 0, 0, 0); |
| 282 | 281 | return 0; |
| 283 | 282 | } |
| 284 | 283 | |
| r20931 | r20932 | |
| 292 | 291 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 293 | 292 | |
| 294 | 293 | /* draw the sprites */ |
| 295 | | mcr3_update_sprites(machine(), bitmap, cliprect, m_spyhunt_sprite_color_mask, 0, -12, 0); |
| 294 | mcr3_update_sprites(bitmap, cliprect, m_spyhunt_sprite_color_mask, 0, -12, 0); |
| 296 | 295 | |
| 297 | 296 | /* render any characters on top */ |
| 298 | 297 | m_alpha_tilemap->draw(bitmap, cliprect, 0, 0); |
trunk/src/mame/video/metro.c
| r20931 | r20932 | |
| 139 | 139 | /* This looks up a single pixel in a tile, given the tile code. |
| 140 | 140 | The Metro hardware has an indirection table, which is used here. |
| 141 | 141 | Returns if to draw the pixel or not, pixel colour is placed in pix */ |
| 142 | | INLINE UINT8 get_tile_pix( running_machine &machine, UINT16 code, UINT8 x, UINT8 y, int big, UINT16 *pix ) |
| 142 | inline UINT8 metro_state::get_tile_pix( UINT16 code, UINT8 x, UINT8 y, int big, UINT16 *pix ) |
| 143 | 143 | { |
| 144 | | metro_state *state = machine.driver_data<metro_state>(); |
| 145 | 144 | int table_index; |
| 146 | 145 | UINT32 tile; |
| 147 | 146 | |
| 148 | 147 | // Use code as an index into the tiles set table |
| 149 | 148 | table_index = ((code & 0x1ff0) >> 4) * 2; |
| 150 | | tile = (state->m_tiletable[table_index + 0] << 16) + state->m_tiletable[table_index + 1]; |
| 149 | tile = (m_tiletable[table_index + 0] << 16) + m_tiletable[table_index + 1]; |
| 151 | 150 | |
| 152 | 151 | if (code & 0x8000) // Special: draw a tile of a single color (i.e. not from the gfx ROMs) |
| 153 | 152 | { |
| r20931 | r20932 | |
| 158 | 157 | else |
| 159 | 158 | return 0; |
| 160 | 159 | } |
| 161 | | else if (((tile & 0x00f00000) == 0x00f00000) && (state->m_support_8bpp)) /* draw tile as 8bpp (e.g. balcube bg) */ |
| 160 | else if (((tile & 0x00f00000) == 0x00f00000) && (m_support_8bpp)) /* draw tile as 8bpp (e.g. balcube bg) */ |
| 162 | 161 | { |
| 163 | | gfx_element *gfx1 = machine.gfx[big?3:1]; |
| 162 | gfx_element *gfx1 = machine().gfx[big?3:1]; |
| 164 | 163 | UINT32 tile2 = big ? ((tile & 0xfffff) + 8*(code & 0xf)) : |
| 165 | 164 | ((tile & 0xfffff) + 2*(code & 0xf)); |
| 166 | 165 | const UINT8* data; |
| r20931 | r20932 | |
| 192 | 191 | } |
| 193 | 192 | else |
| 194 | 193 | { |
| 195 | | gfx_element *gfx1 = machine.gfx[big?2:0]; |
| 194 | gfx_element *gfx1 = machine().gfx[big?2:0]; |
| 196 | 195 | UINT32 tile2 = big ? ((tile & 0xfffff) + 4*(code & 0xf)) : |
| 197 | 196 | ((tile & 0xfffff) + (code & 0xf)); |
| 198 | 197 | const UINT8* data; |
| r20931 | r20932 | |
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | |
| 231 | | INLINE void metro_vram_w( running_machine &machine, offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram ) |
| 230 | inline void metro_state::metro_vram_w( offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram ) |
| 232 | 231 | { |
| 233 | 232 | COMBINE_DATA(&vram[offset]); |
| 234 | 233 | } |
| 235 | 234 | |
| 236 | | WRITE16_MEMBER(metro_state::metro_vram_0_w){ metro_vram_w(machine(), offset, data, mem_mask, 0, m_vram_0); } |
| 237 | | WRITE16_MEMBER(metro_state::metro_vram_1_w){ metro_vram_w(machine(), offset, data, mem_mask, 1, m_vram_1); } |
| 238 | | WRITE16_MEMBER(metro_state::metro_vram_2_w){ metro_vram_w(machine(), offset, data, mem_mask, 2, m_vram_2); } |
| 235 | WRITE16_MEMBER(metro_state::metro_vram_0_w){ metro_vram_w(offset, data, mem_mask, 0, m_vram_0); } |
| 236 | WRITE16_MEMBER(metro_state::metro_vram_1_w){ metro_vram_w(offset, data, mem_mask, 1, m_vram_1); } |
| 237 | WRITE16_MEMBER(metro_state::metro_vram_2_w){ metro_vram_w(offset, data, mem_mask, 2, m_vram_2); } |
| 239 | 238 | |
| 240 | 239 | |
| 241 | 240 | |
| r20931 | r20932 | |
| 408 | 407 | |
| 409 | 408 | ***************************************************************************/ |
| 410 | 409 | |
| 411 | | void metro_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 410 | void metro_state::metro_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 412 | 411 | { |
| 413 | | metro_state *state = machine.driver_data<metro_state>(); |
| 414 | | UINT8 *base_gfx4 = state->m_expanded_gfx1; |
| 415 | | UINT8 *base_gfx8 = state->memregion("gfx1")->base(); |
| 416 | | UINT32 gfx_size = state->memregion("gfx1")->bytes(); |
| 412 | UINT8 *base_gfx4 = m_expanded_gfx1; |
| 413 | UINT8 *base_gfx8 = memregion("gfx1")->base(); |
| 414 | UINT32 gfx_size = memregion("gfx1")->bytes(); |
| 417 | 415 | |
| 418 | | int max_x = machine.primary_screen->width(); |
| 419 | | int max_y = machine.primary_screen->height(); |
| 416 | int max_x = machine().primary_screen->width(); |
| 417 | int max_y = machine().primary_screen->height(); |
| 420 | 418 | |
| 421 | | int max_sprites = state->m_spriteram.bytes() / 8; |
| 422 | | int sprites = state->m_videoregs[0x00/2] % max_sprites; |
| 419 | int max_sprites = m_spriteram.bytes() / 8; |
| 420 | int sprites = m_videoregs[0x00/2] % max_sprites; |
| 423 | 421 | |
| 424 | | int color_start = (state->m_videoregs[0x08/2] & 0x0f) << 4; |
| 422 | int color_start = (m_videoregs[0x08/2] & 0x0f) << 4; |
| 425 | 423 | |
| 426 | 424 | int i, j, pri; |
| 427 | 425 | static const int primask[4] = { 0x0000, 0xff00, 0xff00 | 0xf0f0, 0xff00 | 0xf0f0 | 0xcccc }; |
| r20931 | r20932 | |
| 434 | 432 | |
| 435 | 433 | for (i = 0; i < 0x20; i++) |
| 436 | 434 | { |
| 437 | | if (!(state->m_videoregs[0x02/2] & 0x8000)) |
| 435 | if (!(m_videoregs[0x02/2] & 0x8000)) |
| 438 | 436 | { |
| 439 | | src = state->m_spriteram + (sprites - 1) * (8 / 2); |
| 437 | src = m_spriteram + (sprites - 1) * (8 / 2); |
| 440 | 438 | inc = -(8 / 2); |
| 441 | 439 | } else { |
| 442 | | src = state->m_spriteram; |
| 440 | src = m_spriteram; |
| 443 | 441 | inc = (8 / 2); |
| 444 | 442 | } |
| 445 | 443 | |
| r20931 | r20932 | |
| 467 | 465 | continue; |
| 468 | 466 | } |
| 469 | 467 | |
| 470 | | pri = (state->m_videoregs[0x02/2] & 0x0300) >> 8; |
| 468 | pri = (m_videoregs[0x02/2] & 0x0300) >> 8; |
| 471 | 469 | |
| 472 | | if (!(state->m_videoregs[0x02/2] & 0x8000)) |
| 470 | if (!(m_videoregs[0x02/2] & 0x8000)) |
| 473 | 471 | { |
| 474 | | if (curr_pri > (state->m_videoregs[0x02/2] & 0x1f)) |
| 475 | | pri = (state->m_videoregs[0x02/2] & 0x0c00) >> 10; |
| 472 | if (curr_pri > (m_videoregs[0x02/2] & 0x1f)) |
| 473 | pri = (m_videoregs[0x02/2] & 0x0c00) >> 10; |
| 476 | 474 | } |
| 477 | 475 | |
| 478 | 476 | y = src[1]; |
| r20931 | r20932 | |
| 485 | 483 | |
| 486 | 484 | zoom = zoomtable[(y & 0xfc00) >> 10] << (16 - 8); |
| 487 | 485 | |
| 488 | | x = (x & 0x07ff) - state->m_sprite_xoffs; |
| 489 | | y = (y & 0x03ff) - state->m_sprite_yoffs; |
| 486 | x = (x & 0x07ff) - m_sprite_xoffs; |
| 487 | y = (y & 0x03ff) - m_sprite_yoffs; |
| 490 | 488 | |
| 491 | 489 | width = (((attr >> 11) & 0x7) + 1) * 8; |
| 492 | 490 | height = (((attr >> 8) & 0x7) + 1) * 8; |
| 493 | 491 | |
| 494 | 492 | UINT32 gfxstart = (8 * 8 * 4 / 8) * (((attr & 0x000f) << 16) + code); |
| 495 | 493 | |
| 496 | | if (state->m_flip_screen) |
| 494 | if (m_flip_screen) |
| 497 | 495 | { |
| 498 | 496 | flipx = !flipx; x = max_x - x - width; |
| 499 | 497 | flipy = !flipy; y = max_y - y - height; |
| 500 | 498 | } |
| 501 | 499 | |
| 502 | | if (state->m_support_8bpp && color == 0xf) /* 8bpp */ |
| 500 | if (m_support_8bpp && color == 0xf) /* 8bpp */ |
| 503 | 501 | { |
| 504 | 502 | /* Bounds checking */ |
| 505 | 503 | if ((gfxstart + width * height - 1) >= gfx_size) |
| 506 | 504 | continue; |
| 507 | 505 | |
| 508 | | gfx_element gfx(machine, base_gfx8 + gfxstart, width, height, width, 0, 256); |
| 506 | gfx_element gfx(machine(), base_gfx8 + gfxstart, width, height, width, 0, 256); |
| 509 | 507 | |
| 510 | 508 | pdrawgfxzoom_transpen( bitmap,cliprect, &gfx, |
| 511 | 509 | 0, |
| r20931 | r20932 | |
| 513 | 511 | flipx, flipy, |
| 514 | 512 | x, y, |
| 515 | 513 | zoom, zoom, |
| 516 | | machine.priority_bitmap,primask[pri], 255); |
| 514 | machine().priority_bitmap,primask[pri], 255); |
| 517 | 515 | } |
| 518 | 516 | else |
| 519 | 517 | { |
| r20931 | r20932 | |
| 521 | 519 | if ((gfxstart + width / 2 * height - 1) >= gfx_size) |
| 522 | 520 | continue; |
| 523 | 521 | |
| 524 | | gfx_element gfx(machine, base_gfx4 + 2 * gfxstart, width, height, width, 0, 16); |
| 522 | gfx_element gfx(machine(), base_gfx4 + 2 * gfxstart, width, height, width, 0, 16); |
| 525 | 523 | |
| 526 | 524 | pdrawgfxzoom_transpen( bitmap,cliprect, &gfx, |
| 527 | 525 | 0, |
| r20931 | r20932 | |
| 529 | 527 | flipx, flipy, |
| 530 | 528 | x, y, |
| 531 | 529 | zoom, zoom, |
| 532 | | machine.priority_bitmap,primask[pri], 15); |
| 530 | machine().priority_bitmap,primask[pri], 15); |
| 533 | 531 | } |
| 534 | 532 | #if 0 |
| 535 | 533 | { /* Display priority + zoom on each sprite */ |
| r20931 | r20932 | |
| 555 | 553 | |
| 556 | 554 | // Copy a 'window' from the large 2048x2048 (or 4096x4096 for 16x16 tiles) tilemap |
| 557 | 555 | |
| 558 | | static void draw_tilemap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 flags, UINT32 pcode, |
| 556 | void metro_state::draw_tilemap( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 flags, UINT32 pcode, |
| 559 | 557 | int sx, int sy, int wx, int wy, int big, UINT16 *tilemapram, int layer ) |
| 560 | 558 | { |
| 561 | | metro_state *state = machine.driver_data<metro_state>(); |
| 562 | 559 | int y; |
| 563 | 560 | |
| 564 | | bitmap_ind8 &priority_bitmap = machine.priority_bitmap; |
| 561 | bitmap_ind8 &priority_bitmap = machine().priority_bitmap; |
| 565 | 562 | |
| 566 | 563 | int width = big ? 4096 : 2048; |
| 567 | 564 | int height = big ? 4096 : 2048; |
| r20931 | r20932 | |
| 572 | 569 | int windowwidth = width >> 2; |
| 573 | 570 | int windowheight = height >> 3; |
| 574 | 571 | |
| 575 | | sx += state->m_tilemap_scrolldx[layer] * (state->m_flip_screen ? 1 : -1); |
| 572 | sx += m_tilemap_scrolldx[layer] * (m_flip_screen ? 1 : -1); |
| 576 | 573 | |
| 577 | 574 | for (y = 0; y < scrheight; y++) |
| 578 | 575 | { |
| r20931 | r20932 | |
| 583 | 580 | int srcline = (wy+scrolly)&(height-1); |
| 584 | 581 | int srctilerow = srcline >> (big ? 4 : 3); |
| 585 | 582 | |
| 586 | | if (!state->m_flip_screen) |
| 583 | if (!m_flip_screen) |
| 587 | 584 | { |
| 588 | 585 | dst = &bitmap.pix16(y); |
| 589 | 586 | priority_baseaddr = &priority_bitmap.pix8(y); |
| r20931 | r20932 | |
| 598 | 595 | UINT16 dat = 0; |
| 599 | 596 | |
| 600 | 597 | UINT16 tile = tilemapram[tileoffs]; |
| 601 | | UINT8 draw = get_tile_pix(machine, tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat); |
| 598 | UINT8 draw = get_tile_pix(tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat); |
| 602 | 599 | |
| 603 | 600 | if (draw) |
| 604 | 601 | { |
| r20931 | r20932 | |
| 622 | 619 | UINT16 dat = 0; |
| 623 | 620 | |
| 624 | 621 | UINT16 tile = tilemapram[tileoffs]; |
| 625 | | UINT8 draw = get_tile_pix(machine, tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat); |
| 622 | UINT8 draw = get_tile_pix(tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat); |
| 626 | 623 | |
| 627 | 624 | if (draw) |
| 628 | 625 | { |
| r20931 | r20932 | |
| 636 | 633 | |
| 637 | 634 | // Draw all the layers that match the given priority |
| 638 | 635 | |
| 639 | | static void draw_layers( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int layers_ctrl ) |
| 636 | void metro_state::draw_layers( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int layers_ctrl ) |
| 640 | 637 | { |
| 641 | | metro_state *state = machine.driver_data<metro_state>(); |
| 642 | | UINT16 layers_pri = state->m_videoregs[0x10 / 2]; |
| 638 | UINT16 layers_pri = m_videoregs[0x10 / 2]; |
| 643 | 639 | int layer; |
| 644 | 640 | |
| 645 | 641 | // Draw all the layers with priority == pri |
| r20931 | r20932 | |
| 648 | 644 | if (pri == ((layers_pri >> (layer * 2)) & 3)) |
| 649 | 645 | { |
| 650 | 646 | // Scroll and Window values |
| 651 | | UINT16 sy = state->m_scroll[layer * 2 + 0]; UINT16 sx = state->m_scroll[layer * 2 + 1]; |
| 652 | | UINT16 wy = state->m_window[layer * 2 + 0]; UINT16 wx = state->m_window[layer * 2 + 1]; |
| 647 | UINT16 sy = m_scroll[layer * 2 + 0]; UINT16 sx = m_scroll[layer * 2 + 1]; |
| 648 | UINT16 wy = m_window[layer * 2 + 0]; UINT16 wx = m_window[layer * 2 + 1]; |
| 653 | 649 | |
| 654 | 650 | if (BIT(layers_ctrl, layer)) // for debug |
| 655 | 651 | { |
| r20931 | r20932 | |
| 657 | 653 | |
| 658 | 654 | switch (layer) |
| 659 | 655 | { |
| 660 | | case 0: tilemapram = state->m_vram_0; break; |
| 661 | | case 1: tilemapram = state->m_vram_1; break; |
| 662 | | case 2: tilemapram = state->m_vram_2; break; |
| 656 | case 0: tilemapram = m_vram_0; break; |
| 657 | case 1: tilemapram = m_vram_1; break; |
| 658 | case 2: tilemapram = m_vram_2; break; |
| 663 | 659 | } |
| 664 | 660 | |
| 665 | | int big = state->m_support_16x16 && (*state->m_screenctrl & (0x0020 << layer)); |
| 661 | int big = m_support_16x16 && (*m_screenctrl & (0x0020 << layer)); |
| 666 | 662 | |
| 667 | | draw_tilemap(machine, bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, big, tilemapram, layer); |
| 663 | draw_tilemap(bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, big, tilemapram, layer); |
| 668 | 664 | } |
| 669 | 665 | } |
| 670 | 666 | } |
| r20931 | r20932 | |
| 723 | 719 | k053936_zoom_draw(m_k053936, bitmap, cliprect, m_k053936_tilemap, 0, 0, 1); |
| 724 | 720 | |
| 725 | 721 | for (pri = 3; pri >= 0; pri--) |
| 726 | | draw_layers(machine(), bitmap, cliprect, pri, layers_ctrl); |
| 722 | draw_layers(bitmap, cliprect, pri, layers_ctrl); |
| 727 | 723 | |
| 728 | 724 | if (layers_ctrl & 0x08) |
| 729 | | metro_draw_sprites(machine(), bitmap, cliprect); |
| 725 | metro_draw_sprites(bitmap, cliprect); |
| 730 | 726 | |
| 731 | 727 | return 0; |
| 732 | 728 | } |
trunk/src/mame/video/madalien.c
| r20931 | r20932 | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
| 68 | | INLINE int scan_helper(int col, int row, int section) |
| 68 | inline int madalien_state::scan_helper(int col, int row, int section) |
| 69 | 69 | { |
| 70 | 70 | return (section << 8) | ((~col & 0x0f) << 3) | row; |
| 71 | 71 | } |
| r20931 | r20932 | |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
| 162 | | static void draw_edges(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip, int scroll_mode) |
| 162 | void madalien_state::draw_edges(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip, int scroll_mode) |
| 163 | 163 | { |
| 164 | | madalien_state *state = machine.driver_data<madalien_state>(); |
| 165 | 164 | rectangle clip_edge1; |
| 166 | 165 | rectangle clip_edge2; |
| 167 | 166 | |
| r20931 | r20932 | |
| 170 | 169 | |
| 171 | 170 | if (flip) |
| 172 | 171 | { |
| 173 | | clip_edge1.min_y = *state->m_edge1_pos | 0x80; |
| 174 | | clip_edge2.max_y = (*state->m_edge2_pos & 0x7f) ^ 0x7f; |
| 172 | clip_edge1.min_y = *m_edge1_pos | 0x80; |
| 173 | clip_edge2.max_y = (*m_edge2_pos & 0x7f) ^ 0x7f; |
| 175 | 174 | } |
| 176 | 175 | else |
| 177 | 176 | { |
| 178 | | clip_edge1.max_y = (*state->m_edge1_pos & 0x7f) ^ 0x7f; |
| 179 | | clip_edge2.min_y = *state->m_edge2_pos | 0x80; |
| 177 | clip_edge1.max_y = (*m_edge1_pos & 0x7f) ^ 0x7f; |
| 178 | clip_edge2.min_y = *m_edge2_pos | 0x80; |
| 180 | 179 | } |
| 181 | 180 | |
| 182 | 181 | clip_edge1 &= cliprect; |
| 183 | 182 | clip_edge2 &= cliprect; |
| 184 | 183 | |
| 185 | | state->m_tilemap_edge1[scroll_mode]->mark_all_dirty(); |
| 186 | | state->m_tilemap_edge2[scroll_mode]->mark_all_dirty(); |
| 184 | m_tilemap_edge1[scroll_mode]->mark_all_dirty(); |
| 185 | m_tilemap_edge2[scroll_mode]->mark_all_dirty(); |
| 187 | 186 | |
| 188 | | state->m_tilemap_edge1[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); |
| 189 | | state->m_tilemap_edge1[scroll_mode]->set_scrollx(0, -(*state->m_scroll & 0xfc)); |
| 190 | | state->m_tilemap_edge1[scroll_mode]->set_scrolly(0, *state->m_edge1_pos & 0x7f); |
| 187 | m_tilemap_edge1[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); |
| 188 | m_tilemap_edge1[scroll_mode]->set_scrollx(0, -(*m_scroll & 0xfc)); |
| 189 | m_tilemap_edge1[scroll_mode]->set_scrolly(0, *m_edge1_pos & 0x7f); |
| 191 | 190 | |
| 192 | | state->m_tilemap_edge2[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX : TILEMAP_FLIPY); |
| 193 | | state->m_tilemap_edge2[scroll_mode]->set_scrollx(0, -(*state->m_scroll & 0xfc)); |
| 194 | | state->m_tilemap_edge2[scroll_mode]->set_scrolly(0, *state->m_edge2_pos & 0x7f); |
| 191 | m_tilemap_edge2[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX : TILEMAP_FLIPY); |
| 192 | m_tilemap_edge2[scroll_mode]->set_scrollx(0, -(*m_scroll & 0xfc)); |
| 193 | m_tilemap_edge2[scroll_mode]->set_scrolly(0, *m_edge2_pos & 0x7f); |
| 195 | 194 | |
| 196 | | state->m_tilemap_edge1[scroll_mode]->draw(bitmap, clip_edge1, 0, 0); |
| 197 | | state->m_tilemap_edge2[scroll_mode]->draw(bitmap, clip_edge2, 0, 0); |
| 195 | m_tilemap_edge1[scroll_mode]->draw(bitmap, clip_edge1, 0, 0); |
| 196 | m_tilemap_edge2[scroll_mode]->draw(bitmap, clip_edge2, 0, 0); |
| 198 | 197 | } |
| 199 | 198 | |
| 200 | 199 | |
| 201 | | static void draw_headlight(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip) |
| 200 | void madalien_state::draw_headlight(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip) |
| 202 | 201 | { |
| 203 | | madalien_state *state = machine.driver_data<madalien_state>(); |
| 204 | | if (BIT(*state->m_video_flags, 0)) |
| 202 | if (BIT(*m_video_flags, 0)) |
| 205 | 203 | { |
| 206 | 204 | UINT8 y; |
| 207 | 205 | |
| 208 | 206 | for (y = 0; y < 0x80; y++) |
| 209 | 207 | { |
| 210 | 208 | UINT8 x; |
| 211 | | UINT8 hy = y - *state->m_headlight_pos; |
| 209 | UINT8 hy = y - *m_headlight_pos; |
| 212 | 210 | |
| 213 | 211 | if (flip) |
| 214 | 212 | hy = ~hy; |
| r20931 | r20932 | |
| 226 | 224 | if ((hx < cliprect.min_x) || (hx > cliprect.max_x)) |
| 227 | 225 | continue; |
| 228 | 226 | |
| 229 | | if (state->m_headlight_bitmap->pix16(y, x) != 0) |
| 227 | if (m_headlight_bitmap->pix16(y, x) != 0) |
| 230 | 228 | bitmap.pix16(hy, hx) |= 8; |
| 231 | 229 | } |
| 232 | 230 | } |
| r20931 | r20932 | |
| 234 | 232 | } |
| 235 | 233 | |
| 236 | 234 | |
| 237 | | static void draw_foreground(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip) |
| 235 | void madalien_state::draw_foreground(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip) |
| 238 | 236 | { |
| 239 | | madalien_state *state = machine.driver_data<madalien_state>(); |
| 240 | | state->m_tilemap_fg->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); |
| 241 | | state->m_tilemap_fg->draw(bitmap, cliprect, 0, 0); |
| 237 | m_tilemap_fg->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); |
| 238 | m_tilemap_fg->draw(bitmap, cliprect, 0, 0); |
| 242 | 239 | } |
| 243 | 240 | |
| 244 | 241 | |
| r20931 | r20932 | |
| 263 | 260 | int scroll_mode = *m_scroll & 3; |
| 264 | 261 | |
| 265 | 262 | bitmap.fill(0, cliprect); |
| 266 | | draw_edges(machine(), bitmap, cliprect, flip, scroll_mode); |
| 267 | | draw_foreground(machine(), bitmap, cliprect, flip); |
| 263 | draw_edges(bitmap, cliprect, flip, scroll_mode); |
| 264 | draw_foreground(bitmap, cliprect, flip); |
| 268 | 265 | |
| 269 | 266 | /* highlight section A (outside of tunnels). |
| 270 | 267 | * also, bit 1 of the video_flags register (6A) is |
| r20931 | r20932 | |
| 298 | 295 | bitmap.pix16(y, x) |= 8; |
| 299 | 296 | } |
| 300 | 297 | |
| 301 | | draw_headlight(machine(), bitmap, cliprect, flip); |
| 298 | draw_headlight(bitmap, cliprect, flip); |
| 302 | 299 | |
| 303 | 300 | return 0; |
| 304 | 301 | } |