trunk/src/mame/drivers/dkong.c
| r20764 | r20765 | |
| 400 | 400 | * |
| 401 | 401 | *************************************/ |
| 402 | 402 | |
| 403 | | static void dkong_init_device_driver_data( running_machine &machine ) |
| 403 | void dkong_state::dkong_init_device_driver_data( ) |
| 404 | 404 | { |
| 405 | | dkong_state *state = machine.driver_data<dkong_state>(); |
| 406 | 405 | |
| 407 | | state->m_dev_n2a03a = machine.device("n2a03a"); |
| 408 | | state->m_dev_n2a03b = machine.device("n2a03b"); |
| 409 | | state->m_dev_6h = machine.device("ls259.6h"); |
| 410 | | state->m_dev_vp2 = machine.device("virtual_p2"); |
| 406 | m_dev_n2a03a = machine().device("n2a03a"); |
| 407 | m_dev_n2a03b = machine().device("n2a03b"); |
| 408 | m_dev_6h = machine().device("ls259.6h"); |
| 409 | m_dev_vp2 = machine().device("virtual_p2"); |
| 411 | 410 | } |
| 412 | 411 | |
| 413 | 412 | MACHINE_START_MEMBER(dkong_state,dkong2b) |
| 414 | 413 | { |
| 415 | | dkong_init_device_driver_data(machine()); |
| 414 | dkong_init_device_driver_data(); |
| 416 | 415 | m_hardware_type = HARDWARE_TKG04; |
| 417 | 416 | |
| 418 | 417 | save_item(NAME(m_decrypt_counter)); |
| r20764 | r20765 | |
| 468 | 467 | |
| 469 | 468 | MACHINE_START_MEMBER(dkong_state,dkong3) |
| 470 | 469 | { |
| 471 | | dkong_init_device_driver_data(machine()); |
| 470 | dkong_init_device_driver_data(); |
| 472 | 471 | m_hardware_type = HARDWARE_TKG04; |
| 473 | 472 | } |
| 474 | 473 | |
| r20764 | r20765 | |
| 1606 | 1605 | eeprom->set_clock_line(data & 0x02 ? ASSERT_LINE : CLEAR_LINE); |
| 1607 | 1606 | } |
| 1608 | 1607 | |
| 1609 | | static void braze_decrypt_rom(running_machine &machine, UINT8 *dest) |
| 1608 | void dkong_state::braze_decrypt_rom(UINT8 *dest) |
| 1610 | 1609 | { |
| 1611 | 1610 | UINT8 oldbyte,newbyte; |
| 1612 | 1611 | UINT8 *ROM; |
| 1613 | 1612 | UINT32 mem; |
| 1614 | 1613 | UINT32 newmem; |
| 1615 | 1614 | |
| 1616 | | ROM = machine.root_device().memregion("braze")->base(); |
| 1615 | ROM = machine().root_device().memregion("braze")->base(); |
| 1617 | 1616 | |
| 1618 | 1617 | for (mem=0;mem<0x10000;mem++) |
| 1619 | 1618 | { |
| r20764 | r20765 | |
| 3026 | 3025 | * |
| 3027 | 3026 | *************************************/ |
| 3028 | 3027 | |
| 3029 | | static void drakton_decrypt_rom(running_machine &machine, UINT8 mod, int offs, int *bs) |
| 3028 | void dkong_state::drakton_decrypt_rom(UINT8 mod, int offs, int *bs) |
| 3030 | 3029 | { |
| 3031 | 3030 | UINT8 oldbyte,newbyte; |
| 3032 | 3031 | UINT8 *ROM; |
| 3033 | 3032 | int mem; |
| 3034 | 3033 | |
| 3035 | | ROM = machine.root_device().memregion("maincpu")->base(); |
| 3034 | ROM = machine().root_device().memregion("maincpu")->base(); |
| 3036 | 3035 | |
| 3037 | 3036 | for (mem=0;mem<0x4000;mem++) |
| 3038 | 3037 | { |
| r20764 | r20765 | |
| 3089 | 3088 | are actually used in the PAL. Therefore, we'll take a little |
| 3090 | 3089 | memory overhead and decrypt the ROMs using each method in advance. */ |
| 3091 | 3090 | |
| 3092 | | drakton_decrypt_rom(machine(), 0x02, 0x10000, bs[0]); |
| 3093 | | drakton_decrypt_rom(machine(), 0x40, 0x14000, bs[1]); |
| 3094 | | drakton_decrypt_rom(machine(), 0x8a, 0x18000, bs[2]); |
| 3095 | | drakton_decrypt_rom(machine(), 0xc8, 0x1c000, bs[3]); |
| 3091 | drakton_decrypt_rom(0x02, 0x10000, bs[0]); |
| 3092 | drakton_decrypt_rom(0x40, 0x14000, bs[1]); |
| 3093 | drakton_decrypt_rom(0x8a, 0x18000, bs[2]); |
| 3094 | drakton_decrypt_rom(0xc8, 0x1c000, bs[3]); |
| 3096 | 3095 | } |
| 3097 | 3096 | |
| 3098 | 3097 | |
| r20764 | r20765 | |
| 3110 | 3109 | /* While the PAL supports up to 16 decryption methods, only four |
| 3111 | 3110 | are actually used in the PAL. Therefore, we'll take a little |
| 3112 | 3111 | memory overhead and decrypt the ROMs using each method in advance. */ |
| 3113 | | drakton_decrypt_rom(machine(), 0x03, 0x10000, bs[0]); |
| 3114 | | drakton_decrypt_rom(machine(), 0x81, 0x14000, bs[1]); |
| 3115 | | drakton_decrypt_rom(machine(), 0x0a, 0x18000, bs[2]); |
| 3116 | | drakton_decrypt_rom(machine(), 0x88, 0x1c000, bs[3]); |
| 3112 | drakton_decrypt_rom(0x03, 0x10000, bs[0]); |
| 3113 | drakton_decrypt_rom(0x81, 0x14000, bs[1]); |
| 3114 | drakton_decrypt_rom(0x0a, 0x18000, bs[2]); |
| 3115 | drakton_decrypt_rom(0x88, 0x1c000, bs[3]); |
| 3117 | 3116 | |
| 3118 | 3117 | /* custom handlers supporting Joystick or Steering Wheel */ |
| 3119 | 3118 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x7c00, 0x7c00, read8_delegate(FUNC(dkong_state::strtheat_inputport_0_r),this)); |
| r20764 | r20765 | |
| 3136 | 3135 | space.install_read_handler(0xc800, 0xc800, read8_delegate(FUNC(dkong_state::braze_eeprom_r),this)); |
| 3137 | 3136 | space.install_write_handler(0xc800, 0xc800, write8_delegate(FUNC(dkong_state::braze_eeprom_w),this)); |
| 3138 | 3137 | |
| 3139 | | braze_decrypt_rom(machine(), decrypted); |
| 3138 | braze_decrypt_rom(decrypted); |
| 3140 | 3139 | |
| 3141 | 3140 | membank("bank1")->configure_entries(0, 2, &decrypted[0], 0x8000); |
| 3142 | 3141 | membank("bank1")->set_entry(0); |
trunk/src/mame/drivers/dragrace.c
| r20764 | r20765 | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | | static void dragrace_update_misc_flags( address_space &space ) |
| 37 | void dragrace_state::dragrace_update_misc_flags( address_space &space ) |
| 38 | 38 | { |
| 39 | | dragrace_state *state = space.machine().driver_data<dragrace_state>(); |
| 40 | 39 | /* 0x0900 = set 3SPEED1 0x00000001 |
| 41 | 40 | * 0x0901 = set 4SPEED1 0x00000002 |
| 42 | 41 | * 0x0902 = set 5SPEED1 0x00000004 |
| r20764 | r20765 | |
| 68 | 67 | * 0x091f = set Player 2 Start Lamp 0x80000000 |
| 69 | 68 | * 0x0938 = clear 0x0918 - 0x091f |
| 70 | 69 | */ |
| 71 | | set_led_status(space.machine(), 0, state->m_misc_flags & 0x00008000); |
| 72 | | set_led_status(space.machine(), 1, state->m_misc_flags & 0x80000000); |
| 70 | set_led_status(machine(), 0, m_misc_flags & 0x00008000); |
| 71 | set_led_status(machine(), 1, m_misc_flags & 0x80000000); |
| 73 | 72 | |
| 74 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_MOTOR1_DATA, ~state->m_misc_flags & 0x0000001f); // Speed1 data* |
| 75 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_EXPLODE1_EN, (state->m_misc_flags & 0x00000020) ? 1: 0); // Explosion1 enable |
| 76 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_SCREECH1_EN, (state->m_misc_flags & 0x00000040) ? 1: 0); // Screech1 enable |
| 77 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_KLEXPL1_EN, (state->m_misc_flags & 0x00000200) ? 1: 0); // KLEXPL1 enable |
| 78 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_MOTOR1_EN, (state->m_misc_flags & 0x00000800) ? 1: 0); // Motor1 enable |
| 73 | discrete_sound_w(m_discrete, space, DRAGRACE_MOTOR1_DATA, ~m_misc_flags & 0x0000001f); // Speed1 data* |
| 74 | discrete_sound_w(m_discrete, space, DRAGRACE_EXPLODE1_EN, (m_misc_flags & 0x00000020) ? 1: 0); // Explosion1 enable |
| 75 | discrete_sound_w(m_discrete, space, DRAGRACE_SCREECH1_EN, (m_misc_flags & 0x00000040) ? 1: 0); // Screech1 enable |
| 76 | discrete_sound_w(m_discrete, space, DRAGRACE_KLEXPL1_EN, (m_misc_flags & 0x00000200) ? 1: 0); // KLEXPL1 enable |
| 77 | discrete_sound_w(m_discrete, space, DRAGRACE_MOTOR1_EN, (m_misc_flags & 0x00000800) ? 1: 0); // Motor1 enable |
| 79 | 78 | |
| 80 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_MOTOR2_DATA, (~state->m_misc_flags & 0x001f0000) >> 0x10); // Speed2 data* |
| 81 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_EXPLODE2_EN, (state->m_misc_flags & 0x00200000) ? 1: 0); // Explosion2 enable |
| 82 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_SCREECH2_EN, (state->m_misc_flags & 0x00400000) ? 1: 0); // Screech2 enable |
| 83 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_KLEXPL2_EN, (state->m_misc_flags & 0x02000000) ? 1: 0); // KLEXPL2 enable |
| 84 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_MOTOR2_EN, (state->m_misc_flags & 0x08000000) ? 1: 0); // Motor2 enable |
| 79 | discrete_sound_w(m_discrete, space, DRAGRACE_MOTOR2_DATA, (~m_misc_flags & 0x001f0000) >> 0x10); // Speed2 data* |
| 80 | discrete_sound_w(m_discrete, space, DRAGRACE_EXPLODE2_EN, (m_misc_flags & 0x00200000) ? 1: 0); // Explosion2 enable |
| 81 | discrete_sound_w(m_discrete, space, DRAGRACE_SCREECH2_EN, (m_misc_flags & 0x00400000) ? 1: 0); // Screech2 enable |
| 82 | discrete_sound_w(m_discrete, space, DRAGRACE_KLEXPL2_EN, (m_misc_flags & 0x02000000) ? 1: 0); // KLEXPL2 enable |
| 83 | discrete_sound_w(m_discrete, space, DRAGRACE_MOTOR2_EN, (m_misc_flags & 0x08000000) ? 1: 0); // Motor2 enable |
| 85 | 84 | |
| 86 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_ATTRACT_EN, (state->m_misc_flags & 0x00001000) ? 1: 0); // Attract enable |
| 87 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_LOTONE_EN, (state->m_misc_flags & 0x00002000) ? 1: 0); // LoTone enable |
| 88 | | discrete_sound_w(state->m_discrete, space, DRAGRACE_HITONE_EN, (state->m_misc_flags & 0x20000000) ? 1: 0); // HiTone enable |
| 85 | discrete_sound_w(m_discrete, space, DRAGRACE_ATTRACT_EN, (m_misc_flags & 0x00001000) ? 1: 0); // Attract enable |
| 86 | discrete_sound_w(m_discrete, space, DRAGRACE_LOTONE_EN, (m_misc_flags & 0x00002000) ? 1: 0); // LoTone enable |
| 87 | discrete_sound_w(m_discrete, space, DRAGRACE_HITONE_EN, (m_misc_flags & 0x20000000) ? 1: 0); // HiTone enable |
| 89 | 88 | } |
| 90 | 89 | |
| 91 | 90 | WRITE8_MEMBER(dragrace_state::dragrace_misc_w) |
trunk/src/mame/drivers/darius.c
| r20764 | r20765 | |
| 139 | 139 | #include "darius.lh" |
| 140 | 140 | |
| 141 | 141 | |
| 142 | | static void parse_control( running_machine &machine ) /* assumes Z80 sandwiched between 68Ks */ |
| 142 | void darius_state::parse_control( ) /* assumes Z80 sandwiched between 68Ks */ |
| 143 | 143 | { |
| 144 | 144 | /* bit 0 enables cpu B */ |
| 145 | 145 | /* however this fails when recovering from a save state |
| 146 | 146 | if cpu B is disabled !! */ |
| 147 | | darius_state *state = machine.driver_data<darius_state>(); |
| 148 | | state->m_cpub->execute().set_input_line(INPUT_LINE_RESET, (state->m_cpua_ctrl & 0x01) ? CLEAR_LINE : ASSERT_LINE); |
| 147 | m_cpub->execute().set_input_line(INPUT_LINE_RESET, (m_cpua_ctrl & 0x01) ? CLEAR_LINE : ASSERT_LINE); |
| 149 | 148 | } |
| 150 | 149 | |
| 151 | 150 | WRITE16_MEMBER(darius_state::cpua_ctrl_w) |
| r20764 | r20765 | |
| 155 | 154 | |
| 156 | 155 | m_cpua_ctrl = data; |
| 157 | 156 | |
| 158 | | parse_control(machine()); |
| 157 | parse_control(); |
| 159 | 158 | |
| 160 | 159 | logerror("CPU #0 PC %06x: write %04x to cpu control\n", space.device().safe_pc(), data); |
| 161 | 160 | } |
| r20764 | r20765 | |
| 268 | 267 | SOUND |
| 269 | 268 | *****************************************************/ |
| 270 | 269 | |
| 271 | | static void reset_sound_region( running_machine &machine ) |
| 270 | void darius_state::reset_sound_region( ) |
| 272 | 271 | { |
| 273 | | darius_state *state = machine.driver_data<darius_state>(); |
| 274 | | state->membank("bank1")->set_entry(state->m_banknum); |
| 272 | membank("bank1")->set_entry(m_banknum); |
| 275 | 273 | } |
| 276 | 274 | |
| 277 | 275 | WRITE8_MEMBER(darius_state::sound_bankswitch_w) |
| 278 | 276 | { |
| 279 | 277 | m_banknum = data & 0x03; |
| 280 | | reset_sound_region(machine()); |
| 278 | reset_sound_region(); |
| 281 | 279 | // banknum = data; |
| 282 | 280 | // reset_sound_region(); |
| 283 | 281 | } |
| r20764 | r20765 | |
| 300 | 298 | Sound mixer/pan control |
| 301 | 299 | *****************************************************/ |
| 302 | 300 | |
| 303 | | static void update_fm0( running_machine &machine ) |
| 301 | void darius_state::update_fm0( ) |
| 304 | 302 | { |
| 305 | | darius_state *state = machine.driver_data<darius_state>(); |
| 306 | | int left = ( state->m_pan[0] * state->m_vol[6]) >> 8; |
| 307 | | int right = ((0xff - state->m_pan[0]) * state->m_vol[6]) >> 8; |
| 303 | int left = ( m_pan[0] * m_vol[6]) >> 8; |
| 304 | int right = ((0xff - m_pan[0]) * m_vol[6]) >> 8; |
| 308 | 305 | |
| 309 | | if (state->m_filter0_3l != NULL) |
| 310 | | state->m_filter0_3l->flt_volume_set_volume(left / 100.0); |
| 311 | | if (state->m_filter0_3r != NULL) |
| 312 | | state->m_filter0_3r->flt_volume_set_volume(right / 100.0); /* FM #0 */ |
| 306 | if (m_filter0_3l != NULL) |
| 307 | m_filter0_3l->flt_volume_set_volume(left / 100.0); |
| 308 | if (m_filter0_3r != NULL) |
| 309 | m_filter0_3r->flt_volume_set_volume(right / 100.0); /* FM #0 */ |
| 313 | 310 | } |
| 314 | 311 | |
| 315 | | static void update_fm1( running_machine &machine ) |
| 312 | void darius_state::update_fm1( ) |
| 316 | 313 | { |
| 317 | | darius_state *state = machine.driver_data<darius_state>(); |
| 318 | | int left = ( state->m_pan[1] * state->m_vol[7]) >> 8; |
| 319 | | int right = ((0xff - state->m_pan[1]) * state->m_vol[7]) >> 8; |
| 314 | int left = ( m_pan[1] * m_vol[7]) >> 8; |
| 315 | int right = ((0xff - m_pan[1]) * m_vol[7]) >> 8; |
| 320 | 316 | |
| 321 | | if (state->m_filter1_3l != NULL) |
| 322 | | state->m_filter1_3l->flt_volume_set_volume(left / 100.0); |
| 323 | | if (state->m_filter1_3r != NULL) |
| 324 | | state->m_filter1_3r->flt_volume_set_volume(right / 100.0); /* FM #1 */ |
| 317 | if (m_filter1_3l != NULL) |
| 318 | m_filter1_3l->flt_volume_set_volume(left / 100.0); |
| 319 | if (m_filter1_3r != NULL) |
| 320 | m_filter1_3r->flt_volume_set_volume(right / 100.0); /* FM #1 */ |
| 325 | 321 | } |
| 326 | 322 | |
| 327 | | static void update_psg0( running_machine &machine, int port ) |
| 323 | void darius_state::update_psg0( int port ) |
| 328 | 324 | { |
| 329 | | darius_state *state = machine.driver_data<darius_state>(); |
| 330 | 325 | filter_volume_device *lvol = NULL, *rvol = NULL; |
| 331 | 326 | int left, right; |
| 332 | 327 | |
| 333 | 328 | switch (port) |
| 334 | 329 | { |
| 335 | | case 0: lvol = state->m_filter0_0l; rvol = state->m_filter0_0r; break; |
| 336 | | case 1: lvol = state->m_filter0_1l; rvol = state->m_filter0_1r; break; |
| 337 | | case 2: lvol = state->m_filter0_2l; rvol = state->m_filter0_2r; break; |
| 330 | case 0: lvol = m_filter0_0l; rvol = m_filter0_0r; break; |
| 331 | case 1: lvol = m_filter0_1l; rvol = m_filter0_1r; break; |
| 332 | case 2: lvol = m_filter0_2l; rvol = m_filter0_2r; break; |
| 338 | 333 | default: break; |
| 339 | 334 | } |
| 340 | 335 | |
| 341 | | left = ( state->m_pan[2] * state->m_vol[port]) >> 8; |
| 342 | | right = ((0xff - state->m_pan[2]) * state->m_vol[port]) >> 8; |
| 336 | left = ( m_pan[2] * m_vol[port]) >> 8; |
| 337 | right = ((0xff - m_pan[2]) * m_vol[port]) >> 8; |
| 343 | 338 | |
| 344 | 339 | if (lvol != NULL) |
| 345 | 340 | lvol->flt_volume_set_volume(left / 100.0); |
| r20764 | r20765 | |
| 347 | 342 | rvol->flt_volume_set_volume(right / 100.0); |
| 348 | 343 | } |
| 349 | 344 | |
| 350 | | static void update_psg1( running_machine &machine, int port ) |
| 345 | void darius_state::update_psg1( int port ) |
| 351 | 346 | { |
| 352 | | darius_state *state = machine.driver_data<darius_state>(); |
| 353 | 347 | filter_volume_device *lvol = NULL, *rvol = NULL; |
| 354 | 348 | int left, right; |
| 355 | 349 | |
| 356 | 350 | switch (port) |
| 357 | 351 | { |
| 358 | | case 0: lvol = state->m_filter1_0l; rvol = state->m_filter1_0r; break; |
| 359 | | case 1: lvol = state->m_filter1_1l; rvol = state->m_filter1_1r; break; |
| 360 | | case 2: lvol = state->m_filter1_2l; rvol = state->m_filter1_2r; break; |
| 352 | case 0: lvol = m_filter1_0l; rvol = m_filter1_0r; break; |
| 353 | case 1: lvol = m_filter1_1l; rvol = m_filter1_1r; break; |
| 354 | case 2: lvol = m_filter1_2l; rvol = m_filter1_2r; break; |
| 361 | 355 | default: break; |
| 362 | 356 | } |
| 363 | 357 | |
| 364 | | left = ( state->m_pan[3] * state->m_vol[port + 3]) >> 8; |
| 365 | | right = ((0xff - state->m_pan[3]) * state->m_vol[port + 3]) >> 8; |
| 358 | left = ( m_pan[3] * m_vol[port + 3]) >> 8; |
| 359 | right = ((0xff - m_pan[3]) * m_vol[port + 3]) >> 8; |
| 366 | 360 | |
| 367 | 361 | if (lvol != NULL) |
| 368 | 362 | lvol->flt_volume_set_volume(left / 100.0); |
| r20764 | r20765 | |
| 370 | 364 | rvol->flt_volume_set_volume(right / 100.0); |
| 371 | 365 | } |
| 372 | 366 | |
| 373 | | static void update_da( running_machine &machine ) |
| 367 | void darius_state::update_da( ) |
| 374 | 368 | { |
| 375 | | darius_state *state = machine.driver_data<darius_state>(); |
| 376 | | int left = state->m_def_vol[(state->m_pan[4] >> 4) & 0x0f]; |
| 377 | | int right = state->m_def_vol[(state->m_pan[4] >> 0) & 0x0f]; |
| 369 | int left = m_def_vol[(m_pan[4] >> 4) & 0x0f]; |
| 370 | int right = m_def_vol[(m_pan[4] >> 0) & 0x0f]; |
| 378 | 371 | |
| 379 | | if (state->m_msm5205_l != NULL) |
| 380 | | state->m_msm5205_l->flt_volume_set_volume(left / 100.0); |
| 381 | | if (state->m_msm5205_r != NULL) |
| 382 | | state->m_msm5205_r->flt_volume_set_volume(right / 100.0); |
| 372 | if (m_msm5205_l != NULL) |
| 373 | m_msm5205_l->flt_volume_set_volume(left / 100.0); |
| 374 | if (m_msm5205_r != NULL) |
| 375 | m_msm5205_r->flt_volume_set_volume(right / 100.0); |
| 383 | 376 | } |
| 384 | 377 | |
| 385 | 378 | WRITE8_MEMBER(darius_state::darius_fm0_pan) |
| 386 | 379 | { |
| 387 | 380 | m_pan[0] = data & 0xff; /* data 0x00:right 0xff:left */ |
| 388 | | update_fm0(machine()); |
| 381 | update_fm0(); |
| 389 | 382 | } |
| 390 | 383 | |
| 391 | 384 | WRITE8_MEMBER(darius_state::darius_fm1_pan) |
| 392 | 385 | { |
| 393 | 386 | m_pan[1] = data & 0xff; |
| 394 | | update_fm1(machine()); |
| 387 | update_fm1(); |
| 395 | 388 | } |
| 396 | 389 | |
| 397 | 390 | WRITE8_MEMBER(darius_state::darius_psg0_pan) |
| 398 | 391 | { |
| 399 | 392 | m_pan[2] = data & 0xff; |
| 400 | | update_psg0(machine(), 0); |
| 401 | | update_psg0(machine(), 1); |
| 402 | | update_psg0(machine(), 2); |
| 393 | update_psg0(0); |
| 394 | update_psg0(1); |
| 395 | update_psg0(2); |
| 403 | 396 | } |
| 404 | 397 | |
| 405 | 398 | WRITE8_MEMBER(darius_state::darius_psg1_pan) |
| 406 | 399 | { |
| 407 | 400 | m_pan[3] = data & 0xff; |
| 408 | | update_psg1(machine(), 0); |
| 409 | | update_psg1(machine(), 1); |
| 410 | | update_psg1(machine(), 2); |
| 401 | update_psg1( 0); |
| 402 | update_psg1( 1); |
| 403 | update_psg1( 2); |
| 411 | 404 | } |
| 412 | 405 | |
| 413 | 406 | WRITE8_MEMBER(darius_state::darius_da_pan) |
| 414 | 407 | { |
| 415 | 408 | m_pan[4] = data & 0xff; |
| 416 | | update_da(machine()); |
| 409 | update_da(); |
| 417 | 410 | } |
| 418 | 411 | |
| 419 | 412 | /**** Mixer Control ****/ |
| r20764 | r20765 | |
| 426 | 419 | |
| 427 | 420 | m_vol[0] = m_def_vol[(data >> 4) & 0x0f]; |
| 428 | 421 | m_vol[6] = m_def_vol[(data >> 0) & 0x0f]; |
| 429 | | update_fm0(machine()); |
| 430 | | update_psg0(machine(), 0); |
| 422 | update_fm0(); |
| 423 | update_psg0(0); |
| 431 | 424 | } |
| 432 | 425 | |
| 433 | 426 | WRITE8_MEMBER(darius_state::darius_write_portA1) |
| r20764 | r20765 | |
| 437 | 430 | |
| 438 | 431 | m_vol[3] = m_def_vol[(data >> 4) & 0x0f]; |
| 439 | 432 | m_vol[7] = m_def_vol[(data >> 0) & 0x0f]; |
| 440 | | update_fm1(machine()); |
| 441 | | update_psg1(machine(), 0); |
| 433 | update_fm1(); |
| 434 | update_psg1( 0); |
| 442 | 435 | } |
| 443 | 436 | |
| 444 | 437 | WRITE8_MEMBER(darius_state::darius_write_portB0) |
| r20764 | r20765 | |
| 448 | 441 | |
| 449 | 442 | m_vol[1] = m_def_vol[(data >> 4) & 0x0f]; |
| 450 | 443 | m_vol[2] = m_def_vol[(data >> 0) & 0x0f]; |
| 451 | | update_psg0(machine(), 1); |
| 452 | | update_psg0(machine(), 2); |
| 444 | update_psg0(1); |
| 445 | update_psg0(2); |
| 453 | 446 | } |
| 454 | 447 | |
| 455 | 448 | WRITE8_MEMBER(darius_state::darius_write_portB1) |
| r20764 | r20765 | |
| 459 | 452 | |
| 460 | 453 | m_vol[4] = m_def_vol[(data >> 4) & 0x0f]; |
| 461 | 454 | m_vol[5] = m_def_vol[(data >> 0) & 0x0f]; |
| 462 | | update_psg1(machine(), 1); |
| 463 | | update_psg1(machine(), 2); |
| 455 | update_psg1( 1); |
| 456 | update_psg1( 2); |
| 464 | 457 | } |
| 465 | 458 | |
| 466 | 459 | |
| r20764 | r20765 | |
| 822 | 815 | |
| 823 | 816 | void darius_state::darius_postload() |
| 824 | 817 | { |
| 825 | | parse_control(machine()); |
| 826 | | reset_sound_region(machine()); |
| 818 | parse_control(); |
| 819 | reset_sound_region(); |
| 827 | 820 | } |
| 828 | 821 | |
| 829 | 822 | void darius_state::machine_start() |
trunk/src/mame/machine/dec0.c
| r20764 | r20765 | |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | | static void baddudes_i8751_write(running_machine &machine, int data) |
| 204 | void dec0_state::baddudes_i8751_write(int data) |
| 205 | 205 | { |
| 206 | | dec0_state *state = machine.driver_data<dec0_state>(); |
| 207 | | state->m_i8751_return=0; |
| 206 | m_i8751_return=0; |
| 208 | 207 | |
| 209 | 208 | switch (data&0xffff) { |
| 210 | | case 0x714: state->m_i8751_return=0x700; break; |
| 211 | | case 0x73b: state->m_i8751_return=0x701; break; |
| 212 | | case 0x72c: state->m_i8751_return=0x702; break; |
| 213 | | case 0x73f: state->m_i8751_return=0x703; break; |
| 214 | | case 0x755: state->m_i8751_return=0x704; break; |
| 215 | | case 0x722: state->m_i8751_return=0x705; break; |
| 216 | | case 0x72b: state->m_i8751_return=0x706; break; |
| 217 | | case 0x724: state->m_i8751_return=0x707; break; |
| 218 | | case 0x728: state->m_i8751_return=0x708; break; |
| 219 | | case 0x735: state->m_i8751_return=0x709; break; |
| 220 | | case 0x71d: state->m_i8751_return=0x70a; break; |
| 221 | | case 0x721: state->m_i8751_return=0x70b; break; |
| 222 | | case 0x73e: state->m_i8751_return=0x70c; break; |
| 223 | | case 0x761: state->m_i8751_return=0x70d; break; |
| 224 | | case 0x753: state->m_i8751_return=0x70e; break; |
| 225 | | case 0x75b: state->m_i8751_return=0x70f; break; |
| 209 | case 0x714: m_i8751_return=0x700; break; |
| 210 | case 0x73b: m_i8751_return=0x701; break; |
| 211 | case 0x72c: m_i8751_return=0x702; break; |
| 212 | case 0x73f: m_i8751_return=0x703; break; |
| 213 | case 0x755: m_i8751_return=0x704; break; |
| 214 | case 0x722: m_i8751_return=0x705; break; |
| 215 | case 0x72b: m_i8751_return=0x706; break; |
| 216 | case 0x724: m_i8751_return=0x707; break; |
| 217 | case 0x728: m_i8751_return=0x708; break; |
| 218 | case 0x735: m_i8751_return=0x709; break; |
| 219 | case 0x71d: m_i8751_return=0x70a; break; |
| 220 | case 0x721: m_i8751_return=0x70b; break; |
| 221 | case 0x73e: m_i8751_return=0x70c; break; |
| 222 | case 0x761: m_i8751_return=0x70d; break; |
| 223 | case 0x753: m_i8751_return=0x70e; break; |
| 224 | case 0x75b: m_i8751_return=0x70f; break; |
| 226 | 225 | } |
| 227 | 226 | |
| 228 | | if (!state->m_i8751_return) logerror("%s: warning - write unknown command %02x to 8571\n",machine.describe_context(),data); |
| 229 | | machine.device("maincpu")->execute().set_input_line(5, HOLD_LINE); |
| 227 | if (!m_i8751_return) logerror("%s: warning - write unknown command %02x to 8571\n",machine().describe_context(),data); |
| 228 | machine().device("maincpu")->execute().set_input_line(5, HOLD_LINE); |
| 230 | 229 | } |
| 231 | 230 | |
| 232 | | static void birdtry_i8751_write(running_machine &machine, int data) |
| 231 | void dec0_state::birdtry_i8751_write(int data) |
| 233 | 232 | { |
| 234 | | dec0_state *state = machine.driver_data<dec0_state>(); |
| 235 | 233 | static int pwr, |
| 236 | 234 | hgt; |
| 237 | 235 | |
| 238 | | state->m_i8751_return=0; |
| 236 | m_i8751_return=0; |
| 239 | 237 | |
| 240 | 238 | switch(data&0xffff) { |
| 241 | 239 | /*"Sprite control"*/ |
| 242 | | case 0x22a: state->m_i8751_return = 0x200; break; |
| 240 | case 0x22a: m_i8751_return = 0x200; break; |
| 243 | 241 | |
| 244 | 242 | /* Gives an O.B. otherwise (it must be > 0xb0 )*/ |
| 245 | | case 0x3c7: state->m_i8751_return = 0x7ff; break; |
| 243 | case 0x3c7: m_i8751_return = 0x7ff; break; |
| 246 | 244 | |
| 247 | 245 | /*Enables shot checks*/ |
| 248 | | case 0x33c: state->m_i8751_return = 0x200; break; |
| 246 | case 0x33c: m_i8751_return = 0x200; break; |
| 249 | 247 | |
| 250 | 248 | /*Used on the title screen only(???)*/ |
| 251 | | case 0x31e: state->m_i8751_return = 0x200; break; |
| 249 | case 0x31e: m_i8751_return = 0x200; break; |
| 252 | 250 | |
| 253 | 251 | /* 0x100-0x10d values are for club power meters(1W=0x100<<-->>PT=0x10d). * |
| 254 | 252 | * Returned value to i8751 doesn't matter,but send the result to 0x481. * |
| r20764 | r20765 | |
| 267 | 265 | case 0x10b: pwr = 0x5c; break; /*PW*/ |
| 268 | 266 | case 0x10c: pwr = 0x60; break; /*SW*/ |
| 269 | 267 | case 0x10d: pwr = 0x80; break; /*PT*/ |
| 270 | | case 0x481: state->m_i8751_return = pwr; break; /*Power meter*/ |
| 268 | case 0x481: m_i8751_return = pwr; break; /*Power meter*/ |
| 271 | 269 | |
| 272 | 270 | /* 0x200-0x20f values are for shot height(STRONG=0x200<<-->>WEAK=0x20f). * |
| 273 | 271 | * Returned value to i8751 doesn't matter,but send the result to 0x534. * |
| r20764 | r20765 | |
| 288 | 286 | case 0x20d: hgt = 0x280; break; /*|*/ |
| 289 | 287 | case 0x20e: hgt = 0x240; break; /*|*/ |
| 290 | 288 | case 0x20f: hgt = 0x200; break; /*L*/ |
| 291 | | case 0x534: state->m_i8751_return = hgt; break; /*Shot height*/ |
| 289 | case 0x534: m_i8751_return = hgt; break; /*Shot height*/ |
| 292 | 290 | |
| 293 | 291 | /*At the ending screen(???)*/ |
| 294 | | //case 0x3b4: state->m_i8751_return = 0; break; |
| 292 | //case 0x3b4: m_i8751_return = 0; break; |
| 295 | 293 | |
| 296 | 294 | /*These are activated after a shot (???)*/ |
| 297 | | case 0x6ca: state->m_i8751_return = 0xff; break; |
| 298 | | case 0x7ff: state->m_i8751_return = 0x200; break; |
| 299 | | default: logerror("%s: warning - write unknown command %02x to 8571\n",machine.describe_context(),data); |
| 295 | case 0x6ca: m_i8751_return = 0xff; break; |
| 296 | case 0x7ff: m_i8751_return = 0x200; break; |
| 297 | default: logerror("%s: warning - write unknown command %02x to 8571\n",machine().describe_context(),data); |
| 300 | 298 | } |
| 301 | | machine.device("maincpu")->execute().set_input_line(5, HOLD_LINE); |
| 299 | machine().device("maincpu")->execute().set_input_line(5, HOLD_LINE); |
| 302 | 300 | } |
| 303 | 301 | |
| 304 | | void dec0_i8751_write(running_machine &machine, int data) |
| 302 | void dec0_state::dec0_i8751_write(int data) |
| 305 | 303 | { |
| 306 | | dec0_state *state = machine.driver_data<dec0_state>(); |
| 307 | | state->m_i8751_command=data; |
| 304 | m_i8751_command=data; |
| 308 | 305 | |
| 309 | 306 | /* Writes to this address cause an IRQ to the i8751 microcontroller */ |
| 310 | | if (state->m_GAME == 1) machine.device("mcu")->execute().set_input_line(MCS51_INT1_LINE, ASSERT_LINE); |
| 311 | | if (state->m_GAME == 2) baddudes_i8751_write(machine, data); |
| 312 | | if (state->m_GAME == 3) birdtry_i8751_write(machine, data); |
| 307 | if (m_GAME == 1) machine().device("mcu")->execute().set_input_line(MCS51_INT1_LINE, ASSERT_LINE); |
| 308 | if (m_GAME == 2) baddudes_i8751_write(data); |
| 309 | if (m_GAME == 3) birdtry_i8751_write(data); |
| 313 | 310 | |
| 314 | | //logerror("%s: warning - write %02x to i8751\n",machine.describe_context(),data); |
| 311 | //logerror("%s: warning - write %02x to i8751\n",machine().describe_context(),data); |
| 315 | 312 | } |
| 316 | 313 | |
| 317 | | void dec0_i8751_reset(running_machine &machine) |
| 314 | void dec0_state::dec0_i8751_reset() |
| 318 | 315 | { |
| 319 | | dec0_state *state = machine.driver_data<dec0_state>(); |
| 320 | | state->m_i8751_return=state->m_i8751_command=0; |
| 316 | m_i8751_return=m_i8751_command=0; |
| 321 | 317 | } |
| 322 | 318 | |
| 323 | 319 | /******************************************************************************/ |
| r20764 | r20765 | |
| 348 | 344 | |
| 349 | 345 | /******************************************************************************/ |
| 350 | 346 | |
| 351 | | static void h6280_decrypt(running_machine &machine, const char *cputag) |
| 347 | void dec0_state::h6280_decrypt(const char *cputag) |
| 352 | 348 | { |
| 353 | 349 | int i; |
| 354 | | UINT8 *RAM = machine.root_device().memregion(cputag)->base(); |
| 350 | UINT8 *RAM = machine().root_device().memregion(cputag)->base(); |
| 355 | 351 | |
| 356 | 352 | /* Read each byte, decrypt it */ |
| 357 | 353 | for (i = 0x00000; i < 0x10000; i++) |
| r20764 | r20765 | |
| 364 | 360 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x180000, 0x180fff, read16_delegate(FUNC(dec0_state::hippodrm_68000_share_r),this), write16_delegate(FUNC(dec0_state::hippodrm_68000_share_w),this)); |
| 365 | 361 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xffc800, 0xffcfff, write16_delegate(FUNC(dec0_state::sprite_mirror_w),this)); |
| 366 | 362 | |
| 367 | | h6280_decrypt(machine(), "sub"); |
| 363 | h6280_decrypt("sub"); |
| 368 | 364 | |
| 369 | 365 | /* The protection cpu has additional memory mapped protection! */ |
| 370 | 366 | RAM[0x189] = 0x60; /* RTS prot area */ |
| r20764 | r20765 | |
| 377 | 373 | { |
| 378 | 374 | UINT8 *RAM = machine().root_device().memregion("audiocpu")->base(); |
| 379 | 375 | |
| 380 | | h6280_decrypt(machine(), "audiocpu"); |
| 376 | h6280_decrypt("audiocpu"); |
| 381 | 377 | |
| 382 | 378 | /* Slyspy sound cpu has some protection */ |
| 383 | 379 | RAM[0xf2d] = 0xea; |
trunk/src/mame/video/dcheese.c
| r20764 | r20765 | |
| 136 | 136 | * |
| 137 | 137 | *************************************/ |
| 138 | 138 | |
| 139 | | static void do_clear( running_machine &machine ) |
| 139 | void dcheese_state::do_clear( ) |
| 140 | 140 | { |
| 141 | | dcheese_state *state = machine.driver_data<dcheese_state>(); |
| 142 | 141 | int y; |
| 143 | 142 | |
| 144 | 143 | /* clear the requested scanlines */ |
| 145 | | for (y = state->m_blitter_vidparam[0x2c/2]; y < state->m_blitter_vidparam[0x2a/2]; y++) |
| 146 | | memset(&state->m_dstbitmap->pix16(y % DSTBITMAP_HEIGHT), 0, DSTBITMAP_WIDTH * 2); |
| 144 | for (y = m_blitter_vidparam[0x2c/2]; y < m_blitter_vidparam[0x2a/2]; y++) |
| 145 | memset(&m_dstbitmap->pix16(y % DSTBITMAP_HEIGHT), 0, DSTBITMAP_WIDTH * 2); |
| 147 | 146 | |
| 148 | 147 | /* signal an IRQ when done (timing is just a guess) */ |
| 149 | | machine.scheduler().timer_set(machine.primary_screen->scan_period(), timer_expired_delegate(FUNC(dcheese_state::dcheese_signal_irq_callback),state), 1); |
| 148 | machine().scheduler().timer_set(machine().primary_screen->scan_period(), timer_expired_delegate(FUNC(dcheese_state::dcheese_signal_irq_callback),this), 1); |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | 151 | |
| 153 | | static void do_blit( running_machine &machine ) |
| 152 | void dcheese_state::do_blit( ) |
| 154 | 153 | { |
| 155 | | dcheese_state *state = machine.driver_data<dcheese_state>(); |
| 156 | | INT32 srcminx = state->m_blitter_xparam[0] << 12; |
| 157 | | INT32 srcmaxx = state->m_blitter_xparam[1] << 12; |
| 158 | | INT32 srcminy = state->m_blitter_yparam[0] << 12; |
| 159 | | INT32 srcmaxy = state->m_blitter_yparam[1] << 12; |
| 160 | | INT32 srcx = ((state->m_blitter_xparam[2] & 0x0fff) | ((state->m_blitter_xparam[3] & 0x0fff) << 12)) << 7; |
| 161 | | INT32 srcy = ((state->m_blitter_yparam[2] & 0x0fff) | ((state->m_blitter_yparam[3] & 0x0fff) << 12)) << 7; |
| 162 | | INT32 dxdx = (INT32)(((state->m_blitter_xparam[4] & 0x0fff) | ((state->m_blitter_xparam[5] & 0x0fff) << 12)) << 12) >> 12; |
| 163 | | INT32 dxdy = (INT32)(((state->m_blitter_xparam[6] & 0x0fff) | ((state->m_blitter_xparam[7] & 0x0fff) << 12)) << 12) >> 12; |
| 164 | | INT32 dydx = (INT32)(((state->m_blitter_yparam[4] & 0x0fff) | ((state->m_blitter_yparam[5] & 0x0fff) << 12)) << 12) >> 12; |
| 165 | | INT32 dydy = (INT32)(((state->m_blitter_yparam[6] & 0x0fff) | ((state->m_blitter_yparam[7] & 0x0fff) << 12)) << 12) >> 12; |
| 166 | | UINT8 *src = state->memregion("gfx1")->base(); |
| 167 | | UINT32 pagemask = (state->memregion("gfx1")->bytes() - 1) / 0x40000; |
| 168 | | int xstart = state->m_blitter_xparam[14]; |
| 169 | | int xend = state->m_blitter_xparam[15] + 1; |
| 170 | | int ystart = state->m_blitter_yparam[14]; |
| 171 | | int yend = state->m_blitter_yparam[15]; |
| 172 | | int color = (state->m_blitter_color[0] << 8) & 0xff00; |
| 173 | | int mask = (state->m_blitter_color[0] >> 8) & 0x00ff; |
| 154 | INT32 srcminx = m_blitter_xparam[0] << 12; |
| 155 | INT32 srcmaxx = m_blitter_xparam[1] << 12; |
| 156 | INT32 srcminy = m_blitter_yparam[0] << 12; |
| 157 | INT32 srcmaxy = m_blitter_yparam[1] << 12; |
| 158 | INT32 srcx = ((m_blitter_xparam[2] & 0x0fff) | ((m_blitter_xparam[3] & 0x0fff) << 12)) << 7; |
| 159 | INT32 srcy = ((m_blitter_yparam[2] & 0x0fff) | ((m_blitter_yparam[3] & 0x0fff) << 12)) << 7; |
| 160 | INT32 dxdx = (INT32)(((m_blitter_xparam[4] & 0x0fff) | ((m_blitter_xparam[5] & 0x0fff) << 12)) << 12) >> 12; |
| 161 | INT32 dxdy = (INT32)(((m_blitter_xparam[6] & 0x0fff) | ((m_blitter_xparam[7] & 0x0fff) << 12)) << 12) >> 12; |
| 162 | INT32 dydx = (INT32)(((m_blitter_yparam[4] & 0x0fff) | ((m_blitter_yparam[5] & 0x0fff) << 12)) << 12) >> 12; |
| 163 | INT32 dydy = (INT32)(((m_blitter_yparam[6] & 0x0fff) | ((m_blitter_yparam[7] & 0x0fff) << 12)) << 12) >> 12; |
| 164 | UINT8 *src = memregion("gfx1")->base(); |
| 165 | UINT32 pagemask = (memregion("gfx1")->bytes() - 1) / 0x40000; |
| 166 | int xstart = m_blitter_xparam[14]; |
| 167 | int xend = m_blitter_xparam[15] + 1; |
| 168 | int ystart = m_blitter_yparam[14]; |
| 169 | int yend = m_blitter_yparam[15]; |
| 170 | int color = (m_blitter_color[0] << 8) & 0xff00; |
| 171 | int mask = (m_blitter_color[0] >> 8) & 0x00ff; |
| 174 | 172 | int opaque = (dxdx | dxdy | dydx | dydy) == 0; /* bit of a hack for fredmem */ |
| 175 | 173 | int x, y; |
| 176 | 174 | |
| 177 | 175 | /* loop over target rows */ |
| 178 | 176 | for (y = ystart; y <= yend; y++) |
| 179 | 177 | { |
| 180 | | UINT16 *dst = &state->m_dstbitmap->pix16(y % DSTBITMAP_HEIGHT); |
| 178 | UINT16 *dst = &m_dstbitmap->pix16(y % DSTBITMAP_HEIGHT); |
| 181 | 179 | |
| 182 | 180 | /* loop over target columns */ |
| 183 | 181 | for (x = xstart; x <= xend; x++) |
| r20764 | r20765 | |
| 201 | 199 | } |
| 202 | 200 | |
| 203 | 201 | /* signal an IRQ when done (timing is just a guess) */ |
| 204 | | machine.scheduler().timer_set(machine.primary_screen->scan_period() / 2, timer_expired_delegate(FUNC(dcheese_state::dcheese_signal_irq_callback),state), 2); |
| 202 | machine().scheduler().timer_set(machine().primary_screen->scan_period() / 2, timer_expired_delegate(FUNC(dcheese_state::dcheese_signal_irq_callback),this), 2); |
| 205 | 203 | |
| 206 | 204 | /* these extra parameters are written but they are always zero, so I don't know what they do */ |
| 207 | | if (state->m_blitter_xparam[8] != 0 || state->m_blitter_xparam[9] != 0 || state->m_blitter_xparam[10] != 0 || state->m_blitter_xparam[11] != 0 || |
| 208 | | state->m_blitter_yparam[8] != 0 || state->m_blitter_yparam[9] != 0 || state->m_blitter_yparam[10] != 0 || state->m_blitter_yparam[11] != 0) |
| 205 | if (m_blitter_xparam[8] != 0 || m_blitter_xparam[9] != 0 || m_blitter_xparam[10] != 0 || m_blitter_xparam[11] != 0 || |
| 206 | m_blitter_yparam[8] != 0 || m_blitter_yparam[9] != 0 || m_blitter_yparam[10] != 0 || m_blitter_yparam[11] != 0) |
| 209 | 207 | { |
| 210 | | logerror("%s:blit! (%04X)\n", machine.describe_context(), state->m_blitter_color[0]); |
| 208 | logerror("%s:blit! (%04X)\n", machine().describe_context(), m_blitter_color[0]); |
| 211 | 209 | logerror(" %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X\n", |
| 212 | | state->m_blitter_xparam[0], state->m_blitter_xparam[1], state->m_blitter_xparam[2], state->m_blitter_xparam[3], |
| 213 | | state->m_blitter_xparam[4], state->m_blitter_xparam[5], state->m_blitter_xparam[6], state->m_blitter_xparam[7], |
| 214 | | state->m_blitter_xparam[8], state->m_blitter_xparam[9], state->m_blitter_xparam[10], state->m_blitter_xparam[11], |
| 215 | | state->m_blitter_xparam[12], state->m_blitter_xparam[13], state->m_blitter_xparam[14], state->m_blitter_xparam[15]); |
| 210 | m_blitter_xparam[0], m_blitter_xparam[1], m_blitter_xparam[2], m_blitter_xparam[3], |
| 211 | m_blitter_xparam[4], m_blitter_xparam[5], m_blitter_xparam[6], m_blitter_xparam[7], |
| 212 | m_blitter_xparam[8], m_blitter_xparam[9], m_blitter_xparam[10], m_blitter_xparam[11], |
| 213 | m_blitter_xparam[12], m_blitter_xparam[13], m_blitter_xparam[14], m_blitter_xparam[15]); |
| 216 | 214 | logerror(" %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X\n", |
| 217 | | state->m_blitter_yparam[0], state->m_blitter_yparam[1], state->m_blitter_yparam[2], state->m_blitter_yparam[3], |
| 218 | | state->m_blitter_yparam[4], state->m_blitter_yparam[5], state->m_blitter_yparam[6], state->m_blitter_yparam[7], |
| 219 | | state->m_blitter_yparam[8], state->m_blitter_yparam[9], state->m_blitter_yparam[10], state->m_blitter_yparam[11], |
| 220 | | state->m_blitter_yparam[12], state->m_blitter_yparam[13], state->m_blitter_yparam[14], state->m_blitter_yparam[15]); |
| 215 | m_blitter_yparam[0], m_blitter_yparam[1], m_blitter_yparam[2], m_blitter_yparam[3], |
| 216 | m_blitter_yparam[4], m_blitter_yparam[5], m_blitter_yparam[6], m_blitter_yparam[7], |
| 217 | m_blitter_yparam[8], m_blitter_yparam[9], m_blitter_yparam[10], m_blitter_yparam[11], |
| 218 | m_blitter_yparam[12], m_blitter_yparam[13], m_blitter_yparam[14], m_blitter_yparam[15]); |
| 221 | 219 | } |
| 222 | 220 | } |
| 223 | 221 | |
| r20764 | r20765 | |
| 277 | 275 | break; |
| 278 | 276 | |
| 279 | 277 | case 0x38/2: /* blit */ |
| 280 | | do_blit(machine()); |
| 278 | do_blit(); |
| 281 | 279 | break; |
| 282 | 280 | |
| 283 | 281 | case 0x3e/2: /* clear */ |
| 284 | | do_clear(machine()); |
| 282 | do_clear(); |
| 285 | 283 | break; |
| 286 | 284 | |
| 287 | 285 | default: |
trunk/src/mame/video/dooyong.c
| r20764 | r20765 | |
| 2 | 2 | #include "includes/dooyong.h" |
| 3 | 3 | |
| 4 | 4 | |
| 5 | | INLINE void dooyong_scroll8_w(offs_t offset, UINT8 data, UINT8 *scroll, tilemap_t *map) |
| 5 | inline void dooyong_state::dooyong_scroll8_w(offs_t offset, UINT8 data, UINT8 *scroll, tilemap_t *map) |
| 6 | 6 | { |
| 7 | 7 | UINT8 old = scroll[offset]; |
| 8 | 8 | if (old != data) |
| r20764 | r20765 | |
| 30 | 30 | /* 0x02 is initialised on startup by some games and written to continuously by others */ |
| 31 | 31 | /*{ |
| 32 | 32 | const char *name; |
| 33 | | if (scroll == state->m_bgscroll8) name = "bg"; |
| 34 | | else if (scroll == state->m_bg2scroll8) name = "bg2"; |
| 35 | | else if (scroll == state->m_fgscroll8) name = "fg"; |
| 36 | | else if (scroll == state->m_fg2scroll8) name = "fg2"; |
| 33 | if (scroll == m_bgscroll8) name = "bg"; |
| 34 | else if (scroll == m_bg2scroll8) name = "bg2"; |
| 35 | else if (scroll == m_fgscroll8) name = "fg"; |
| 36 | else if (scroll == m_fg2scroll8) name = "fg2"; |
| 37 | 37 | else name = "unknown"; |
| 38 | 38 | printf("Unknown %s tilemap control: 0x%02x = 0x%02x\n", name, (unsigned)offset, (unsigned)data); |
| 39 | 39 | }*/ |
| r20764 | r20765 | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | |
| 337 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pollux_extensions) |
| 337 | void dooyong_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pollux_extensions) |
| 338 | 338 | { |
| 339 | 339 | /* Sprites take 32 bytes each in memory: |
| 340 | 340 | MSB LSB |
| r20764 | r20765 | |
| 359 | 359 | height only used by pollux, bluehawk and flytiger |
| 360 | 360 | x flip and y flip only used by pollux and flytiger */ |
| 361 | 361 | |
| 362 | | dooyong_state *state = machine.driver_data<dooyong_state>(); |
| 363 | | UINT8 *buffered_spriteram = state->m_spriteram->buffer(); |
| 362 | UINT8 *buffered_spriteram = m_spriteram->buffer(); |
| 364 | 363 | int offs; |
| 365 | 364 | |
| 366 | | for (offs = 0; offs < state->m_spriteram->bytes(); offs += 32) |
| 365 | for (offs = 0; offs < m_spriteram->bytes(); offs += 32) |
| 367 | 366 | { |
| 368 | 367 | int sx, sy, code, color, pri; |
| 369 | 368 | int flipx = 0, flipy = 0, height = 0, y; |
| r20764 | r20765 | |
| 404 | 403 | } |
| 405 | 404 | } |
| 406 | 405 | |
| 407 | | if (state->flip_screen()) |
| 406 | if (flip_screen()) |
| 408 | 407 | { |
| 409 | 408 | sx = 498 - sx; |
| 410 | 409 | sy = 240 - (16 * height) - sy; |
| r20764 | r20765 | |
| 414 | 413 | |
| 415 | 414 | for (y = 0; y <= height; y++) |
| 416 | 415 | { |
| 417 | | pdrawgfx_transpen(bitmap, cliprect, machine.gfx[1], |
| 416 | pdrawgfx_transpen(bitmap, cliprect, machine().gfx[1], |
| 418 | 417 | code + y, |
| 419 | 418 | color, |
| 420 | 419 | flipx, flipy, |
| 421 | 420 | sx, sy + (16 * (flipy ? (height - y) : y)), |
| 422 | | machine.priority_bitmap, |
| 421 | machine().priority_bitmap, |
| 423 | 422 | pri, 15); |
| 424 | 423 | } |
| 425 | 424 | } |
| 426 | 425 | } |
| 427 | 426 | |
| 428 | | static void rshark_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 427 | void dooyong_state::rshark_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 429 | 428 | { |
| 430 | | dooyong_state *state = machine.driver_data<dooyong_state>(); |
| 431 | | UINT16 *buffered_spriteram16 = state->m_spriteram16->buffer(); |
| 429 | UINT16 *buffered_spriteram16 = m_spriteram16->buffer(); |
| 432 | 430 | |
| 433 | 431 | /* Sprites take 8 16-bit words each in memory: |
| 434 | 432 | MSB LSB |
| r20764 | r20765 | |
| 451 | 449 | |
| 452 | 450 | int offs; |
| 453 | 451 | |
| 454 | | for (offs = (state->m_spriteram16->bytes() / 2) - 8; offs >= 0; offs -= 8) |
| 452 | for (offs = (m_spriteram16->bytes() / 2) - 8; offs >= 0; offs -= 8) |
| 455 | 453 | { |
| 456 | 454 | if (buffered_spriteram16[offs] & 0x0001) /* enable */ |
| 457 | 455 | { |
| r20764 | r20765 | |
| 469 | 467 | width = buffered_spriteram16[offs+1] & 0x000f; |
| 470 | 468 | height = (buffered_spriteram16[offs+1] & 0x00f0) >> 4; |
| 471 | 469 | |
| 472 | | if (state->flip_screen()) |
| 470 | if (flip_screen()) |
| 473 | 471 | { |
| 474 | 472 | sx = 498 - (16 * width) - sx; |
| 475 | 473 | sy = 240 - (16 * height) - sy; |
| r20764 | r20765 | |
| 483 | 481 | for (x = 0; x <= width; x++) |
| 484 | 482 | { |
| 485 | 483 | int _x = sx + (16 * (flipx ? (width - x) : x)); |
| 486 | | pdrawgfx_transpen(bitmap, cliprect, machine.gfx[0], |
| 484 | pdrawgfx_transpen(bitmap, cliprect, machine().gfx[0], |
| 487 | 485 | code, |
| 488 | 486 | color, |
| 489 | 487 | flipx, flipy, |
| 490 | 488 | _x, _y, |
| 491 | | machine.priority_bitmap, |
| 489 | machine().priority_bitmap, |
| 492 | 490 | pri, 15); |
| 493 | 491 | code++; |
| 494 | 492 | } |
| r20764 | r20765 | |
| 508 | 506 | m_tx_tilemap->draw(bitmap, cliprect, 0, 4); |
| 509 | 507 | |
| 510 | 508 | if (!m_sprites_disabled) |
| 511 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 509 | draw_sprites(bitmap, cliprect, 0); |
| 512 | 510 | return 0; |
| 513 | 511 | } |
| 514 | 512 | |
| r20764 | r20765 | |
| 521 | 519 | m_fg_tilemap->draw(bitmap, cliprect, 0, 2); |
| 522 | 520 | m_tx_tilemap->draw(bitmap, cliprect, 0, 4); |
| 523 | 521 | |
| 524 | | draw_sprites(machine(), bitmap, cliprect, 1); |
| 522 | draw_sprites(bitmap, cliprect, 1); |
| 525 | 523 | return 0; |
| 526 | 524 | } |
| 527 | 525 | |
| r20764 | r20765 | |
| 534 | 532 | m_fg_tilemap->draw(bitmap, cliprect, 0, 2); |
| 535 | 533 | m_tx_tilemap->draw(bitmap, cliprect, 0, 4); |
| 536 | 534 | |
| 537 | | draw_sprites(machine(), bitmap, cliprect, 2); |
| 535 | draw_sprites(bitmap, cliprect, 2); |
| 538 | 536 | return 0; |
| 539 | 537 | } |
| 540 | 538 | |
| r20764 | r20765 | |
| 555 | 553 | } |
| 556 | 554 | m_tx_tilemap->draw(bitmap, cliprect, 0, 4); |
| 557 | 555 | |
| 558 | | draw_sprites(machine(), bitmap, cliprect, 4); |
| 556 | draw_sprites(bitmap, cliprect, 4); |
| 559 | 557 | return 0; |
| 560 | 558 | } |
| 561 | 559 | |
| r20764 | r20765 | |
| 570 | 568 | m_fg2_tilemap->draw(bitmap, cliprect, 0, 4); |
| 571 | 569 | m_tx_tilemap->draw(bitmap, cliprect, 0, 4); |
| 572 | 570 | |
| 573 | | draw_sprites(machine(), bitmap, cliprect, 3); |
| 571 | draw_sprites(bitmap, cliprect, 3); |
| 574 | 572 | return 0; |
| 575 | 573 | } |
| 576 | 574 | |
| r20764 | r20765 | |
| 595 | 593 | m_fg_tilemap->draw(bitmap, cliprect, 0, 2); |
| 596 | 594 | m_fg2_tilemap->draw(bitmap, cliprect, 0, 2); |
| 597 | 595 | |
| 598 | | rshark_draw_sprites(machine(), bitmap, cliprect); |
| 596 | rshark_draw_sprites(bitmap, cliprect); |
| 599 | 597 | return 0; |
| 600 | 598 | } |
| 601 | 599 | |
| r20764 | r20765 | |
| 606 | 604 | |
| 607 | 605 | m_bg_tilemap->draw(bitmap, cliprect, 0, 1); |
| 608 | 606 | |
| 609 | | rshark_draw_sprites(machine(), bitmap, cliprect); |
| 607 | rshark_draw_sprites(bitmap, cliprect); |
| 610 | 608 | return 0; |
| 611 | 609 | } |
| 612 | 610 | |
trunk/src/mame/video/dynduke.c
| r20764 | r20765 | |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri) |
| 129 | void dynduke_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri) |
| 130 | 130 | { |
| 131 | | dynduke_state *state = machine.driver_data<dynduke_state>(); |
| 132 | | UINT16 *buffered_spriteram16 = state->m_spriteram->buffer(); |
| 131 | UINT16 *buffered_spriteram16 = m_spriteram->buffer(); |
| 133 | 132 | int offs,fx,fy,x,y,color,sprite; |
| 134 | 133 | |
| 135 | | if (!state->m_sprite_enable) return; |
| 134 | if (!m_sprite_enable) return; |
| 136 | 135 | |
| 137 | 136 | for (offs = 0x800-4;offs >= 0;offs -= 4) |
| 138 | 137 | { |
| r20764 | r20765 | |
| 151 | 150 | sprite = buffered_spriteram16[offs+1]; |
| 152 | 151 | sprite &= 0x3fff; |
| 153 | 152 | |
| 154 | | if (state->flip_screen()) { |
| 153 | if (flip_screen()) { |
| 155 | 154 | x=240-x; |
| 156 | 155 | y=240-y; |
| 157 | 156 | if (fx) fx=0; else fx=1; |
| 158 | 157 | if (fy) fy=0; else fy=1; |
| 159 | 158 | } |
| 160 | 159 | |
| 161 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[3], |
| 160 | drawgfx_transpen(bitmap,cliprect,machine().gfx[3], |
| 162 | 161 | sprite, |
| 163 | 162 | color,fx,fy,x,y,15); |
| 164 | 163 | } |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | | static void draw_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri ) |
| 166 | void dynduke_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri ) |
| 168 | 167 | { |
| 169 | | dynduke_state *state = machine.driver_data<dynduke_state>(); |
| 170 | 168 | /* The transparency / palette handling on the background layer is very strange */ |
| 171 | | bitmap_ind16 &bm = state->m_bg_layer->pixmap(); |
| 169 | bitmap_ind16 &bm = m_bg_layer->pixmap(); |
| 172 | 170 | int scrolly, scrollx; |
| 173 | 171 | int x,y; |
| 174 | 172 | |
| 175 | 173 | /* if we're disabled, don't draw */ |
| 176 | | if (!state->m_back_enable) |
| 174 | if (!m_back_enable) |
| 177 | 175 | { |
| 178 | | bitmap.fill(get_black_pen(machine), cliprect); |
| 176 | bitmap.fill(get_black_pen(machine()), cliprect); |
| 179 | 177 | return; |
| 180 | 178 | } |
| 181 | 179 | |
| 182 | | scrolly = ((state->m_scroll_ram[0x01]&0x30)<<4)+((state->m_scroll_ram[0x02]&0x7f)<<1)+((state->m_scroll_ram[0x02]&0x80)>>7); |
| 183 | | scrollx = ((state->m_scroll_ram[0x09]&0x30)<<4)+((state->m_scroll_ram[0x0a]&0x7f)<<1)+((state->m_scroll_ram[0x0a]&0x80)>>7); |
| 180 | scrolly = ((m_scroll_ram[0x01]&0x30)<<4)+((m_scroll_ram[0x02]&0x7f)<<1)+((m_scroll_ram[0x02]&0x80)>>7); |
| 181 | scrollx = ((m_scroll_ram[0x09]&0x30)<<4)+((m_scroll_ram[0x0a]&0x7f)<<1)+((m_scroll_ram[0x0a]&0x80)>>7); |
| 184 | 182 | |
| 185 | 183 | for (y=0;y<256;y++) |
| 186 | 184 | { |
| r20764 | r20765 | |
| 206 | 204 | if ((srcdat & 0x20) == pri) |
| 207 | 205 | { |
| 208 | 206 | if (srcdat & 0x10) srcdat += 0x400; |
| 209 | | //if (srcdat & 0x10) srcdat += machine.rand()&0x1f; |
| 207 | //if (srcdat & 0x10) srcdat += machine().rand()&0x1f; |
| 210 | 208 | |
| 211 | 209 | srcdat = (srcdat & 0x000f) | ((srcdat & 0xffc0) >> 2); |
| 212 | 210 | dst[x] = srcdat; |
| r20764 | r20765 | |
| 226 | 224 | m_tx_layer->enable(m_txt_enable); |
| 227 | 225 | |
| 228 | 226 | |
| 229 | | draw_background(machine(), bitmap, cliprect,0x00); |
| 230 | | draw_sprites(machine(),bitmap,cliprect,0); // Untested: does anything use it? Could be behind background |
| 231 | | draw_sprites(machine(),bitmap,cliprect,1); |
| 232 | | draw_background(machine(), bitmap, cliprect,0x20); |
| 227 | draw_background(bitmap, cliprect,0x00); |
| 228 | draw_sprites(bitmap,cliprect,0); // Untested: does anything use it? Could be behind background |
| 229 | draw_sprites(bitmap,cliprect,1); |
| 230 | draw_background(bitmap, cliprect,0x20); |
| 233 | 231 | |
| 234 | | draw_sprites(machine(),bitmap,cliprect,2); |
| 232 | draw_sprites(bitmap,cliprect,2); |
| 235 | 233 | m_fg_layer->draw(bitmap, cliprect, 0,0); |
| 236 | | draw_sprites(machine(),bitmap,cliprect,3); |
| 234 | draw_sprites(bitmap,cliprect,3); |
| 237 | 235 | m_tx_layer->draw(bitmap, cliprect, 0,0); |
| 238 | 236 | |
| 239 | 237 | return 0; |
trunk/src/mame/video/dkong.c
| r20764 | r20765 | |
| 543 | 543 | |
| 544 | 544 | ***************************************************************************/ |
| 545 | 545 | |
| 546 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 mask_bank, UINT32 shift_bits) |
| 546 | void dkong_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 mask_bank, UINT32 shift_bits) |
| 547 | 547 | { |
| 548 | | dkong_state *state = machine.driver_data<dkong_state>(); |
| 549 | 548 | int offs; |
| 550 | 549 | int scanline_vf; /* buffering scanline including flip */ |
| 551 | 550 | int scanline_vfc; /* line buffering scanline including flip - this is the cached scanline_vf */ |
| r20764 | r20765 | |
| 595 | 594 | scanline_vfc = (cliprect.max_y - 1) & 0xFF; |
| 596 | 595 | scanline = cliprect.max_y & 0xFF; |
| 597 | 596 | |
| 598 | | if (state->m_flip) |
| 597 | if (m_flip) |
| 599 | 598 | { |
| 600 | 599 | scanline_vf ^= 0xFF; |
| 601 | 600 | scanline_vfc ^= 0xFF; |
| r20764 | r20765 | |
| 608 | 607 | add_x = 0xF7; |
| 609 | 608 | } |
| 610 | 609 | |
| 611 | | for (offs = state->m_sprite_bank<<9, num_sprt=0; (num_sprt < 16) && (offs < (state->m_sprite_bank<<9) + 0x200) /* sprite_ram_size */; offs += 4) |
| 610 | for (offs = m_sprite_bank<<9, num_sprt=0; (num_sprt < 16) && (offs < (m_sprite_bank<<9) + 0x200) /* sprite_ram_size */; offs += 4) |
| 612 | 611 | { |
| 613 | | int y = state->m_sprite_ram[offs]; |
| 612 | int y = m_sprite_ram[offs]; |
| 614 | 613 | int do_draw = (((y + add_y + 1 + scanline_vf) & 0xF0) == 0xF0) ? 1 : 0; |
| 615 | 614 | |
| 616 | 615 | if (do_draw) |
| r20764 | r20765 | |
| 621 | 620 | /* has similar hardware, uses a memory mapped port to change */ |
| 622 | 621 | /* palette bank, so it's limited to 16 color codes) */ |
| 623 | 622 | |
| 624 | | int code = (state->m_sprite_ram[offs + 1] & 0x7f) + ((state->m_sprite_ram[offs + 2] & mask_bank) << shift_bits); |
| 625 | | int color = (state->m_sprite_ram[offs + 2] & 0x0f) + 16 * state->m_palette_bank; |
| 626 | | int flipx = state->m_sprite_ram[offs + 2] & 0x80; |
| 627 | | int flipy = state->m_sprite_ram[offs + 1] & 0x80; |
| 623 | int code = (m_sprite_ram[offs + 1] & 0x7f) + ((m_sprite_ram[offs + 2] & mask_bank) << shift_bits); |
| 624 | int color = (m_sprite_ram[offs + 2] & 0x0f) + 16 * m_palette_bank; |
| 625 | int flipx = m_sprite_ram[offs + 2] & 0x80; |
| 626 | int flipy = m_sprite_ram[offs + 1] & 0x80; |
| 628 | 627 | |
| 629 | 628 | /* On the real board, the x and y are read inverted after the first |
| 630 | 629 | * buffer stage. This due to the fact that the 82S09 delivers complements |
| 631 | 630 | * of stored data on read! |
| 632 | 631 | */ |
| 633 | 632 | |
| 634 | | int x = (state->m_sprite_ram[offs + 3] + add_x + 1) & 0xFF; |
| 635 | | if (state->m_flip) |
| 633 | int x = (m_sprite_ram[offs + 3] + add_x + 1) & 0xFF; |
| 634 | if (m_flip) |
| 636 | 635 | { |
| 637 | 636 | x = (x ^ 0xFF) - 15; |
| 638 | 637 | flipx = !flipx; |
| 639 | 638 | } |
| 640 | 639 | y = scanline - ((y + add_y + 1 + scanline_vfc) & 0x0F); |
| 641 | 640 | |
| 642 | | drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, x, y, 0); |
| 641 | drawgfx_transpen(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, x, y, 0); |
| 643 | 642 | |
| 644 | 643 | // wraparound |
| 645 | | drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, state->m_flip ? x + 256 : x - 256, y, 0); |
| 646 | | drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, x, y - 256, 0); |
| 644 | drawgfx_transpen(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, m_flip ? x + 256 : x - 256, y, 0); |
| 645 | drawgfx_transpen(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, x, y - 256, 0); |
| 647 | 646 | |
| 648 | 647 | num_sprt++; |
| 649 | 648 | } |
| r20764 | r20765 | |
| 668 | 667 | * TODO: This should be part of the vblank routine |
| 669 | 668 | */ |
| 670 | 669 | |
| 671 | | INLINE double CD4049(running_machine &machine, double x) |
| 670 | inline double dkong_state::CD4049(double x) |
| 672 | 671 | { |
| 673 | | dkong_state *state = machine.driver_data<dkong_state>(); |
| 674 | 672 | |
| 675 | 673 | if (x>0) |
| 676 | | return exp(-state->m_cd4049_a * pow(x,state->m_cd4049_b)); |
| 674 | return exp(-m_cd4049_a * pow(x,m_cd4049_b)); |
| 677 | 675 | else |
| 678 | 676 | return 1.0; |
| 679 | 677 | } |
| r20764 | r20765 | |
| 690 | 688 | #define dt (1./60./(double) VTOTAL) |
| 691 | 689 | #define period2 (((INT64)(PIXEL_CLOCK) * ( 33L * 68L )) / (INT32)10000000L / 3) /* period/2 in pixel ... */ |
| 692 | 690 | |
| 693 | | static void radarscp_step(running_machine &machine, int line_cnt) |
| 691 | void dkong_state::radarscp_step(int line_cnt) |
| 694 | 692 | { |
| 695 | | dkong_state *state = machine.driver_data<dkong_state>(); |
| 696 | 693 | |
| 697 | 694 | /* Condensator is illegible in schematics for TRS2 board. |
| 698 | 695 | * TRS1 board states 3.3u. |
| r20764 | r20765 | |
| 709 | 706 | |
| 710 | 707 | if ( line_cnt == 0) |
| 711 | 708 | { |
| 712 | | state->m_sig30Hz = (1-state->m_sig30Hz); |
| 713 | | if (state->m_sig30Hz) |
| 714 | | state->m_lfsr_5I = (machine.rand() > RAND_MAX/2); |
| 709 | m_sig30Hz = (1-m_sig30Hz); |
| 710 | if (m_sig30Hz) |
| 711 | m_lfsr_5I = (machine().rand() > RAND_MAX/2); |
| 715 | 712 | } |
| 716 | 713 | |
| 717 | 714 | /* sound2 mixes in a 30Hz noise signal. |
| r20764 | r20765 | |
| 720 | 717 | */ |
| 721 | 718 | |
| 722 | 719 | /* Now mix with SND02 (sound 2) line - on 74ls259, bit2 */ |
| 723 | | address_space &space = machine.driver_data()->generic_space(); |
| 724 | | state->m_rflip_sig = latch8_bit2_r(state->m_dev_6h, space, 0) & state->m_lfsr_5I; |
| 720 | address_space &space = machine().driver_data()->generic_space(); |
| 721 | m_rflip_sig = latch8_bit2_r(m_dev_6h, space, 0) & m_lfsr_5I; |
| 725 | 722 | |
| 726 | 723 | /* blue background generation */ |
| 727 | 724 | |
| r20764 | r20765 | |
| 729 | 726 | if (line_cnt>511) |
| 730 | 727 | line_cnt -= VTOTAL; |
| 731 | 728 | |
| 732 | | sig = state->m_rflip_sig ^ ((line_cnt & 0x80)>>7); |
| 729 | sig = m_rflip_sig ^ ((line_cnt & 0x80)>>7); |
| 733 | 730 | |
| 734 | | if (state->m_hardware_type == HARDWARE_TRS01) |
| 735 | | state->m_rflip_sig = !state->m_rflip_sig; |
| 731 | if (m_hardware_type == HARDWARE_TRS01) |
| 732 | m_rflip_sig = !m_rflip_sig; |
| 736 | 733 | |
| 737 | 734 | if (sig) /* 128VF */ |
| 738 | | diff = (0.0 - state->m_cv1); |
| 735 | diff = (0.0 - m_cv1); |
| 739 | 736 | else |
| 740 | | diff = (4.8 - state->m_cv1); |
| 737 | diff = (4.8 - m_cv1); |
| 741 | 738 | diff = diff - diff*exp(0.0 - (1.0/RC1 * dt) ); |
| 742 | | state->m_cv1 += diff; |
| 739 | m_cv1 += diff; |
| 743 | 740 | |
| 744 | | diff = (state->m_cv1 - state->m_cv2 - state->m_vg1); |
| 741 | diff = (m_cv1 - m_cv2 - m_vg1); |
| 745 | 742 | diff = diff - diff*exp(0.0 - (1.0/RC2 * dt) ); |
| 746 | | state->m_cv2 += diff; |
| 743 | m_cv2 += diff; |
| 747 | 744 | |
| 748 | 745 | // FIXME: use the inverse function |
| 749 | 746 | // Solve the amplifier by iteration |
| 750 | 747 | for (int j=1; j<=11; j++)// 11% = 1/75 / (1/75+1/10) |
| 751 | 748 | { |
| 752 | 749 | double f = (double) j / 100.0f; |
| 753 | | state->m_vg1 = (state->m_cv1 - state->m_cv2)*(1-f) + f * state->m_vg2; |
| 754 | | state->m_vg2 = 5*CD4049(machine, state->m_vg1/5); |
| 750 | m_vg1 = (m_cv1 - m_cv2)*(1-f) + f * m_vg2; |
| 751 | m_vg2 = 5*CD4049(m_vg1/5); |
| 755 | 752 | } |
| 756 | 753 | // FIXME: use the inverse function |
| 757 | 754 | // Solve the amplifier by iteration 50% = both resistors equal |
| 758 | 755 | for (int j=10; j<=20; j++) |
| 759 | 756 | { |
| 760 | 757 | double f = (double) j / 40.0f; |
| 761 | | vg3i = (1.0f-f) * state->m_vg2 + f * state->m_vg3; |
| 762 | | state->m_vg3 = 5*CD4049(machine, vg3i/5); |
| 758 | vg3i = (1.0f-f) * m_vg2 + f * m_vg3; |
| 759 | m_vg3 = 5*CD4049(vg3i/5); |
| 763 | 760 | } |
| 764 | 761 | |
| 765 | 762 | #define RC17 (33e-6 * 1e3 * (0*4.7+1.0/(1.0/10.0+1.0/20.0+0.0/0.3))) |
| 766 | | diff = (state->m_vg3 - state->m_vc17); |
| 763 | diff = (m_vg3 - m_vc17); |
| 767 | 764 | diff = diff - diff*exp(0.0 - (1.0/RC17 * dt) ); |
| 768 | | state->m_vc17 += diff; |
| 765 | m_vc17 += diff; |
| 769 | 766 | |
| 770 | | double vo = (state->m_vg3 - state->m_vc17); |
| 767 | double vo = (m_vg3 - m_vc17); |
| 771 | 768 | vo = vo + 20.0 / (20.0+10.0) * 5; |
| 772 | 769 | |
| 773 | 770 | // Transistor is marked as OMIT in TRS-02 schems. |
| r20764 | r20765 | |
| 778 | 775 | //vo = vo / (1.0 / 4.7 + 1.0 / 16.0 + 1.0 / 30.0 ); |
| 779 | 776 | //printf("%f %f\n", vg3, vc17); |
| 780 | 777 | |
| 781 | | state->m_blue_level = (int)(vo/5.0*255); |
| 782 | | //printf("%d\n", state->m_blue_level); |
| 778 | m_blue_level = (int)(vo/5.0*255); |
| 779 | //printf("%d\n", m_blue_level); |
| 783 | 780 | |
| 784 | 781 | /* |
| 785 | 782 | * Grid signal |
| 786 | 783 | * |
| 787 | 784 | * Mixed with ANS line (bit 5) from Port B of 8039 |
| 788 | 785 | */ |
| 789 | | if (state->m_grid_on && latch8_bit5_r(state->m_dev_vp2, space, 0)) |
| 786 | if (m_grid_on && latch8_bit5_r(m_dev_vp2, space, 0)) |
| 790 | 787 | { |
| 791 | | diff = (0.0 - state->m_cv3); |
| 788 | diff = (0.0 - m_cv3); |
| 792 | 789 | diff = diff - diff*exp(0.0 - (1.0/RC32 * dt) ); |
| 793 | 790 | } |
| 794 | 791 | else |
| 795 | 792 | { |
| 796 | | diff = (5.0 - state->m_cv3); |
| 793 | diff = (5.0 - m_cv3); |
| 797 | 794 | diff = diff - diff*exp(0.0 - (1.0/RC31 * dt) ); |
| 798 | 795 | } |
| 799 | | state->m_cv3 += diff; |
| 796 | m_cv3 += diff; |
| 800 | 797 | |
| 801 | | diff = (state->m_vg2 - 0.8 * state->m_cv3 - state->m_cv4); |
| 798 | diff = (m_vg2 - 0.8 * m_cv3 - m_cv4); |
| 802 | 799 | diff = diff - diff*exp(0.0 - (1.0/RC4 * dt) ); |
| 803 | | state->m_cv4 += diff; |
| 800 | m_cv4 += diff; |
| 804 | 801 | |
| 805 | | if (CD4049(machine, CD4049(machine, (state->m_vg2 - state->m_cv4)/5.0))>2.4/5.0) /* TTL - Level */ |
| 806 | | state->m_grid_sig = 0; |
| 802 | if (CD4049(CD4049((m_vg2 - m_cv4)/5.0))>2.4/5.0) /* TTL - Level */ |
| 803 | m_grid_sig = 0; |
| 807 | 804 | else |
| 808 | | state->m_grid_sig = 1; |
| 805 | m_grid_sig = 1; |
| 809 | 806 | |
| 810 | 807 | /* stars */ |
| 811 | | state->m_pixelcnt += HTOTAL; |
| 812 | | if (state->m_pixelcnt > period2 ) |
| 808 | m_pixelcnt += HTOTAL; |
| 809 | if (m_pixelcnt > period2 ) |
| 813 | 810 | { |
| 814 | | state->m_star_ff = !state->m_star_ff; |
| 815 | | state->m_pixelcnt = state->m_pixelcnt - period2; |
| 811 | m_star_ff = !m_star_ff; |
| 812 | m_pixelcnt = m_pixelcnt - period2; |
| 816 | 813 | } |
| 817 | 814 | |
| 818 | 815 | } |
| 819 | 816 | |
| 820 | | static void radarscp_draw_background(running_machine &machine, dkong_state *state, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 817 | void dkong_state::radarscp_draw_background(dkong_state *state, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 821 | 818 | { |
| 822 | 819 | const UINT8 *htable = NULL; |
| 823 | 820 | int x,y; |
| 824 | 821 | UINT8 draw_ok; |
| 825 | 822 | UINT16 *pixel; |
| 826 | 823 | |
| 827 | | if (state->m_hardware_type == HARDWARE_TRS01) |
| 828 | | htable = state->m_gfx4; |
| 824 | if (m_hardware_type == HARDWARE_TRS01) |
| 825 | htable = m_gfx4; |
| 829 | 826 | |
| 830 | 827 | y = cliprect.min_y; |
| 831 | 828 | while (y <= cliprect.max_y) |
| r20764 | r20765 | |
| 835 | 832 | { |
| 836 | 833 | pixel = &bitmap.pix16(y, x); |
| 837 | 834 | draw_ok = !(*pixel & 0x01) && !(*pixel & 0x02); |
| 838 | | if (state->m_hardware_type == HARDWARE_TRS01) /* Check again from schematics */ |
| 839 | | draw_ok = draw_ok && !((htable[ (!state->m_rflip_sig<<7) | (x>>2)] >>2) & 0x01); |
| 835 | if (m_hardware_type == HARDWARE_TRS01) /* Check again from schematics */ |
| 836 | draw_ok = draw_ok && !((htable[ (!m_rflip_sig<<7) | (x>>2)] >>2) & 0x01); |
| 840 | 837 | if (draw_ok) |
| 841 | | *pixel = *(&state->m_bg_bits.pix16(y, x)); |
| 838 | *pixel = *(&m_bg_bits.pix16(y, x)); |
| 842 | 839 | x++; |
| 843 | 840 | } |
| 844 | 841 | y++; |
| 845 | 842 | } |
| 846 | 843 | } |
| 847 | 844 | |
| 848 | | static void radarscp_scanline(running_machine &machine, int scanline) |
| 845 | void dkong_state::radarscp_scanline(int scanline) |
| 849 | 846 | { |
| 850 | | dkong_state *state = machine.driver_data<dkong_state>(); |
| 851 | | const UINT8 *table = state->m_gfx3; |
| 852 | | int table_len = state->m_gfx3_len; |
| 847 | const UINT8 *table = m_gfx3; |
| 848 | int table_len = m_gfx3_len; |
| 853 | 849 | int x,y,offset; |
| 854 | 850 | UINT16 *pixel; |
| 855 | | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 851 | const rectangle &visarea = machine().primary_screen->visible_area(); |
| 856 | 852 | |
| 857 | 853 | y = scanline; |
| 858 | | radarscp_step(machine, y); |
| 854 | radarscp_step(y); |
| 859 | 855 | if (y <= visarea.min_y || y > visarea.max_y) |
| 860 | | state->m_counter = 0; |
| 861 | | offset = (state->m_flip ^ state->m_rflip_sig) ? 0x000 : 0x400; |
| 856 | m_counter = 0; |
| 857 | offset = (m_flip ^ m_rflip_sig) ? 0x000 : 0x400; |
| 862 | 858 | x = 0; |
| 863 | | while (x < machine.primary_screen->width()) |
| 859 | while (x < machine().primary_screen->width()) |
| 864 | 860 | { |
| 865 | | pixel = &state->m_bg_bits.pix16(y, x); |
| 866 | | if ((state->m_counter < table_len) && (x == 4 * (table[state->m_counter|offset] & 0x7f))) |
| 861 | pixel = &m_bg_bits.pix16(y, x); |
| 862 | if ((m_counter < table_len) && (x == 4 * (table[m_counter|offset] & 0x7f))) |
| 867 | 863 | { |
| 868 | | if ( state->m_star_ff && (table[state->m_counter|offset] & 0x80) ) /* star */ |
| 864 | if ( m_star_ff && (table[m_counter|offset] & 0x80) ) /* star */ |
| 869 | 865 | *pixel = RADARSCP_STAR_COL; |
| 870 | | else if (state->m_grid_sig && !(table[state->m_counter|offset] & 0x80)) /* radar */ |
| 871 | | *pixel = RADARSCP_GRID_COL_OFFSET+state->m_grid_col; |
| 866 | else if (m_grid_sig && !(table[m_counter|offset] & 0x80)) /* radar */ |
| 867 | *pixel = RADARSCP_GRID_COL_OFFSET+m_grid_col; |
| 872 | 868 | else |
| 873 | | *pixel = RADARSCP_BCK_COL_OFFSET + state->m_blue_level; |
| 874 | | state->m_counter++; |
| 869 | *pixel = RADARSCP_BCK_COL_OFFSET + m_blue_level; |
| 870 | m_counter++; |
| 875 | 871 | } |
| 876 | 872 | else |
| 877 | | *pixel = RADARSCP_BCK_COL_OFFSET + state->m_blue_level; |
| 873 | *pixel = RADARSCP_BCK_COL_OFFSET + m_blue_level; |
| 878 | 874 | x++; |
| 879 | 875 | } |
| 880 | | while ((state->m_counter < table_len) && ( x < 4 * (table[state->m_counter|offset] & 0x7f))) |
| 881 | | state->m_counter++; |
| 876 | while ((m_counter < table_len) && ( x < 4 * (table[m_counter|offset] & 0x7f))) |
| 877 | m_counter++; |
| 882 | 878 | } |
| 883 | 879 | |
| 884 | 880 | TIMER_CALLBACK_MEMBER(dkong_state::scanline_callback) |
| r20764 | r20765 | |
| 886 | 882 | int scanline = param; |
| 887 | 883 | |
| 888 | 884 | if ((m_hardware_type == HARDWARE_TRS02) || (m_hardware_type == HARDWARE_TRS01)) |
| 889 | | radarscp_scanline(machine(), scanline); |
| 885 | radarscp_scanline(scanline); |
| 890 | 886 | |
| 891 | 887 | /* update any video up to the current scanline */ |
| 892 | 888 | machine().primary_screen->update_now(); |
| r20764 | r20765 | |
| 896 | 892 | m_scanline_timer->adjust(machine().primary_screen->time_until_pos(scanline), scanline); |
| 897 | 893 | } |
| 898 | 894 | |
| 899 | | static void check_palette(running_machine &machine) |
| 895 | void dkong_state::check_palette() |
| 900 | 896 | { |
| 901 | | dkong_state *state = machine.driver_data<dkong_state>(); |
| 902 | 897 | ioport_port *port; |
| 903 | 898 | int newset; |
| 904 | 899 | |
| 905 | | port = state->ioport("VIDHW"); |
| 900 | port = ioport("VIDHW"); |
| 906 | 901 | if (port != NULL) |
| 907 | 902 | { |
| 908 | 903 | newset = port->read(); |
| 909 | | if (newset != state->m_vidhw) |
| 904 | if (newset != m_vidhw) |
| 910 | 905 | { |
| 911 | | state->m_vidhw = newset; |
| 906 | m_vidhw = newset; |
| 912 | 907 | switch (newset) |
| 913 | 908 | { |
| 914 | 909 | case DKONG_RADARSCP_CONVERSION: |
| 915 | | state->PALETTE_INIT_CALL_MEMBER(radarscp); |
| 910 | PALETTE_INIT_CALL_MEMBER(radarscp); |
| 916 | 911 | break; |
| 917 | 912 | case DKONG_BOARD: |
| 918 | | state->PALETTE_INIT_CALL_MEMBER(dkong2b); |
| 913 | PALETTE_INIT_CALL_MEMBER(dkong2b); |
| 919 | 914 | break; |
| 920 | 915 | } |
| 921 | 916 | } |
| r20764 | r20765 | |
| 985 | 980 | { |
| 986 | 981 | case HARDWARE_TKG02: |
| 987 | 982 | case HARDWARE_TKG04: |
| 988 | | check_palette(machine()); |
| 983 | check_palette(); |
| 989 | 984 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 990 | | draw_sprites(machine(), bitmap, cliprect, 0x40, 1); |
| 985 | draw_sprites(bitmap, cliprect, 0x40, 1); |
| 991 | 986 | break; |
| 992 | 987 | case HARDWARE_TRS01: |
| 993 | 988 | case HARDWARE_TRS02: |
| 994 | 989 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 995 | | draw_sprites(machine(), bitmap, cliprect, 0x40, 1); |
| 996 | | radarscp_draw_background(machine(), this, bitmap, cliprect); |
| 990 | draw_sprites(bitmap, cliprect, 0x40, 1); |
| 991 | radarscp_draw_background(this, bitmap, cliprect); |
| 997 | 992 | break; |
| 998 | 993 | default: |
| 999 | 994 | fatalerror("Invalid hardware type in dkong_video_update\n"); |
| r20764 | r20765 | |
| 1027 | 1022 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1028 | 1023 | |
| 1029 | 1024 | /* it uses sprite_ram[offs + 2] & 0x10 for sprite bank */ |
| 1030 | | draw_sprites(machine(), bitmap, cliprect, 0x10, 3); |
| 1025 | draw_sprites(bitmap, cliprect, 0x10, 3); |
| 1031 | 1026 | return 0; |
| 1032 | 1027 | } |
trunk/src/mame/video/dassault.c
| r20764 | r20765 | |
| 26 | 26 | m_sprgen2->alloc_sprite_bitmap(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | | static void mixdassaultlayer(running_machine &machine, bitmap_rgb32 &bitmap, bitmap_ind16* sprite_bitmap, const rectangle &cliprect, UINT16 pri, UINT16 primask, UINT16 penbase, UINT8 alpha) |
| 29 | void dassault_state::mixdassaultlayer(bitmap_rgb32 &bitmap, bitmap_ind16* sprite_bitmap, const rectangle &cliprect, UINT16 pri, UINT16 primask, UINT16 penbase, UINT8 alpha) |
| 30 | 30 | { |
| 31 | 31 | int y, x; |
| 32 | | const pen_t *paldata = machine.pens; |
| 32 | const pen_t *paldata = machine().pens; |
| 33 | 33 | |
| 34 | 34 | UINT16* srcline; |
| 35 | 35 | UINT32* dstline; |
| r20764 | r20765 | |
| 97 | 97 | /* The middle playfields can be swapped priority-wise */ |
| 98 | 98 | if ((priority & 3) == 0) |
| 99 | 99 | { |
| 100 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 |
| 100 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 |
| 101 | 101 | deco16ic_tilemap_2_draw(m_deco_tilegen1, bitmap, cliprect, 0, 2); // 2 |
| 102 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 |
| 102 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 |
| 103 | 103 | deco16ic_tilemap_1_draw(m_deco_tilegen2, bitmap, cliprect, 0, 16); // 16 |
| 104 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 |
| 105 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 64? |
| 106 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 |
| 104 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 |
| 105 | mixdassaultlayer(bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 64? |
| 106 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 |
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | else if ((priority & 3) == 1) |
| 110 | 110 | { |
| 111 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 |
| 111 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 |
| 112 | 112 | deco16ic_tilemap_1_draw(m_deco_tilegen2, bitmap, cliprect, 0, 2); // 2 |
| 113 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 |
| 114 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 16? |
| 115 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 |
| 113 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 |
| 114 | mixdassaultlayer(bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 16? |
| 115 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 |
| 116 | 116 | deco16ic_tilemap_2_draw(m_deco_tilegen1, bitmap, cliprect, 0, 64); // 64 |
| 117 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 |
| 117 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 |
| 118 | 118 | } |
| 119 | 119 | else if ((priority & 3) == 3) |
| 120 | 120 | { |
| 121 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 |
| 121 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 |
| 122 | 122 | deco16ic_tilemap_1_draw(m_deco_tilegen2, bitmap, cliprect, 0, 2); // 2 |
| 123 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 |
| 123 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 |
| 124 | 124 | deco16ic_tilemap_2_draw(m_deco_tilegen1, bitmap, cliprect, 0, 16); // 16 |
| 125 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 |
| 126 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 64? |
| 127 | | mixdassaultlayer(machine(), bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 |
| 125 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 |
| 126 | mixdassaultlayer(bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 64? |
| 127 | mixdassaultlayer(bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 |
| 128 | 128 | } |
| 129 | 129 | else |
| 130 | 130 | { |
trunk/src/mame/video/deco_mlc.c
| r20764 | r20765 | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | #ifdef UNUSED_FUNCTION |
| 34 | | static void blitRaster(running_machine &machine, bitmap_rgb32 &bitmap, int rasterMode) |
| 34 | void deco_mlc_state::blitRaster(bitmap_rgb32 &bitmap, int rasterMode) |
| 35 | 35 | { |
| 36 | | deco_mlc_state *state = machine.driver_data<deco_mlc_state>(); |
| 37 | 36 | int x,y; |
| 38 | 37 | for (y=0; y<256; y++) //todo |
| 39 | 38 | { |
| 40 | 39 | UINT32* src=&temp_bitmap->pix32(y&0x1ff); |
| 41 | 40 | UINT32* dst=&bitmap.pix32(y); |
| 42 | | UINT32 xptr=(state->m_mlc_raster_table[0][y]<<13); |
| 41 | UINT32 xptr=(m_mlc_raster_table[0][y]<<13); |
| 43 | 42 | |
| 44 | | if (machine.input().code_pressed(KEYCODE_X)) |
| 43 | if (machine().input().code_pressed(KEYCODE_X)) |
| 45 | 44 | xptr=0; |
| 46 | 45 | |
| 47 | 46 | for (x=0; x<320; x++) |
| r20764 | r20765 | |
| 49 | 48 | if (src[x]) |
| 50 | 49 | dst[x]=src[(xptr>>16)&0x1ff]; |
| 51 | 50 | |
| 52 | | //if (machine.input().code_pressed(KEYCODE_X)) |
| 51 | //if (machine().input().code_pressed(KEYCODE_X)) |
| 53 | 52 | // xptr+=0x10000; |
| 54 | 53 | //else if(rasterHackTest[0][y]<0) |
| 55 | | xptr+=0x10000 - ((state->m_mlc_raster_table[2][y]&0x3ff)<<5); |
| 54 | xptr+=0x10000 - ((m_mlc_raster_table[2][y]&0x3ff)<<5); |
| 56 | 55 | //else |
| 57 | | // xptr+=0x10000 + (state->m_mlc_raster_table[0][y]<<5); |
| 56 | // xptr+=0x10000 + (m_mlc_raster_table[0][y]<<5); |
| 58 | 57 | } |
| 59 | 58 | } |
| 60 | 59 | } |
| r20764 | r20765 | |
| 209 | 208 | } |
| 210 | 209 | } |
| 211 | 210 | |
| 212 | | static void draw_sprites(running_machine& machine, bitmap_rgb32 &bitmap,const rectangle &cliprect) |
| 211 | void deco_mlc_state::draw_sprites( bitmap_rgb32 &bitmap,const rectangle &cliprect) |
| 213 | 212 | { |
| 214 | | deco_mlc_state *state = machine.driver_data<deco_mlc_state>(); |
| 215 | 213 | UINT32 *index_ptr=0; |
| 216 | 214 | int offs,fx=0,fy=0,x,y,color,colorOffset,sprite,indx,h,w,bx,by,fx1,fy1; |
| 217 | 215 | int xoffs,yoffs; |
| 218 | | UINT8 *rom = state->memregion("gfx2")->base() + 0x20000, *index_ptr8; |
| 219 | | UINT8 *rawrom = state->memregion("gfx2")->base(); |
| 216 | UINT8 *rom = memregion("gfx2")->base() + 0x20000, *index_ptr8; |
| 217 | UINT8 *rawrom = memregion("gfx2")->base(); |
| 220 | 218 | int blockIsTilemapIndex=0; |
| 221 | 219 | int sprite2=0,indx2=0,use8bppMode=0; |
| 222 | 220 | int yscale,xscale; |
| r20764 | r20765 | |
| 230 | 228 | // int rasterDirty=0; |
| 231 | 229 | int clipper=0; |
| 232 | 230 | rectangle user_clip; |
| 233 | | UINT32* mlc_spriteram=state->m_mlc_buffered_spriteram; // spriteram32 |
| 231 | UINT32* mlc_spriteram=m_mlc_buffered_spriteram; // spriteram32 |
| 234 | 232 | |
| 235 | 233 | for (offs = (0x3000/4)-8; offs>=0; offs-=8) |
| 236 | 234 | { |
| 237 | 235 | if ((mlc_spriteram[offs+0]&0x8000)==0) |
| 238 | 236 | continue; |
| 239 | | if ((mlc_spriteram[offs+1]&0x2000) && (machine.primary_screen->frame_number() & 1)) |
| 237 | if ((mlc_spriteram[offs+1]&0x2000) && (machine().primary_screen->frame_number() & 1)) |
| 240 | 238 | continue; |
| 241 | 239 | |
| 242 | 240 | /* |
| r20764 | r20765 | |
| 297 | 295 | however there are space for 8 clipping windows, where is the high bit? (Or is it ~0x400?) */ |
| 298 | 296 | clipper=((clipper&2)>>1)|((clipper&1)<<1); // Swap low two bits |
| 299 | 297 | |
| 300 | | user_clip.min_y=state->m_mlc_clip_ram[(clipper*4)+0]; |
| 301 | | user_clip.max_y=state->m_mlc_clip_ram[(clipper*4)+1]; |
| 302 | | user_clip.min_x=state->m_mlc_clip_ram[(clipper*4)+2]; |
| 303 | | user_clip.max_x=state->m_mlc_clip_ram[(clipper*4)+3]; |
| 298 | user_clip.min_y=m_mlc_clip_ram[(clipper*4)+0]; |
| 299 | user_clip.max_y=m_mlc_clip_ram[(clipper*4)+1]; |
| 300 | user_clip.min_x=m_mlc_clip_ram[(clipper*4)+2]; |
| 301 | user_clip.max_x=m_mlc_clip_ram[(clipper*4)+3]; |
| 304 | 302 | |
| 305 | 303 | user_clip &= cliprect; |
| 306 | 304 | |
| 307 | 305 | /* Any colours out of range (for the bpp value) trigger 'shadow' mode */ |
| 308 | | if (color & (state->m_colour_mask+1)) |
| 306 | if (color & (m_colour_mask+1)) |
| 309 | 307 | alpha=0x80; |
| 310 | 308 | else |
| 311 | 309 | alpha=0xff; |
| 312 | | color&=state->m_colour_mask; |
| 310 | color&=m_colour_mask; |
| 313 | 311 | |
| 314 | 312 | /* If this bit is set, combine this block with the next one */ |
| 315 | 313 | if (mlc_spriteram[offs+1]&0x1000) { |
| r20764 | r20765 | |
| 356 | 354 | |
| 357 | 355 | } else { |
| 358 | 356 | indx&=0x1fff; |
| 359 | | index_ptr=state->m_mlc_vram + indx*4; |
| 357 | index_ptr=m_mlc_vram + indx*4; |
| 360 | 358 | h=(index_ptr[0]>>8)&0xf; |
| 361 | 359 | w=(index_ptr[1]>>8)&0xf; |
| 362 | 360 | |
| r20764 | r20765 | |
| 364 | 362 | if (!w) w=16; |
| 365 | 363 | |
| 366 | 364 | if (use8bppMode) { |
| 367 | | UINT32* index_ptr2=state->m_mlc_vram + ((indx2*4)&0x7fff); |
| 365 | UINT32* index_ptr2=m_mlc_vram + ((indx2*4)&0x7fff); |
| 368 | 366 | sprite2=((index_ptr2[2]&0x3)<<16) | (index_ptr2[3]&0xffff); |
| 369 | 367 | } |
| 370 | 368 | |
| r20764 | r20765 | |
| 444 | 442 | } |
| 445 | 443 | else |
| 446 | 444 | { |
| 447 | | const UINT32* ptr=state->m_mlc_vram + ((sprite)&0x7fff); |
| 445 | const UINT32* ptr=m_mlc_vram + ((sprite)&0x7fff); |
| 448 | 446 | tile=(*ptr)&0xffff; |
| 449 | 447 | |
| 450 | 448 | if (tileFormat) |
| r20764 | r20765 | |
| 466 | 464 | // rasterDirty=1; |
| 467 | 465 | |
| 468 | 466 | mlc_drawgfxzoom( |
| 469 | | /*rasterMode ? temp_bitmap : */bitmap,user_clip,machine.gfx[0], |
| 467 | /*rasterMode ? temp_bitmap : */bitmap,user_clip,machine().gfx[0], |
| 470 | 468 | tile,tile2, |
| 471 | 469 | color + colorOffset,fx,fy,xbase,ybase, |
| 472 | 470 | 0, |
| r20764 | r20765 | |
| 511 | 509 | { |
| 512 | 510 | // temp_bitmap->fill(0, cliprect); |
| 513 | 511 | bitmap.fill(machine().pens[0], cliprect); /* Pen 0 fill colour confirmed from Skull Fang level 2 */ |
| 514 | | draw_sprites(machine(),bitmap,cliprect); |
| 512 | draw_sprites(bitmap,cliprect); |
| 515 | 513 | return 0; |
| 516 | 514 | } |
trunk/src/mame/video/docastle.c
| r20764 | r20765 | |
| 109 | 109 | SET_TILE_INFO_MEMBER(0, code, color, 0); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | | static void video_start_common( running_machine &machine, UINT32 tile_transmask ) |
| 112 | void docastle_state::video_start_common( UINT32 tile_transmask ) |
| 113 | 113 | { |
| 114 | | docastle_state *state = machine.driver_data<docastle_state>(); |
| 115 | | state->m_do_tilemap = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(docastle_state::get_tile_info),state), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); |
| 116 | | state->m_do_tilemap->set_transmask(0, tile_transmask, 0x0000); |
| 114 | m_do_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(docastle_state::get_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); |
| 115 | m_do_tilemap->set_transmask(0, tile_transmask, 0x0000); |
| 117 | 116 | } |
| 118 | 117 | |
| 119 | 118 | void docastle_state::video_start() |
| 120 | 119 | { |
| 121 | | video_start_common(machine(), 0x00ff); |
| 120 | video_start_common(0x00ff); |
| 122 | 121 | } |
| 123 | 122 | |
| 124 | 123 | VIDEO_START_MEMBER(docastle_state,dorunrun) |
| 125 | 124 | { |
| 126 | | video_start_common(machine(), 0xff00); |
| 125 | video_start_common(0xff00); |
| 127 | 126 | } |
| 128 | 127 | |
| 129 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 128 | void docastle_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 130 | 129 | { |
| 131 | | docastle_state *state = machine.driver_data<docastle_state>(); |
| 132 | 130 | int offs; |
| 133 | 131 | |
| 134 | | machine.priority_bitmap.fill(1); |
| 132 | machine().priority_bitmap.fill(1); |
| 135 | 133 | |
| 136 | | for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 134 | for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4) |
| 137 | 135 | { |
| 138 | 136 | int sx, sy, flipx, flipy, code, color; |
| 139 | 137 | |
| 140 | | if (machine.gfx[1]->elements() > 256) |
| 138 | if (machine().gfx[1]->elements() > 256) |
| 141 | 139 | { |
| 142 | 140 | /* spriteram |
| 143 | 141 | |
| r20764 | r20765 | |
| 156 | 154 | |
| 157 | 155 | */ |
| 158 | 156 | |
| 159 | | code = state->m_spriteram[offs + 3]; |
| 160 | | color = state->m_spriteram[offs + 2] & 0x0f; |
| 161 | | sx = ((state->m_spriteram[offs + 1] + 8) & 0xff) - 8; |
| 162 | | sy = state->m_spriteram[offs]; |
| 163 | | flipx = state->m_spriteram[offs + 2] & 0x40; |
| 157 | code = m_spriteram[offs + 3]; |
| 158 | color = m_spriteram[offs + 2] & 0x0f; |
| 159 | sx = ((m_spriteram[offs + 1] + 8) & 0xff) - 8; |
| 160 | sy = m_spriteram[offs]; |
| 161 | flipx = m_spriteram[offs + 2] & 0x40; |
| 164 | 162 | flipy = 0; |
| 165 | | if (state->m_spriteram[offs + 2] & 0x10) code += 0x100; |
| 166 | | if (state->m_spriteram[offs + 2] & 0x80) code += 0x200; |
| 163 | if (m_spriteram[offs + 2] & 0x10) code += 0x100; |
| 164 | if (m_spriteram[offs + 2] & 0x80) code += 0x200; |
| 167 | 165 | } |
| 168 | 166 | else |
| 169 | 167 | { |
| r20764 | r20765 | |
| 182 | 180 | |
| 183 | 181 | */ |
| 184 | 182 | |
| 185 | | code = state->m_spriteram[offs + 3]; |
| 186 | | color = state->m_spriteram[offs + 2] & 0x1f; |
| 187 | | sx = ((state->m_spriteram[offs + 1] + 8) & 0xff) - 8; |
| 188 | | sy = state->m_spriteram[offs]; |
| 189 | | flipx = state->m_spriteram[offs + 2] & 0x40; |
| 190 | | flipy = state->m_spriteram[offs + 2] & 0x80; |
| 183 | code = m_spriteram[offs + 3]; |
| 184 | color = m_spriteram[offs + 2] & 0x1f; |
| 185 | sx = ((m_spriteram[offs + 1] + 8) & 0xff) - 8; |
| 186 | sy = m_spriteram[offs]; |
| 187 | flipx = m_spriteram[offs + 2] & 0x40; |
| 188 | flipy = m_spriteram[offs + 2] & 0x80; |
| 191 | 189 | } |
| 192 | 190 | |
| 193 | | if (state->flip_screen()) |
| 191 | if (flip_screen()) |
| 194 | 192 | { |
| 195 | 193 | sx = 240 - sx; |
| 196 | 194 | sy = 240 - sy; |
| r20764 | r20765 | |
| 199 | 197 | } |
| 200 | 198 | |
| 201 | 199 | /* first draw the sprite, visible */ |
| 202 | | pdrawgfx_transmask(bitmap,cliprect,machine.gfx[1], |
| 200 | pdrawgfx_transmask(bitmap,cliprect,machine().gfx[1], |
| 203 | 201 | code, |
| 204 | 202 | color, |
| 205 | 203 | flipx,flipy, |
| 206 | 204 | sx,sy, |
| 207 | | machine.priority_bitmap, |
| 205 | machine().priority_bitmap, |
| 208 | 206 | 0x00,0x80ff); |
| 209 | 207 | |
| 210 | 208 | /* then draw the mask, behind the background but obscuring following sprites */ |
| 211 | | pdrawgfx_transmask(bitmap,cliprect,machine.gfx[1], |
| 209 | pdrawgfx_transmask(bitmap,cliprect,machine().gfx[1], |
| 212 | 210 | code, |
| 213 | 211 | color, |
| 214 | 212 | flipx,flipy, |
| 215 | 213 | sx,sy, |
| 216 | | machine.priority_bitmap, |
| 214 | machine().priority_bitmap, |
| 217 | 215 | 0x02,0x7fff); |
| 218 | 216 | } |
| 219 | 217 | } |
| r20764 | r20765 | |
| 221 | 219 | UINT32 docastle_state::screen_update_docastle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 222 | 220 | { |
| 223 | 221 | m_do_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 224 | | draw_sprites(machine(), bitmap, cliprect); |
| 222 | draw_sprites(bitmap, cliprect); |
| 225 | 223 | m_do_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0); |
| 226 | 224 | return 0; |
| 227 | 225 | } |
trunk/src/mame/video/ddragon3.c
| r20764 | r20765 | |
| 106 | 106 | * 6,7| unused |
| 107 | 107 | */ |
| 108 | 108 | |
| 109 | | static void draw_sprites( running_machine& machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 109 | void ddragon3_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 110 | 110 | { |
| 111 | | ddragon3_state *state = machine.driver_data<ddragon3_state>(); |
| 112 | | UINT16 *source = state->m_spriteram; |
| 111 | UINT16 *source = m_spriteram; |
| 113 | 112 | UINT16 *finish = source + 0x800; |
| 114 | 113 | |
| 115 | 114 | while (source < finish) |
| r20764 | r20765 | |
| 132 | 131 | if (attr & 0x02) sy = 239 + (0x100 - sy); else sy = 240 - sy; |
| 133 | 132 | if (sx > 0x17f) sx = 0 - (0x200 - sx); |
| 134 | 133 | |
| 135 | | if (state->flip_screen()) |
| 134 | if (flip_screen()) |
| 136 | 135 | { |
| 137 | 136 | sx = 304 - sx; |
| 138 | 137 | sy = 224 - sy; |
| r20764 | r20765 | |
| 143 | 142 | for (i = 0; i <= height; i++) |
| 144 | 143 | { |
| 145 | 144 | drawgfx_transpen(bitmap, cliprect, |
| 146 | | machine.gfx[1], code + i, color, flipx, flipy, |
| 147 | | sx, sy + (state->flip_screen() ? (i * 16) : (-i * 16)), 0); |
| 145 | machine().gfx[1], code + i, color, flipx, flipy, |
| 146 | sx, sy + (flip_screen() ? (i * 16) : (-i * 16)), 0); |
| 148 | 147 | } |
| 149 | 148 | } |
| 150 | 149 | |
| r20764 | r20765 | |
| 163 | 162 | { |
| 164 | 163 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 165 | 164 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 166 | | draw_sprites(machine(), bitmap, cliprect); |
| 165 | draw_sprites(bitmap, cliprect); |
| 167 | 166 | } |
| 168 | 167 | else if ((m_vreg & 0x60) == 0x60) |
| 169 | 168 | { |
| 170 | 169 | m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 171 | 170 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 172 | | draw_sprites(machine(), bitmap, cliprect); |
| 171 | draw_sprites(bitmap, cliprect); |
| 173 | 172 | } |
| 174 | 173 | else |
| 175 | 174 | { |
| 176 | 175 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 177 | | draw_sprites(machine(), bitmap, cliprect); |
| 176 | draw_sprites(bitmap, cliprect); |
| 178 | 177 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 179 | 178 | } |
| 180 | 179 | return 0; |
| r20764 | r20765 | |
| 190 | 189 | if(m_vreg & 8) |
| 191 | 190 | { |
| 192 | 191 | m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 193 | | draw_sprites(machine(), bitmap, cliprect); |
| 192 | draw_sprites(bitmap, cliprect); |
| 194 | 193 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 195 | 194 | } |
| 196 | 195 | else |
| 197 | 196 | { |
| 198 | 197 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 199 | 198 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 200 | | draw_sprites(machine(), bitmap, cliprect); |
| 199 | draw_sprites(bitmap, cliprect); |
| 201 | 200 | } |
| 202 | 201 | return 0; |
| 203 | 202 | } |
trunk/src/mame/video/deco32.c
| r20764 | r20765 | |
| 60 | 60 | COMBINE_DATA(&m_ace_ram[offset]); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | | static void updateAceRam(running_machine& machine) |
| 63 | void deco32_state::updateAceRam() |
| 64 | 64 | { |
| 65 | | deco32_state *state = machine.driver_data<deco32_state>(); |
| 66 | 65 | int r,g,b,i; |
| 67 | | UINT8 fadeptr=state->m_ace_ram[0x20]; |
| 68 | | UINT8 fadeptg=state->m_ace_ram[0x21]; |
| 69 | | UINT8 fadeptb=state->m_ace_ram[0x22]; |
| 70 | | UINT8 fadepsr=state->m_ace_ram[0x23]; |
| 71 | | UINT8 fadepsg=state->m_ace_ram[0x24]; |
| 72 | | UINT8 fadepsb=state->m_ace_ram[0x25]; |
| 73 | | // UINT8 mode=state->m_ace_ram[0x26]; |
| 66 | UINT8 fadeptr=m_ace_ram[0x20]; |
| 67 | UINT8 fadeptg=m_ace_ram[0x21]; |
| 68 | UINT8 fadeptb=m_ace_ram[0x22]; |
| 69 | UINT8 fadepsr=m_ace_ram[0x23]; |
| 70 | UINT8 fadepsg=m_ace_ram[0x24]; |
| 71 | UINT8 fadepsb=m_ace_ram[0x25]; |
| 72 | // UINT8 mode=m_ace_ram[0x26]; |
| 74 | 73 | |
| 75 | | state->m_ace_ram_dirty=0; |
| 74 | m_ace_ram_dirty=0; |
| 76 | 75 | |
| 77 | 76 | for (i=0; i<2048; i++) |
| 78 | 77 | { |
| 79 | 78 | /* Lerp palette entry to 'fadept' according to 'fadeps' */ |
| 80 | | b = (state->m_generic_paletteram_32[i] >>16) & 0xff; |
| 81 | | g = (state->m_generic_paletteram_32[i] >> 8) & 0xff; |
| 82 | | r = (state->m_generic_paletteram_32[i] >> 0) & 0xff; |
| 79 | b = (m_generic_paletteram_32[i] >>16) & 0xff; |
| 80 | g = (m_generic_paletteram_32[i] >> 8) & 0xff; |
| 81 | r = (m_generic_paletteram_32[i] >> 0) & 0xff; |
| 83 | 82 | |
| 84 | 83 | if (i>255) /* Screenshots seem to suggest ACE fades do not affect playfield 1 palette (0-255) */ |
| 85 | 84 | { |
| r20764 | r20765 | |
| 89 | 88 | r = (UINT8)((float)r + (((float)fadeptr - (float)r) * (float)fadepsr/255.0f)); |
| 90 | 89 | } |
| 91 | 90 | |
| 92 | | palette_set_color(machine,i,MAKE_RGB(r,g,b)); |
| 91 | palette_set_color(machine(),i,MAKE_RGB(r,g,b)); |
| 93 | 92 | } |
| 94 | 93 | } |
| 95 | 94 | |
| r20764 | r20765 | |
| 331 | 330 | } |
| 332 | 331 | } |
| 333 | 332 | |
| 334 | | static void dragngun_draw_sprites(running_machine& machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata) |
| 333 | void dragngun_state::dragngun_draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata) |
| 335 | 334 | { |
| 336 | | dragngun_state *state = machine.driver_data<dragngun_state>(); |
| 337 | 335 | const UINT32 *layout_ram; |
| 338 | 336 | const UINT32 *lookup_ram; |
| 339 | 337 | int offs; |
| r20764 | r20765 | |
| 384 | 382 | */ |
| 385 | 383 | |
| 386 | 384 | /* Sprite global disable bit */ |
| 387 | | if (state->m_dragngun_sprite_ctrl&0x40000000) |
| 385 | if (m_dragngun_sprite_ctrl&0x40000000) |
| 388 | 386 | return; |
| 389 | 387 | |
| 390 | 388 | for (offs = 0;offs < 0x800;offs += 8) |
| r20764 | r20765 | |
| 399 | 397 | continue; |
| 400 | 398 | |
| 401 | 399 | if (spritedata[offs+0]&0x400) |
| 402 | | layout_ram = state->m_dragngun_sprite_layout_1_ram + ((spritedata[offs+0]&0x1ff)*4); //CHECK! |
| 400 | layout_ram = m_dragngun_sprite_layout_1_ram + ((spritedata[offs+0]&0x1ff)*4); //CHECK! |
| 403 | 401 | else |
| 404 | | layout_ram = state->m_dragngun_sprite_layout_0_ram + ((spritedata[offs+0]&0x1ff)*4); //1ff in drag gun code?? |
| 402 | layout_ram = m_dragngun_sprite_layout_0_ram + ((spritedata[offs+0]&0x1ff)*4); //1ff in drag gun code?? |
| 405 | 403 | h = (layout_ram[1]>>0)&0xf; |
| 406 | 404 | w = (layout_ram[1]>>4)&0xf; |
| 407 | 405 | if (!h || !w) |
| r20764 | r20765 | |
| 428 | 426 | |
| 429 | 427 | // if (spritedata[offs+0]&0x400) |
| 430 | 428 | if (layout_ram[0]&0x2000) |
| 431 | | lookup_ram = state->m_dragngun_sprite_lookup_1_ram + (layout_ram[0]&0x1fff); |
| 429 | lookup_ram = m_dragngun_sprite_lookup_1_ram + (layout_ram[0]&0x1fff); |
| 432 | 430 | else |
| 433 | | lookup_ram = state->m_dragngun_sprite_lookup_0_ram + (layout_ram[0]&0x1fff); |
| 431 | lookup_ram = m_dragngun_sprite_lookup_0_ram + (layout_ram[0]&0x1fff); |
| 434 | 432 | |
| 435 | 433 | zoomx=scalex * 0x10000 / (w*16); |
| 436 | 434 | zoomy=scaley * 0x10000 / (h*16); |
| r20764 | r20765 | |
| 454 | 452 | /* High bits of the sprite reference into the sprite control bits for banking */ |
| 455 | 453 | switch (sprite&0x3000) { |
| 456 | 454 | default: |
| 457 | | case 0x0000: sprite=(sprite&0xfff) | ((state->m_dragngun_sprite_ctrl&0x000f)<<12); break; |
| 458 | | case 0x1000: sprite=(sprite&0xfff) | ((state->m_dragngun_sprite_ctrl&0x00f0)<< 8); break; |
| 459 | | case 0x2000: sprite=(sprite&0xfff) | ((state->m_dragngun_sprite_ctrl&0x0f00)<< 4); break; |
| 460 | | case 0x3000: sprite=(sprite&0xfff) | ((state->m_dragngun_sprite_ctrl&0xf000)<< 0); break; |
| 455 | case 0x0000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0x000f)<<12); break; |
| 456 | case 0x1000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0x00f0)<< 8); break; |
| 457 | case 0x2000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0x0f00)<< 4); break; |
| 458 | case 0x3000: sprite=(sprite&0xfff) | ((m_dragngun_sprite_ctrl&0xf000)<< 0); break; |
| 461 | 459 | } |
| 462 | 460 | |
| 463 | 461 | /* Because of the unusual interleaved rom layout, we have to mangle the bank bits |
| r20764 | r20765 | |
| 479 | 477 | |
| 480 | 478 | if (zoomx!=0x10000 || zoomy!=0x10000) |
| 481 | 479 | dragngun_drawgfxzoom( |
| 482 | | bitmap,cliprect,machine.gfx[bank], |
| 480 | bitmap,cliprect,machine().gfx[bank], |
| 483 | 481 | sprite, |
| 484 | 482 | colour, |
| 485 | 483 | fx,fy, |
| r20764 | r20765 | |
| 487 | 485 | 15,zoomx,zoomy,NULL,0, |
| 488 | 486 | ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha ); |
| 489 | 487 | else |
| 490 | | drawgfx_alpha(bitmap,cliprect,machine.gfx[bank], |
| 488 | drawgfx_alpha(bitmap,cliprect,machine().gfx[bank], |
| 491 | 489 | sprite, |
| 492 | 490 | colour, |
| 493 | 491 | fx,fy, |
| r20764 | r20765 | |
| 634 | 632 | { |
| 635 | 633 | rectangle clip(cliprect.min_x, cliprect.max_x, 8, 247); |
| 636 | 634 | |
| 637 | | dragngun_draw_sprites(machine(),bitmap,clip,m_spriteram->buffer()); |
| 635 | dragngun_draw_sprites(bitmap,clip,m_spriteram->buffer()); |
| 638 | 636 | deco16ic_tilemap_1_draw(m_deco_tilegen1, bitmap, clip, 0, 0); |
| 639 | 637 | |
| 640 | 638 | } |
| r20764 | r20765 | |
| 686 | 684 | blending support - it can't be done in-place on the final framebuffer |
| 687 | 685 | without a lot of support bitmaps. |
| 688 | 686 | */ |
| 689 | | static void mixDualAlphaSprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx0, gfx_element *gfx1, int mixAlphaTilemap) |
| 687 | void deco32_state::mixDualAlphaSprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, gfx_element *gfx0, gfx_element *gfx1, int mixAlphaTilemap) |
| 690 | 688 | { |
| 691 | | deco32_state *state = gfx0->machine().driver_data<deco32_state>(); |
| 692 | | running_machine &machine = gfx0->machine(); |
| 693 | | const pen_t *pens = machine.pens; |
| 689 | const pen_t *pens = machine().pens; |
| 694 | 690 | const pen_t *pal0 = &pens[gfx0->colorbase()]; |
| 695 | 691 | const pen_t *pal1 = &pens[gfx1->colorbase()]; |
| 696 | | const pen_t *pal2 = &pens[machine.gfx[(state->m_pri&1) ? 1 : 2]->colorbase()]; |
| 692 | const pen_t *pal2 = &pens[machine().gfx[(m_pri&1) ? 1 : 2]->colorbase()]; |
| 697 | 693 | int x,y; |
| 698 | | bitmap_ind16& sprite0_mix_bitmap = machine.device<decospr_device>("spritegen1")->get_sprite_temp_bitmap(); |
| 699 | | bitmap_ind16& sprite1_mix_bitmap = machine.device<decospr_device>("spritegen2")->get_sprite_temp_bitmap(); |
| 694 | bitmap_ind16& sprite0_mix_bitmap = machine().device<decospr_device>("spritegen1")->get_sprite_temp_bitmap(); |
| 695 | bitmap_ind16& sprite1_mix_bitmap = machine().device<decospr_device>("spritegen2")->get_sprite_temp_bitmap(); |
| 700 | 696 | |
| 701 | 697 | |
| 702 | 698 | /* Mix sprites into main bitmap, based on priority & alpha */ |
| 703 | 699 | for (y=8; y<248; y++) { |
| 704 | | UINT8* tilemapPri=&machine.priority_bitmap.pix8(y); |
| 700 | UINT8* tilemapPri=&machine().priority_bitmap.pix8(y); |
| 705 | 701 | UINT16* sprite0=&sprite0_mix_bitmap.pix16(y); |
| 706 | 702 | UINT16* sprite1=&sprite1_mix_bitmap.pix16(y); |
| 707 | 703 | UINT32* destLine=&bitmap.pix32(y); |
| 708 | | UINT16* alphaTilemap=&state->m_tilemap_alpha_bitmap->pix16(y); |
| 704 | UINT16* alphaTilemap=&m_tilemap_alpha_bitmap->pix16(y); |
| 709 | 705 | |
| 710 | 706 | for (x=0; x<320; x++) { |
| 711 | 707 | UINT16 priColAlphaPal0=sprite0[x]; |
| r20764 | r20765 | |
| 759 | 755 | */ |
| 760 | 756 | |
| 761 | 757 | /* Alpha values are tied to ACE ram... */ |
| 762 | | //int alpha=((state->m_ace_ram[0x0 + (((priColAlphaPal1&0xf0)>>4)/2)]) * 8)-1; |
| 758 | //int alpha=((m_ace_ram[0x0 + (((priColAlphaPal1&0xf0)>>4)/2)]) * 8)-1; |
| 763 | 759 | //if (alpha<0) |
| 764 | 760 | // alpha=0; |
| 765 | 761 | |
| r20764 | r20765 | |
| 768 | 764 | |
| 769 | 765 | if (pri1==0 && (((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2)))) |
| 770 | 766 | { |
| 771 | | if ((state->m_pri&1)==0 || ((state->m_pri&1)==1 && tilemapPri[x]<4) || ((state->m_pri&1)==1 && mixAlphaTilemap)) |
| 767 | if ((m_pri&1)==0 || ((m_pri&1)==1 && tilemapPri[x]<4) || ((m_pri&1)==1 && mixAlphaTilemap)) |
| 772 | 768 | destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->granularity() * col1)], 0x80); |
| 773 | 769 | } |
| 774 | 770 | else if (pri1==1 && ((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2))) |
| r20764 | r20765 | |
| 807 | 803 | && ((priColAlphaPal1&0xff)==0 || (pri1&0x3)==2 || (pri1&0x3)==3 || alpha1)) |
| 808 | 804 | { |
| 809 | 805 | /* Alpha values are tied to ACE ram */ |
| 810 | | int alpha=((state->m_ace_ram[0x17 + (((p&0xf0)>>4)/2)]) * 8)-1; |
| 806 | int alpha=((m_ace_ram[0x17 + (((p&0xf0)>>4)/2)]) * 8)-1; |
| 811 | 807 | if (alpha<0) |
| 812 | 808 | alpha=0; |
| 813 | 809 | |
| r20764 | r20765 | |
| 833 | 829 | alphaTilemap=1; |
| 834 | 830 | |
| 835 | 831 | if (m_ace_ram_dirty) |
| 836 | | updateAceRam(machine()); |
| 832 | updateAceRam(); |
| 837 | 833 | |
| 838 | 834 | machine().priority_bitmap.fill(0, cliprect); |
| 839 | 835 | |
trunk/src/mame/video/dcon.c
| r20764 | r20765 | |
| 139 | 139 | m_gfx_bank_select = 0; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | | static void draw_sprites(running_machine& machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 142 | void dcon_state::draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 143 | 143 | { |
| 144 | | dcon_state *state = machine.driver_data<dcon_state>(); |
| 145 | | UINT16 *spriteram16 = state->m_spriteram; |
| 144 | UINT16 *spriteram16 = m_spriteram; |
| 146 | 145 | int offs,fx,fy,x,y,color,sprite; |
| 147 | 146 | int dx,dy,ax,ay,inc,pri_mask = 0; |
| 148 | 147 | |
| r20764 | r20765 | |
| 185 | 184 | for (ay=0; ay<dy; ay++) { |
| 186 | 185 | if (!fx && !fy) |
| 187 | 186 | { |
| 188 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 187 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 189 | 188 | sprite + inc, |
| 190 | 189 | color,fx,fy,x+ax*16,y+ay*16, |
| 191 | | machine.priority_bitmap,pri_mask,15); |
| 190 | machine().priority_bitmap,pri_mask,15); |
| 192 | 191 | |
| 193 | 192 | // wrap around y |
| 194 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 193 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 195 | 194 | sprite + inc, |
| 196 | 195 | color,fx,fy,x+ax*16,y+ay*16 + 512, |
| 197 | | machine.priority_bitmap,pri_mask,15); |
| 196 | machine().priority_bitmap,pri_mask,15); |
| 198 | 197 | |
| 199 | 198 | // wrap around y |
| 200 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 199 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 201 | 200 | sprite + inc, |
| 202 | 201 | color,fx,fy,x+ax*16,y+ay*16 - 512, |
| 203 | | machine.priority_bitmap,pri_mask,15); |
| 202 | machine().priority_bitmap,pri_mask,15); |
| 204 | 203 | } |
| 205 | 204 | else if (fx && !fy) |
| 206 | 205 | { |
| 207 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 206 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 208 | 207 | sprite + inc, |
| 209 | 208 | color,fx,fy,x+(dx-1-ax)*16,y+ay*16, |
| 210 | | machine.priority_bitmap,pri_mask,15); |
| 209 | machine().priority_bitmap,pri_mask,15); |
| 211 | 210 | |
| 212 | 211 | // wrap around y |
| 213 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 212 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 214 | 213 | sprite + inc, |
| 215 | 214 | color,fx,fy,x+(dx-1-ax)*16,y+ay*16 + 512, |
| 216 | | machine.priority_bitmap,pri_mask,15); |
| 215 | machine().priority_bitmap,pri_mask,15); |
| 217 | 216 | |
| 218 | 217 | // wrap around y |
| 219 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 218 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 220 | 219 | sprite + inc, |
| 221 | 220 | color,fx,fy,x+(dx-1-ax)*16,y+ay*16 - 512, |
| 222 | | machine.priority_bitmap,pri_mask,15); |
| 221 | machine().priority_bitmap,pri_mask,15); |
| 223 | 222 | } |
| 224 | 223 | else if (!fx && fy) |
| 225 | 224 | { |
| 226 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 225 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 227 | 226 | sprite + inc, |
| 228 | 227 | color,fx,fy,x+ax*16,y+(dy-1-ay)*16, |
| 229 | | machine.priority_bitmap,pri_mask,15); |
| 228 | machine().priority_bitmap,pri_mask,15); |
| 230 | 229 | |
| 231 | 230 | // wrap around y |
| 232 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 231 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 233 | 232 | sprite + inc, |
| 234 | 233 | color,fx,fy,x+ax*16,y+(dy-1-ay)*16 + 512, |
| 235 | | machine.priority_bitmap,pri_mask,15); |
| 234 | machine().priority_bitmap,pri_mask,15); |
| 236 | 235 | |
| 237 | 236 | // wrap around y |
| 238 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 237 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 239 | 238 | sprite + inc, |
| 240 | 239 | color,fx,fy,x+ax*16,y+(dy-1-ay)*16 - 512, |
| 241 | | machine.priority_bitmap,pri_mask,15); |
| 240 | machine().priority_bitmap,pri_mask,15); |
| 242 | 241 | } |
| 243 | 242 | else |
| 244 | 243 | { |
| 245 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 244 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 246 | 245 | sprite + inc, |
| 247 | 246 | color,fx,fy,x+(dx-1-ax)*16,y+(dy-1-ay)*16, |
| 248 | | machine.priority_bitmap,pri_mask,15); |
| 247 | machine().priority_bitmap,pri_mask,15); |
| 249 | 248 | |
| 250 | 249 | // wrap around y |
| 251 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 250 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 252 | 251 | sprite + inc, |
| 253 | 252 | color,fx,fy,x+(dx-1-ax)*16,y+(dy-1-ay)*16 + 512, |
| 254 | | machine.priority_bitmap,pri_mask,15); |
| 253 | machine().priority_bitmap,pri_mask,15); |
| 255 | 254 | |
| 256 | 255 | // wrap around y |
| 257 | | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[4], |
| 256 | pdrawgfx_transpen(bitmap,cliprect,machine().gfx[4], |
| 258 | 257 | sprite + inc, |
| 259 | 258 | color,fx,fy,x+(dx-1-ax)*16,y+(dy-1-ay)*16 - 512, |
| 260 | | machine.priority_bitmap,pri_mask,15); |
| 259 | machine().priority_bitmap,pri_mask,15); |
| 261 | 260 | } |
| 262 | 261 | |
| 263 | 262 | inc++; |
| r20764 | r20765 | |
| 286 | 285 | m_foreground_layer->draw(bitmap, cliprect, 0,2); |
| 287 | 286 | m_text_layer->draw(bitmap, cliprect, 0,4); |
| 288 | 287 | |
| 289 | | draw_sprites(machine(),bitmap,cliprect); |
| 288 | draw_sprites(bitmap,cliprect); |
| 290 | 289 | return 0; |
| 291 | 290 | } |
| 292 | 291 | |
| r20764 | r20765 | |
| 320 | 319 | m_foreground_layer->draw(bitmap, cliprect, 0,2); |
| 321 | 320 | m_text_layer->draw(bitmap, cliprect, 0,4); |
| 322 | 321 | |
| 323 | | draw_sprites(machine(),bitmap,cliprect); |
| 322 | draw_sprites(bitmap,cliprect); |
| 324 | 323 | return 0; |
| 325 | 324 | } |
trunk/src/mame/video/deniam.c
| r20764 | r20765 | |
| 2 | 2 | #include "includes/deniam.h" |
| 3 | 3 | |
| 4 | 4 | |
| 5 | | static void deniam_common_init( running_machine &machine ) |
| 5 | void deniam_state::deniam_common_init( ) |
| 6 | 6 | { |
| 7 | | deniam_state *state = machine.driver_data<deniam_state>(); |
| 8 | 7 | int i; |
| 9 | 8 | |
| 10 | | state->m_bg_scrollx_reg = 0x00a4/2; |
| 11 | | state->m_bg_scrolly_reg = 0x00a8/2; |
| 12 | | state->m_bg_page_reg = 0x00ac/2; |
| 13 | | state->m_fg_scrollx_reg = 0x00a2/2; |
| 14 | | state->m_fg_scrolly_reg = 0x00a6/2; |
| 15 | | state->m_fg_page_reg = 0x00aa/2; |
| 9 | m_bg_scrollx_reg = 0x00a4/2; |
| 10 | m_bg_scrolly_reg = 0x00a8/2; |
| 11 | m_bg_page_reg = 0x00ac/2; |
| 12 | m_fg_scrollx_reg = 0x00a2/2; |
| 13 | m_fg_scrolly_reg = 0x00a6/2; |
| 14 | m_fg_page_reg = 0x00aa/2; |
| 16 | 15 | |
| 17 | | state->m_display_enable = 0; |
| 18 | | state->m_coinctrl = 0; |
| 16 | m_display_enable = 0; |
| 17 | m_coinctrl = 0; |
| 19 | 18 | |
| 20 | 19 | for (i = 0; i < 4; i++) |
| 21 | 20 | { |
| 22 | | state->m_bg_page[i] = 0; |
| 23 | | state->m_fg_page[i] = 0; |
| 21 | m_bg_page[i] = 0; |
| 22 | m_fg_page[i] = 0; |
| 24 | 23 | } |
| 25 | 24 | } |
| 26 | 25 | |
| 27 | 26 | DRIVER_INIT_MEMBER(deniam_state,logicpro) |
| 28 | 27 | { |
| 29 | | deniam_common_init(machine()); |
| 28 | deniam_common_init(); |
| 30 | 29 | |
| 31 | 30 | m_bg_scrollx_offs = 0x00d; |
| 32 | 31 | m_bg_scrolly_offs = 0x000; |
| r20764 | r20765 | |
| 36 | 35 | |
| 37 | 36 | DRIVER_INIT_MEMBER(deniam_state,karianx) |
| 38 | 37 | { |
| 39 | | deniam_common_init(machine()); |
| 38 | deniam_common_init(); |
| 40 | 39 | |
| 41 | 40 | m_bg_scrollx_offs = 0x10d; |
| 42 | 41 | m_bg_scrolly_offs = 0x080; |
| r20764 | r20765 | |
| 201 | 200 | * c | ---------------- | zoomy like in System 16? |
| 202 | 201 | * e | ---------------- | |
| 203 | 202 | */ |
| 204 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 203 | void deniam_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 205 | 204 | { |
| 206 | | deniam_state *state = machine.driver_data<deniam_state>(); |
| 207 | 205 | int offs; |
| 208 | | UINT8 *gfx = state->memregion("gfx2")->base(); |
| 206 | UINT8 *gfx = memregion("gfx2")->base(); |
| 209 | 207 | |
| 210 | | for (offs = state->m_spriteram.bytes() / 2 - 8; offs >= 0; offs -= 8) |
| 208 | for (offs = m_spriteram.bytes() / 2 - 8; offs >= 0; offs -= 8) |
| 211 | 209 | { |
| 212 | 210 | int sx, starty, endy, x, y, start, color, width, flipx, primask; |
| 213 | 211 | UINT8 *rom = gfx; |
| 214 | 212 | |
| 215 | | sx = (state->m_spriteram[offs + 1] & 0x01ff) + 16 * 8 - 1; |
| 213 | sx = (m_spriteram[offs + 1] & 0x01ff) + 16 * 8 - 1; |
| 216 | 214 | if (sx >= 512) sx -= 512; |
| 217 | | starty = state->m_spriteram[offs + 0] & 0xff; |
| 218 | | endy = state->m_spriteram[offs + 0] >> 8; |
| 215 | starty = m_spriteram[offs + 0] & 0xff; |
| 216 | endy = m_spriteram[offs + 0] >> 8; |
| 219 | 217 | |
| 220 | | width = state->m_spriteram[offs + 2] & 0x007f; |
| 221 | | flipx = state->m_spriteram[offs + 2] & 0x0100; |
| 218 | width = m_spriteram[offs + 2] & 0x007f; |
| 219 | flipx = m_spriteram[offs + 2] & 0x0100; |
| 222 | 220 | if (flipx) sx++; |
| 223 | 221 | |
| 224 | | color = 0x40 + (state->m_spriteram[offs + 4] & 0x3f); |
| 222 | color = 0x40 + (m_spriteram[offs + 4] & 0x3f); |
| 225 | 223 | |
| 226 | 224 | primask = 8; |
| 227 | | switch (state->m_spriteram[offs + 4] & 0xc0) |
| 225 | switch (m_spriteram[offs + 4] & 0xc0) |
| 228 | 226 | { |
| 229 | 227 | case 0x00: primask |= 4 | 2 | 1; break; /* below everything */ |
| 230 | 228 | case 0x40: primask |= 4 | 2; break; /* below fg and tx */ |
| r20764 | r20765 | |
| 233 | 231 | } |
| 234 | 232 | |
| 235 | 233 | |
| 236 | | start = state->m_spriteram[offs + 3] + ((state->m_spriteram[offs + 4] & 0x1f00) << 8); |
| 234 | start = m_spriteram[offs + 3] + ((m_spriteram[offs + 4] & 0x1f00) << 8); |
| 237 | 235 | rom += 2 * start; |
| 238 | 236 | |
| 239 | 237 | for (y = starty + 1; y <= endy; y++) |
| r20764 | r20765 | |
| 258 | 256 | { |
| 259 | 257 | if (cliprect.contains(sx + x, y)) |
| 260 | 258 | { |
| 261 | | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 259 | if ((machine().priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 262 | 260 | bitmap.pix16(y, sx + x) = color * 16 + (rom[i] & 0x0f); |
| 263 | | machine.priority_bitmap.pix8(y, sx + x) = 8; |
| 261 | machine().priority_bitmap.pix8(y, sx + x) = 8; |
| 264 | 262 | } |
| 265 | 263 | } |
| 266 | 264 | x++; |
| r20764 | r20765 | |
| 277 | 275 | { |
| 278 | 276 | if (cliprect.contains(sx + x, y)) |
| 279 | 277 | { |
| 280 | | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 278 | if ((machine().priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 281 | 279 | bitmap.pix16(y, sx + x) = color * 16+(rom[i] >> 4); |
| 282 | | machine.priority_bitmap.pix8(y, sx + x) = 8; |
| 280 | machine().priority_bitmap.pix8(y, sx + x) = 8; |
| 283 | 281 | } |
| 284 | 282 | } |
| 285 | 283 | x++; |
| r20764 | r20765 | |
| 300 | 298 | { |
| 301 | 299 | if (cliprect.contains(sx + x, y)) |
| 302 | 300 | { |
| 303 | | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 301 | if ((machine().priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 304 | 302 | bitmap.pix16(y, sx + x) = color * 16 + (rom[i] >> 4); |
| 305 | | machine.priority_bitmap.pix8(y, sx + x) = 8; |
| 303 | machine().priority_bitmap.pix8(y, sx + x) = 8; |
| 306 | 304 | } |
| 307 | 305 | } |
| 308 | 306 | x++; |
| r20764 | r20765 | |
| 319 | 317 | { |
| 320 | 318 | if (cliprect.contains(sx + x, y)) |
| 321 | 319 | { |
| 322 | | if ((machine.priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 320 | if ((machine().priority_bitmap.pix8(y, sx + x) & primask) == 0) |
| 323 | 321 | bitmap.pix16(y, sx + x) = color * 16 + (rom[i] & 0x0f); |
| 324 | | machine.priority_bitmap.pix8(y, sx + x) = 8; |
| 322 | machine().priority_bitmap.pix8(y, sx + x) = 8; |
| 325 | 323 | } |
| 326 | 324 | } |
| 327 | 325 | x++; |
| r20764 | r20765 | |
| 334 | 332 | } |
| 335 | 333 | } |
| 336 | 334 | |
| 337 | | static void set_bg_page( running_machine &machine, int page, int value ) |
| 335 | void deniam_state::set_bg_page( int page, int value ) |
| 338 | 336 | { |
| 339 | | deniam_state *state = machine.driver_data<deniam_state>(); |
| 340 | 337 | int tile_index; |
| 341 | 338 | |
| 342 | | if (state->m_bg_page[page] != value) |
| 339 | if (m_bg_page[page] != value) |
| 343 | 340 | { |
| 344 | | state->m_bg_page[page] = value; |
| 341 | m_bg_page[page] = value; |
| 345 | 342 | for (tile_index = page * 0x800; tile_index < (page + 1) * 0x800; tile_index++) |
| 346 | | state->m_bg_tilemap->mark_tile_dirty(tile_index); |
| 343 | m_bg_tilemap->mark_tile_dirty(tile_index); |
| 347 | 344 | } |
| 348 | 345 | } |
| 349 | 346 | |
| 350 | | static void set_fg_page( running_machine &machine, int page, int value ) |
| 347 | void deniam_state::set_fg_page( int page, int value ) |
| 351 | 348 | { |
| 352 | | deniam_state *state = machine.driver_data<deniam_state>(); |
| 353 | 349 | int tile_index; |
| 354 | 350 | |
| 355 | | if (state->m_fg_page[page] != value) |
| 351 | if (m_fg_page[page] != value) |
| 356 | 352 | { |
| 357 | | state->m_fg_page[page] = value; |
| 353 | m_fg_page[page] = value; |
| 358 | 354 | for (tile_index = page * 0x800; tile_index < (page + 1) * 0x800; tile_index++) |
| 359 | | state->m_fg_tilemap->mark_tile_dirty(tile_index); |
| 355 | m_fg_tilemap->mark_tile_dirty(tile_index); |
| 360 | 356 | } |
| 361 | 357 | } |
| 362 | 358 | |
| r20764 | r20765 | |
| 371 | 367 | bg_scrollx = m_textram[m_bg_scrollx_reg] - m_bg_scrollx_offs; |
| 372 | 368 | bg_scrolly = (m_textram[m_bg_scrolly_reg] & 0xff) - m_bg_scrolly_offs; |
| 373 | 369 | page = m_textram[m_bg_page_reg]; |
| 374 | | set_bg_page(machine(), 3, (page >>12) & 0x0f); |
| 375 | | set_bg_page(machine(), 2, (page >> 8) & 0x0f); |
| 376 | | set_bg_page(machine(), 1, (page >> 4) & 0x0f); |
| 377 | | set_bg_page(machine(), 0, (page >> 0) & 0x0f); |
| 370 | set_bg_page(3, (page >>12) & 0x0f); |
| 371 | set_bg_page(2, (page >> 8) & 0x0f); |
| 372 | set_bg_page(1, (page >> 4) & 0x0f); |
| 373 | set_bg_page(0, (page >> 0) & 0x0f); |
| 378 | 374 | |
| 379 | 375 | fg_scrollx = m_textram[m_fg_scrollx_reg] - m_fg_scrollx_offs; |
| 380 | 376 | fg_scrolly = (m_textram[m_fg_scrolly_reg] & 0xff) - m_fg_scrolly_offs; |
| 381 | 377 | page = m_textram[m_fg_page_reg]; |
| 382 | | set_fg_page(machine(), 3, (page >>12) & 0x0f); |
| 383 | | set_fg_page(machine(), 2, (page >> 8) & 0x0f); |
| 384 | | set_fg_page(machine(), 1, (page >> 4) & 0x0f); |
| 385 | | set_fg_page(machine(), 0, (page >> 0) & 0x0f); |
| 378 | set_fg_page(3, (page >>12) & 0x0f); |
| 379 | set_fg_page(2, (page >> 8) & 0x0f); |
| 380 | set_fg_page(1, (page >> 4) & 0x0f); |
| 381 | set_fg_page(0, (page >> 0) & 0x0f); |
| 386 | 382 | |
| 387 | 383 | m_bg_tilemap->set_scrollx(0, bg_scrollx & 0x1ff); |
| 388 | 384 | m_bg_tilemap->set_scrolly(0, bg_scrolly & 0x0ff); |
| r20764 | r20765 | |
| 395 | 391 | m_fg_tilemap->draw(bitmap, cliprect, 0, 2); |
| 396 | 392 | m_tx_tilemap->draw(bitmap, cliprect, 0, 4); |
| 397 | 393 | |
| 398 | | draw_sprites(machine(), bitmap, cliprect); |
| 394 | draw_sprites(bitmap, cliprect); |
| 399 | 395 | return 0; |
| 400 | 396 | } |
trunk/src/mame/video/darius.c
| r20764 | r20765 | |
| 4 | 4 | |
| 5 | 5 | /***************************************************************************/ |
| 6 | 6 | |
| 7 | | INLINE void actual_get_fg_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) |
| 7 | inline void darius_state::actual_get_fg_tile_info( tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) |
| 8 | 8 | { |
| 9 | 9 | UINT16 code = (ram[tile_index + 0x2000] & 0x7ff); |
| 10 | 10 | UINT16 attr = ram[tile_index]; |
| 11 | 11 | |
| 12 | | SET_TILE_INFO( |
| 12 | SET_TILE_INFO_MEMBER( |
| 13 | 13 | gfxnum, |
| 14 | 14 | code, |
| 15 | 15 | ((attr & 0xff) << 2), |
| r20764 | r20765 | |
| 18 | 18 | |
| 19 | 19 | TILE_GET_INFO_MEMBER(darius_state::get_fg_tile_info) |
| 20 | 20 | { |
| 21 | | actual_get_fg_tile_info(machine(), tileinfo, tile_index, m_fg_ram, 2); |
| 21 | actual_get_fg_tile_info(tileinfo, tile_index, m_fg_ram, 2); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /***************************************************************************/ |
| r20764 | r20765 | |
| 41 | 41 | |
| 42 | 42 | /***************************************************************************/ |
| 43 | 43 | |
| 44 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int x_offs, int y_offs ) |
| 44 | void darius_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int x_offs, int y_offs ) |
| 45 | 45 | { |
| 46 | | darius_state *state = machine.driver_data<darius_state>(); |
| 47 | | UINT16 *spriteram = state->m_spriteram; |
| 46 | UINT16 *spriteram = m_spriteram; |
| 48 | 47 | int offs, curx, cury; |
| 49 | 48 | UINT16 code, data, sx, sy; |
| 50 | 49 | UINT8 flipx, flipy, color, priority; |
| 51 | 50 | |
| 52 | | for (offs = state->m_spriteram.bytes() / 2 - 4; offs >= 0; offs -= 4) |
| 51 | for (offs = m_spriteram.bytes() / 2 - 4; offs >= 0; offs -= 4) |
| 53 | 52 | { |
| 54 | 53 | code = spriteram[offs + 2] & 0x1fff; |
| 55 | 54 | |
| r20764 | r20765 | |
| 77 | 76 | if (curx > 900) curx -= 1024; |
| 78 | 77 | if (cury > 400) cury -= 512; |
| 79 | 78 | |
| 80 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 79 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 81 | 80 | code, color, |
| 82 | 81 | flipx, flipy, |
| 83 | 82 | curx, cury, 0); |
| r20764 | r20765 | |
| 87 | 86 | |
| 88 | 87 | |
| 89 | 88 | |
| 90 | | static UINT32 update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffs) |
| 89 | UINT32 darius_state::update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffs) |
| 91 | 90 | { |
| 92 | | darius_state *state = screen.machine().driver_data<darius_state>(); |
| 91 | pc080sn_tilemap_update(m_pc080sn); |
| 93 | 92 | |
| 94 | | pc080sn_tilemap_update(state->m_pc080sn); |
| 95 | | |
| 96 | 93 | // draw bottom layer(always active) |
| 97 | | pc080sn_tilemap_draw_offset(state->m_pc080sn, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0, -xoffs, 0); |
| 94 | pc080sn_tilemap_draw_offset(m_pc080sn, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0, -xoffs, 0); |
| 98 | 95 | |
| 99 | 96 | /* Sprites can be under/over the layer below text layer */ |
| 100 | | draw_sprites(screen.machine(), bitmap, cliprect, 0, xoffs, -8); // draw sprites with priority 0 which are under the mid layer |
| 97 | draw_sprites(bitmap, cliprect, 0, xoffs, -8); // draw sprites with priority 0 which are under the mid layer |
| 101 | 98 | |
| 102 | 99 | // draw middle layer |
| 103 | | pc080sn_tilemap_draw_offset(state->m_pc080sn, bitmap, cliprect, 1, 0, 0, -xoffs, 0); |
| 100 | pc080sn_tilemap_draw_offset(m_pc080sn, bitmap, cliprect, 1, 0, 0, -xoffs, 0); |
| 104 | 101 | |
| 105 | | draw_sprites(screen.machine(), bitmap, cliprect, 1, xoffs, -8); // draw sprites with priority 1 which are over the mid layer |
| 102 | draw_sprites(bitmap, cliprect, 1, xoffs, -8); // draw sprites with priority 1 which are over the mid layer |
| 106 | 103 | |
| 107 | 104 | /* top(text) layer is in fixed position */ |
| 108 | | state->m_fg_tilemap->set_scrollx(0, 0 + xoffs); |
| 109 | | state->m_fg_tilemap->set_scrolly(0, -8); |
| 110 | | state->m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 105 | m_fg_tilemap->set_scrollx(0, 0 + xoffs); |
| 106 | m_fg_tilemap->set_scrolly(0, -8); |
| 107 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 111 | 108 | return 0; |
| 112 | 109 | } |
| 113 | 110 | |