trunk/src/mame/machine/balsente.c
| r20741 | r20742 | |
| 14 | 14 | |
| 15 | 15 | #define LOG_CEM_WRITES 0 |
| 16 | 16 | |
| 17 | | |
| 18 | | /* local prototypes */ |
| 19 | | static void poly17_init(running_machine &machine); |
| 20 | | static void update_grudge_steering(running_machine &machine); |
| 21 | | |
| 22 | | |
| 23 | | |
| 24 | | |
| 25 | 17 | /************************************* |
| 26 | 18 | * |
| 27 | 19 | * Interrupt handling |
| r20741 | r20742 | |
| 50 | 42 | |
| 51 | 43 | /* if this is Grudge Match, update the steering */ |
| 52 | 44 | if (m_grudge_steering_result & 0x80) |
| 53 | | update_grudge_steering(machine()); |
| 45 | update_grudge_steering(); |
| 54 | 46 | |
| 55 | 47 | /* if we're a shooter, we do a little more work */ |
| 56 | 48 | if (m_shooter) |
| r20741 | r20742 | |
| 85 | 77 | m_cem_device[5] = m_cem6; |
| 86 | 78 | |
| 87 | 79 | /* create the polynomial tables */ |
| 88 | | poly17_init(machine()); |
| 80 | poly17_init(); |
| 89 | 81 | |
| 90 | 82 | /* register for saving */ |
| 91 | 83 | for (i = 0; i < 3; i++) |
| r20741 | r20742 | |
| 190 | 182 | * |
| 191 | 183 | *************************************/ |
| 192 | 184 | |
| 193 | | static void poly17_init(running_machine &machine) |
| 185 | void balsente_state::poly17_init() |
| 194 | 186 | { |
| 195 | | balsente_state *state = machine.driver_data<balsente_state>(); |
| 196 | 187 | UINT32 i, x = 0; |
| 197 | 188 | UINT8 *p, *r; |
| 198 | 189 | |
| 199 | 190 | /* allocate memory */ |
| 200 | | p = state->m_poly17; |
| 201 | | r = state->m_rand17; |
| 191 | p = m_poly17; |
| 192 | r = m_rand17; |
| 202 | 193 | |
| 203 | 194 | /* generate the polynomial */ |
| 204 | 195 | for (i = 0; i < POLY17_SIZE; i++) |
| r20741 | r20742 | |
| 337 | 328 | * |
| 338 | 329 | *************************************/ |
| 339 | 330 | |
| 340 | | static void m6850_update_io(running_machine &machine) |
| 331 | void balsente_state::m6850_update_io() |
| 341 | 332 | { |
| 342 | | balsente_state *state = machine.driver_data<balsente_state>(); |
| 343 | 333 | UINT8 new_state; |
| 344 | 334 | |
| 345 | 335 | /* sound -> main CPU communications */ |
| 346 | | if (!(state->m_m6850_sound_status & 0x02)) |
| 336 | if (!(m_m6850_sound_status & 0x02)) |
| 347 | 337 | { |
| 348 | 338 | /* set the overrun bit if the data in the destination hasn't been read yet */ |
| 349 | | if (state->m_m6850_status & 0x01) |
| 350 | | state->m_m6850_status |= 0x20; |
| 339 | if (m_m6850_status & 0x01) |
| 340 | m_m6850_status |= 0x20; |
| 351 | 341 | |
| 352 | 342 | /* copy the sound's output to our input */ |
| 353 | | state->m_m6850_input = state->m_m6850_sound_output; |
| 343 | m_m6850_input = m_m6850_sound_output; |
| 354 | 344 | |
| 355 | 345 | /* set the receive register full bit */ |
| 356 | | state->m_m6850_status |= 0x01; |
| 346 | m_m6850_status |= 0x01; |
| 357 | 347 | |
| 358 | 348 | /* set the sound's trasmitter register empty bit */ |
| 359 | | state->m_m6850_sound_status |= 0x02; |
| 349 | m_m6850_sound_status |= 0x02; |
| 360 | 350 | } |
| 361 | 351 | |
| 362 | 352 | /* main -> sound CPU communications */ |
| 363 | | if (state->m_m6850_data_ready) |
| 353 | if (m_m6850_data_ready) |
| 364 | 354 | { |
| 365 | 355 | /* set the overrun bit if the data in the destination hasn't been read yet */ |
| 366 | | if (state->m_m6850_sound_status & 0x01) |
| 367 | | state->m_m6850_sound_status |= 0x20; |
| 356 | if (m_m6850_sound_status & 0x01) |
| 357 | m_m6850_sound_status |= 0x20; |
| 368 | 358 | |
| 369 | 359 | /* copy the main CPU's output to our input */ |
| 370 | | state->m_m6850_sound_input = state->m_m6850_output; |
| 360 | m_m6850_sound_input = m_m6850_output; |
| 371 | 361 | |
| 372 | 362 | /* set the receive register full bit */ |
| 373 | | state->m_m6850_sound_status |= 0x01; |
| 363 | m_m6850_sound_status |= 0x01; |
| 374 | 364 | |
| 375 | 365 | /* set the main CPU's trasmitter register empty bit */ |
| 376 | | state->m_m6850_status |= 0x02; |
| 377 | | state->m_m6850_data_ready = 0; |
| 366 | m_m6850_status |= 0x02; |
| 367 | m_m6850_data_ready = 0; |
| 378 | 368 | } |
| 379 | 369 | |
| 380 | 370 | /* check for reset states */ |
| 381 | | if ((state->m_m6850_control & 3) == 3) |
| 371 | if ((m_m6850_control & 3) == 3) |
| 382 | 372 | { |
| 383 | | state->m_m6850_status = 0x02; |
| 384 | | state->m_m6850_data_ready = 0; |
| 373 | m_m6850_status = 0x02; |
| 374 | m_m6850_data_ready = 0; |
| 385 | 375 | } |
| 386 | | if ((state->m_m6850_sound_control & 3) == 3) |
| 387 | | state->m_m6850_sound_status = 0x02; |
| 376 | if ((m_m6850_sound_control & 3) == 3) |
| 377 | m_m6850_sound_status = 0x02; |
| 388 | 378 | |
| 389 | 379 | /* check for transmit/receive IRQs on the main CPU */ |
| 390 | 380 | new_state = 0; |
| 391 | | if ((state->m_m6850_control & 0x80) && (state->m_m6850_status & 0x21)) new_state = 1; |
| 392 | | if ((state->m_m6850_control & 0x60) == 0x20 && (state->m_m6850_status & 0x02)) new_state = 1; |
| 381 | if ((m_m6850_control & 0x80) && (m_m6850_status & 0x21)) new_state = 1; |
| 382 | if ((m_m6850_control & 0x60) == 0x20 && (m_m6850_status & 0x02)) new_state = 1; |
| 393 | 383 | |
| 394 | 384 | /* apply the change */ |
| 395 | | if (new_state && !(state->m_m6850_status & 0x80)) |
| 385 | if (new_state && !(m_m6850_status & 0x80)) |
| 396 | 386 | { |
| 397 | | machine.device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, ASSERT_LINE); |
| 398 | | state->m_m6850_status |= 0x80; |
| 387 | machine().device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, ASSERT_LINE); |
| 388 | m_m6850_status |= 0x80; |
| 399 | 389 | } |
| 400 | | else if (!new_state && (state->m_m6850_status & 0x80)) |
| 390 | else if (!new_state && (m_m6850_status & 0x80)) |
| 401 | 391 | { |
| 402 | | machine.device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, CLEAR_LINE); |
| 403 | | state->m_m6850_status &= ~0x80; |
| 392 | machine().device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE, CLEAR_LINE); |
| 393 | m_m6850_status &= ~0x80; |
| 404 | 394 | } |
| 405 | 395 | |
| 406 | 396 | /* check for transmit/receive IRQs on the sound CPU */ |
| 407 | 397 | new_state = 0; |
| 408 | | if ((state->m_m6850_sound_control & 0x80) && (state->m_m6850_sound_status & 0x21)) new_state = 1; |
| 409 | | if ((state->m_m6850_sound_control & 0x60) == 0x20 && (state->m_m6850_sound_status & 0x02)) new_state = 1; |
| 410 | | if (!(state->m_counter_control & 0x20)) new_state = 0; |
| 398 | if ((m_m6850_sound_control & 0x80) && (m_m6850_sound_status & 0x21)) new_state = 1; |
| 399 | if ((m_m6850_sound_control & 0x60) == 0x20 && (m_m6850_sound_status & 0x02)) new_state = 1; |
| 400 | if (!(m_counter_control & 0x20)) new_state = 0; |
| 411 | 401 | |
| 412 | 402 | /* apply the change */ |
| 413 | | if (new_state && !(state->m_m6850_sound_status & 0x80)) |
| 403 | if (new_state && !(m_m6850_sound_status & 0x80)) |
| 414 | 404 | { |
| 415 | | machine.device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE); |
| 416 | | state->m_m6850_sound_status |= 0x80; |
| 405 | machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE); |
| 406 | m_m6850_sound_status |= 0x80; |
| 417 | 407 | } |
| 418 | | else if (!new_state && (state->m_m6850_sound_status & 0x80)) |
| 408 | else if (!new_state && (m_m6850_sound_status & 0x80)) |
| 419 | 409 | { |
| 420 | | machine.device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE); |
| 421 | | state->m_m6850_sound_status &= ~0x80; |
| 410 | machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE); |
| 411 | m_m6850_sound_status &= ~0x80; |
| 422 | 412 | } |
| 423 | 413 | } |
| 424 | 414 | |
| r20741 | r20742 | |
| 447 | 437 | |
| 448 | 438 | /* clear the overrun and receive buffer full bits */ |
| 449 | 439 | m_m6850_status &= ~0x21; |
| 450 | | m6850_update_io(machine()); |
| 440 | m6850_update_io(); |
| 451 | 441 | } |
| 452 | 442 | |
| 453 | 443 | return result; |
| r20741 | r20742 | |
| 459 | 449 | /* set the output data byte and indicate that we're ready to go */ |
| 460 | 450 | m_m6850_output = param; |
| 461 | 451 | m_m6850_data_ready = 1; |
| 462 | | m6850_update_io(machine()); |
| 452 | m6850_update_io(); |
| 463 | 453 | } |
| 464 | 454 | |
| 465 | 455 | |
| r20741 | r20742 | |
| 467 | 457 | { |
| 468 | 458 | /* indicate that the transmit buffer is no longer empty and update the I/O state */ |
| 469 | 459 | m_m6850_status &= ~0x02; |
| 470 | | m6850_update_io(machine()); |
| 460 | m6850_update_io(); |
| 471 | 461 | |
| 472 | 462 | /* set a timer for 500usec later to actually transmit the data */ |
| 473 | 463 | /* (this is very important for several games, esp Snacks'n Jaxson) */ |
| r20741 | r20742 | |
| 483 | 473 | m_m6850_control = data; |
| 484 | 474 | |
| 485 | 475 | /* re-update since interrupt enables could have been modified */ |
| 486 | | m6850_update_io(machine()); |
| 476 | m6850_update_io(); |
| 487 | 477 | } |
| 488 | 478 | |
| 489 | 479 | /* output register is at offset 1; set a timer to synchronize the CPUs */ |
| r20741 | r20742 | |
| 516 | 506 | |
| 517 | 507 | /* clear the overrun and receive buffer full bits */ |
| 518 | 508 | m_m6850_sound_status &= ~0x21; |
| 519 | | m6850_update_io(machine()); |
| 509 | m6850_update_io(); |
| 520 | 510 | } |
| 521 | 511 | |
| 522 | 512 | return result; |
| r20741 | r20742 | |
| 537 | 527 | } |
| 538 | 528 | |
| 539 | 529 | /* re-update since interrupt enables could have been modified */ |
| 540 | | m6850_update_io(machine()); |
| 530 | m6850_update_io(); |
| 541 | 531 | } |
| 542 | 532 | |
| 543 | 533 | |
| r20741 | r20742 | |
| 846 | 836 | * |
| 847 | 837 | *************************************/ |
| 848 | 838 | |
| 849 | | static void set_counter_0_ff(timer_device &timer, int newstate) |
| 839 | void balsente_state::set_counter_0_ff(timer_device &timer, int newstate) |
| 850 | 840 | { |
| 851 | | balsente_state *state = timer.machine().driver_data<balsente_state>(); |
| 852 | | |
| 853 | 841 | /* the flip/flop output is inverted, so if we went high to low, that's a clock */ |
| 854 | | if (state->m_counter_0_ff && !newstate) |
| 842 | if (m_counter_0_ff && !newstate) |
| 855 | 843 | { |
| 856 | 844 | /* only count if gated and non-zero */ |
| 857 | | if (state->m_counter[0].count > 0 && state->m_counter[0].gate) |
| 845 | if (m_counter[0].count > 0 && m_counter[0].gate) |
| 858 | 846 | { |
| 859 | | state->m_counter[0].count--; |
| 860 | | if (state->m_counter[0].count == 0) |
| 861 | | state->balsente_counter_callback(timer, NULL, 0); |
| 847 | m_counter[0].count--; |
| 848 | if (m_counter[0].count == 0) |
| 849 | balsente_counter_callback(timer, NULL, 0); |
| 862 | 850 | } |
| 863 | 851 | } |
| 864 | 852 | |
| 865 | 853 | /* remember the new state */ |
| 866 | | state->m_counter_0_ff = newstate; |
| 854 | m_counter_0_ff = newstate; |
| 867 | 855 | } |
| 868 | 856 | |
| 869 | 857 | |
| r20741 | r20742 | |
| 967 | 955 | if (!(data & 0x10)) set_counter_0_ff(*m_counter_0_timer, 0); |
| 968 | 956 | |
| 969 | 957 | /* bit 5 clears the NMI interrupt; recompute the I/O state now */ |
| 970 | | m6850_update_io(machine()); |
| 958 | m6850_update_io(); |
| 971 | 959 | } |
| 972 | 960 | |
| 973 | 961 | |
| r20741 | r20742 | |
| 1113 | 1101 | } |
| 1114 | 1102 | |
| 1115 | 1103 | |
| 1116 | | static void update_grudge_steering(running_machine &machine) |
| 1104 | void balsente_state::update_grudge_steering() |
| 1117 | 1105 | { |
| 1118 | | balsente_state *state = machine.driver_data<balsente_state>(); |
| 1119 | 1106 | UINT8 wheel[3]; |
| 1120 | 1107 | INT8 diff[3]; |
| 1121 | 1108 | |
| 1122 | 1109 | /* read the current steering values */ |
| 1123 | | wheel[0] = state->ioport("AN0")->read(); |
| 1124 | | wheel[1] = state->ioport("AN1")->read(); |
| 1125 | | wheel[2] = state->ioport("AN2")->read(); |
| 1110 | wheel[0] = ioport("AN0")->read(); |
| 1111 | wheel[1] = ioport("AN1")->read(); |
| 1112 | wheel[2] = ioport("AN2")->read(); |
| 1126 | 1113 | |
| 1127 | 1114 | /* diff the values */ |
| 1128 | | diff[0] = wheel[0] - state->m_grudge_last_steering[0]; |
| 1129 | | diff[1] = wheel[1] - state->m_grudge_last_steering[1]; |
| 1130 | | diff[2] = wheel[2] - state->m_grudge_last_steering[2]; |
| 1115 | diff[0] = wheel[0] - m_grudge_last_steering[0]; |
| 1116 | diff[1] = wheel[1] - m_grudge_last_steering[1]; |
| 1117 | diff[2] = wheel[2] - m_grudge_last_steering[2]; |
| 1131 | 1118 | |
| 1132 | 1119 | /* update the last values */ |
| 1133 | | state->m_grudge_last_steering[0] += diff[0]; |
| 1134 | | state->m_grudge_last_steering[1] += diff[1]; |
| 1135 | | state->m_grudge_last_steering[2] += diff[2]; |
| 1120 | m_grudge_last_steering[0] += diff[0]; |
| 1121 | m_grudge_last_steering[1] += diff[1]; |
| 1122 | m_grudge_last_steering[2] += diff[2]; |
| 1136 | 1123 | |
| 1137 | 1124 | /* compute the result */ |
| 1138 | | state->m_grudge_steering_result = 0xff; |
| 1125 | m_grudge_steering_result = 0xff; |
| 1139 | 1126 | if (diff[0]) |
| 1140 | 1127 | { |
| 1141 | | state->m_grudge_steering_result ^= 0x01; |
| 1142 | | if (diff[0] > 0) state->m_grudge_steering_result ^= 0x02; |
| 1128 | m_grudge_steering_result ^= 0x01; |
| 1129 | if (diff[0] > 0) m_grudge_steering_result ^= 0x02; |
| 1143 | 1130 | } |
| 1144 | 1131 | if (diff[1]) |
| 1145 | 1132 | { |
| 1146 | | state->m_grudge_steering_result ^= 0x04; |
| 1147 | | if (diff[1] > 0) state->m_grudge_steering_result ^= 0x08; |
| 1133 | m_grudge_steering_result ^= 0x04; |
| 1134 | if (diff[1] > 0) m_grudge_steering_result ^= 0x08; |
| 1148 | 1135 | } |
| 1149 | 1136 | if (diff[2]) |
| 1150 | 1137 | { |
| 1151 | | state->m_grudge_steering_result ^= 0x10; |
| 1152 | | if (diff[2] > 0) state->m_grudge_steering_result ^= 0x20; |
| 1138 | m_grudge_steering_result ^= 0x10; |
| 1139 | if (diff[2] > 0) m_grudge_steering_result ^= 0x20; |
| 1153 | 1140 | } |
| 1154 | 1141 | logerror("Recomputed steering\n"); |
| 1155 | 1142 | } |
trunk/src/mame/video/20pacgal.c
| r20741 | r20742 | |
| 22 | 22 | * |
| 23 | 23 | *************************************/ |
| 24 | 24 | |
| 25 | | static void get_pens(running_machine &machine, const _20pacgal_state *state, pen_t *pens) |
| 25 | void _20pacgal_state::get_pens(pen_t *pens) |
| 26 | 26 | { |
| 27 | 27 | offs_t offs; |
| 28 | | UINT8 *color_prom = machine.root_device().memregion("proms")->base() + (NUM_PENS * state->m_game_selected); |
| 28 | UINT8 *color_prom = machine().root_device().memregion("proms")->base() + (NUM_PENS * m_game_selected); |
| 29 | 29 | |
| 30 | 30 | for (offs = 0; offs < NUM_PENS ;offs++) |
| 31 | 31 | { |
| r20741 | r20742 | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | | static void do_pen_lookup(running_machine &machine, const _20pacgal_state *state, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 76 | void _20pacgal_state::do_pen_lookup(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 77 | 77 | { |
| 78 | 78 | int y, x; |
| 79 | 79 | pen_t pens[NUM_PENS + NUM_STAR_PENS]; |
| 80 | 80 | |
| 81 | | get_pens(machine, state, pens); |
| 81 | get_pens(pens); |
| 82 | 82 | |
| 83 | 83 | for (y = cliprect.min_y; y <= cliprect.max_y; y++) |
| 84 | 84 | for(x = cliprect.min_x; x <= cliprect.max_x; x++) |
| r20741 | r20742 | |
| 93 | 93 | * |
| 94 | 94 | *************************************/ |
| 95 | 95 | |
| 96 | | static void draw_sprite(running_machine& machine, const _20pacgal_state *state, bitmap_rgb32 &bitmap, int y, int x, |
| 96 | void _20pacgal_state::draw_sprite(bitmap_rgb32 &bitmap, int y, int x, |
| 97 | 97 | UINT8 code, UINT8 color, int flip_y, int flip_x) |
| 98 | 98 | { |
| 99 | 99 | int sy; |
| 100 | 100 | |
| 101 | 101 | offs_t pen_base = (color & 0x1f) << 2; |
| 102 | | pen_base += state->m_sprite_pal_base; |
| 102 | pen_base += m_sprite_pal_base; |
| 103 | 103 | |
| 104 | 104 | if (flip_y) |
| 105 | 105 | y = y + 0x0f; |
| r20741 | r20742 | |
| 122 | 122 | /* address mangling */ |
| 123 | 123 | gfx_offs = (gfx_offs & 0x1f83) | ((gfx_offs & 0x003c) << 1) | ((gfx_offs & 0x0040) >> 4); |
| 124 | 124 | |
| 125 | | data = (state->m_sprite_gfx_ram[gfx_offs + 0] << 24) | |
| 126 | | (state->m_sprite_gfx_ram[gfx_offs + 1] << 16) | |
| 127 | | (state->m_sprite_gfx_ram[gfx_offs + 2] << 8) | |
| 128 | | (state->m_sprite_gfx_ram[gfx_offs + 3] << 0); |
| 125 | data = (m_sprite_gfx_ram[gfx_offs + 0] << 24) | |
| 126 | (m_sprite_gfx_ram[gfx_offs + 1] << 16) | |
| 127 | (m_sprite_gfx_ram[gfx_offs + 2] << 8) | |
| 128 | (m_sprite_gfx_ram[gfx_offs + 3] << 0); |
| 129 | 129 | |
| 130 | 130 | /* for each pixel in the row */ |
| 131 | 131 | for (sx = 0; sx < 0x10; sx++) |
| r20741 | r20742 | |
| 135 | 135 | offs_t pen = (data & 0xc0000000) >> 30; |
| 136 | 136 | UINT8 col; |
| 137 | 137 | |
| 138 | | col = state->m_sprite_color_lookup[pen_base | pen] & 0x0f; |
| 138 | col = m_sprite_color_lookup[pen_base | pen] & 0x0f; |
| 139 | 139 | |
| 140 | 140 | /* pen bits A0-A3 */ |
| 141 | 141 | if (col) |
| r20741 | r20742 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
| 166 | | static void draw_sprites(running_machine& machine,const _20pacgal_state *state, bitmap_rgb32 &bitmap) |
| 166 | void _20pacgal_state::draw_sprites(bitmap_rgb32 &bitmap) |
| 167 | 167 | { |
| 168 | 168 | int offs; |
| 169 | 169 | |
| r20741 | r20742 | |
| 176 | 176 | }; |
| 177 | 177 | int x, y; |
| 178 | 178 | |
| 179 | | UINT8 code = state->m_sprite_ram[offs + 0x000]; |
| 180 | | UINT8 color = state->m_sprite_ram[offs + 0x001]; |
| 179 | UINT8 code = m_sprite_ram[offs + 0x000]; |
| 180 | UINT8 color = m_sprite_ram[offs + 0x001]; |
| 181 | 181 | |
| 182 | | int sx = state->m_sprite_ram[offs + 0x081] - 41 + 0x100*(state->m_sprite_ram[offs + 0x101] & 3); |
| 183 | | int sy = 256 - state->m_sprite_ram[offs + 0x080] + 1; |
| 182 | int sx = m_sprite_ram[offs + 0x081] - 41 + 0x100*(m_sprite_ram[offs + 0x101] & 3); |
| 183 | int sy = 256 - m_sprite_ram[offs + 0x080] + 1; |
| 184 | 184 | |
| 185 | | int flip_x = (state->m_sprite_ram[offs + 0x100] & 0x01) >> 0; |
| 186 | | int flip_y = (state->m_sprite_ram[offs + 0x100] & 0x02) >> 1; |
| 187 | | int size_x = (state->m_sprite_ram[offs + 0x100] & 0x04) >> 2; |
| 188 | | int size_y = (state->m_sprite_ram[offs + 0x100] & 0x08) >> 3; |
| 185 | int flip_x = (m_sprite_ram[offs + 0x100] & 0x01) >> 0; |
| 186 | int flip_y = (m_sprite_ram[offs + 0x100] & 0x02) >> 1; |
| 187 | int size_x = (m_sprite_ram[offs + 0x100] & 0x04) >> 2; |
| 188 | int size_y = (m_sprite_ram[offs + 0x100] & 0x08) >> 3; |
| 189 | 189 | |
| 190 | 190 | sy = sy - (16 * size_y); |
| 191 | 191 | sy = (sy & 0xff) - 32; /* fix wraparound */ |
| 192 | 192 | |
| 193 | 193 | /* only Galaga appears to be effected by the global flip state */ |
| 194 | | if (state->m_game_selected && (state->m_flip[0] & 0x01)) |
| 194 | if (m_game_selected && (m_flip[0] & 0x01)) |
| 195 | 195 | { |
| 196 | 196 | flip_x = !flip_x; |
| 197 | 197 | flip_y = !flip_y; |
| r20741 | r20742 | |
| 199 | 199 | |
| 200 | 200 | for (y = 0; y <= size_y; y++) |
| 201 | 201 | for (x = 0; x <= size_x; x++) |
| 202 | | draw_sprite(machine,state, bitmap, |
| 202 | draw_sprite(bitmap, |
| 203 | 203 | sy + (16 * y), sx + (16 * x), |
| 204 | 204 | code + code_offs[y ^ (size_y * flip_y)][x ^ (size_x * flip_x)], |
| 205 | 205 | color, |
| r20741 | r20742 | |
| 215 | 215 | * |
| 216 | 216 | *************************************/ |
| 217 | 217 | |
| 218 | | static void draw_chars(const _20pacgal_state *state, bitmap_rgb32 &bitmap) |
| 218 | void _20pacgal_state::draw_chars(bitmap_rgb32 &bitmap) |
| 219 | 219 | { |
| 220 | 220 | offs_t offs; |
| 221 | 221 | |
| 222 | | int flip = state->m_flip[0] & 0x01; |
| 222 | int flip = m_flip[0] & 0x01; |
| 223 | 223 | |
| 224 | 224 | /* for each byte in the video RAM */ |
| 225 | 225 | for (offs = 0; offs < 0x400; offs++) |
| r20741 | r20742 | |
| 227 | 227 | int sy; |
| 228 | 228 | int y, x; |
| 229 | 229 | |
| 230 | | UINT8 *gfx = &state->m_char_gfx_ram.target()[state->m_video_ram[0x0000 | offs] << 4]; |
| 231 | | UINT32 color_base = (state->m_video_ram[0x0400 | offs] & 0x3f) << 2; |
| 230 | UINT8 *gfx = &m_char_gfx_ram.target()[m_video_ram[0x0000 | offs] << 4]; |
| 231 | UINT32 color_base = (m_video_ram[0x0400 | offs] & 0x3f) << 2; |
| 232 | 232 | |
| 233 | 233 | /* map the offset to (x, y) character coordinates */ |
| 234 | 234 | if ((offs & 0x03c0) == 0) |
| r20741 | r20742 | |
| 349 | 349 | * |
| 350 | 350 | */ |
| 351 | 351 | |
| 352 | | static void draw_stars(_20pacgal_state *state, bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
| 352 | void _20pacgal_state::draw_stars(bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
| 353 | 353 | { |
| 354 | | if ( (state->m_stars_ctrl[0] >> 5) & 1 ) |
| 354 | if ( (m_stars_ctrl[0] >> 5) & 1 ) |
| 355 | 355 | { |
| 356 | 356 | int clock; |
| 357 | | UINT16 lfsr = state->m_stars_seed[0] + state->m_stars_seed[1]*256; |
| 358 | | UINT8 feedback = (state->m_stars_ctrl[0] >> 6) & 1; |
| 359 | | UINT16 star_seta = (state->m_stars_ctrl[0] >> 3) & 0x01; |
| 360 | | UINT16 star_setb = (state->m_stars_ctrl[0] >> 3) & 0x02; |
| 357 | UINT16 lfsr = m_stars_seed[0] + m_stars_seed[1]*256; |
| 358 | UINT8 feedback = (m_stars_ctrl[0] >> 6) & 1; |
| 359 | UINT16 star_seta = (m_stars_ctrl[0] >> 3) & 0x01; |
| 360 | UINT16 star_setb = (m_stars_ctrl[0] >> 3) & 0x02; |
| 361 | 361 | int cnt = 0; |
| 362 | 362 | |
| 363 | 363 | /* This is a guess based on galaga star sets */ |
| r20741 | r20742 | |
| 409 | 409 | UINT32 _20pacgal_state::screen_update_20pacgal(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 410 | 410 | { |
| 411 | 411 | bitmap.fill(0, cliprect); |
| 412 | | draw_stars(this, bitmap,cliprect); |
| 413 | | draw_chars(this, bitmap); |
| 414 | | draw_sprites(machine(),this, bitmap); |
| 415 | | do_pen_lookup(machine(), this, bitmap, cliprect); |
| 412 | draw_stars(bitmap,cliprect); |
| 413 | draw_chars(bitmap); |
| 414 | draw_sprites(bitmap); |
| 415 | do_pen_lookup(bitmap, cliprect); |
| 416 | 416 | |
| 417 | 417 | return 0; |
| 418 | 418 | } |
trunk/src/mame/video/btime.c
| r20741 | r20742 | |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | | static void draw_chars( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 transparency, UINT8 color, int priority ) |
| 292 | void btime_state::draw_chars( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 transparency, UINT8 color, int priority ) |
| 293 | 293 | { |
| 294 | | btime_state *state = machine.driver_data<btime_state>(); |
| 295 | 294 | offs_t offs; |
| 296 | 295 | |
| 297 | | for (offs = 0; offs < state->m_videoram.bytes(); offs++) |
| 296 | for (offs = 0; offs < m_videoram.bytes(); offs++) |
| 298 | 297 | { |
| 299 | 298 | UINT8 x = 31 - (offs / 32); |
| 300 | 299 | UINT8 y = offs % 32; |
| 301 | 300 | |
| 302 | | UINT16 code = state->m_videoram[offs] + 256 * (state->m_colorram[offs] & 3); |
| 301 | UINT16 code = m_videoram[offs] + 256 * (m_colorram[offs] & 3); |
| 303 | 302 | |
| 304 | 303 | /* check priority */ |
| 305 | 304 | if ((priority != -1) && (priority != ((code >> 7) & 0x01))) |
| 306 | 305 | continue; |
| 307 | 306 | |
| 308 | | if (state->flip_screen()) |
| 307 | if (flip_screen()) |
| 309 | 308 | { |
| 310 | 309 | x = 31 + 16 - x; |
| 311 | 310 | y = 33 - y; |
| 312 | 311 | } |
| 313 | 312 | |
| 314 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 313 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 315 | 314 | code, |
| 316 | 315 | color, |
| 317 | | state->flip_screen(),state->flip_screen(), |
| 316 | flip_screen(),flip_screen(), |
| 318 | 317 | 8*x,8*y, |
| 319 | 318 | transparency ? 0 : -1); |
| 320 | 319 | } |
| 321 | 320 | } |
| 322 | 321 | |
| 323 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 color, |
| 322 | void btime_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 color, |
| 324 | 323 | UINT8 sprite_y_adjust, UINT8 sprite_y_adjust_flip_screen, |
| 325 | 324 | UINT8 *sprite_ram, offs_t interleave ) |
| 326 | 325 | { |
| 327 | | btime_state *state = machine.driver_data<btime_state>(); |
| 328 | 326 | int i; |
| 329 | 327 | offs_t offs; |
| 330 | 328 | |
| r20741 | r20742 | |
| 342 | 340 | flipx = sprite_ram[offs + 0] & 0x04; |
| 343 | 341 | flipy = sprite_ram[offs + 0] & 0x02; |
| 344 | 342 | |
| 345 | | if (state->flip_screen()) |
| 343 | if (flip_screen()) |
| 346 | 344 | { |
| 347 | 345 | x = 240 + 128 - x; |
| 348 | 346 | y = 256 - y + sprite_y_adjust_flip_screen; |
| r20741 | r20742 | |
| 353 | 351 | |
| 354 | 352 | y = y - sprite_y_adjust; |
| 355 | 353 | |
| 356 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 354 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 357 | 355 | sprite_ram[offs + interleave], |
| 358 | 356 | color, |
| 359 | 357 | flipx,flipy, |
| 360 | 358 | x, y,0); |
| 361 | 359 | |
| 362 | | y = y + (state->flip_screen() ? -256 : 256); |
| 360 | y = y + (flip_screen() ? -256 : 256); |
| 363 | 361 | |
| 364 | 362 | // Wrap around |
| 365 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 363 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 366 | 364 | sprite_ram[offs + interleave], |
| 367 | 365 | color, |
| 368 | 366 | flipx,flipy, |
| r20741 | r20742 | |
| 371 | 369 | } |
| 372 | 370 | |
| 373 | 371 | |
| 374 | | static void draw_background( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* tmap, UINT8 color ) |
| 372 | void btime_state::draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* tmap, UINT8 color ) |
| 375 | 373 | { |
| 376 | | btime_state *state = machine.driver_data<btime_state>(); |
| 377 | 374 | int i; |
| 378 | | const UINT8 *gfx = state->memregion("bg_map")->base(); |
| 379 | | int scroll = -(state->m_bnj_scroll2 | ((state->m_bnj_scroll1 & 0x03) << 8)); |
| 375 | const UINT8 *gfx = memregion("bg_map")->base(); |
| 376 | int scroll = -(m_bnj_scroll2 | ((m_bnj_scroll1 & 0x03) << 8)); |
| 380 | 377 | |
| 381 | 378 | // One extra iteration for wrap around |
| 382 | 379 | for (i = 0; i < 5; i++, scroll += 256) |
| r20741 | r20742 | |
| 395 | 392 | int x = 240 - (16 * (offs / 16) + scroll) - 1; |
| 396 | 393 | int y = 16 * (offs % 16); |
| 397 | 394 | |
| 398 | | if (state->flip_screen()) |
| 395 | if (flip_screen()) |
| 399 | 396 | { |
| 400 | 397 | x = 240 + 128 - x; |
| 401 | 398 | y = 256 - y; |
| 402 | 399 | } |
| 403 | 400 | |
| 404 | | drawgfx_opaque(bitmap, cliprect,machine.gfx[2], |
| 401 | drawgfx_opaque(bitmap, cliprect,machine().gfx[2], |
| 405 | 402 | gfx[tileoffset + offs], |
| 406 | 403 | color, |
| 407 | | state->flip_screen(),state->flip_screen(), |
| 404 | flip_screen(),flip_screen(), |
| 408 | 405 | x,y); |
| 409 | 406 | } |
| 410 | 407 | } |
| r20741 | r20742 | |
| 429 | 426 | start = (start + 1) & 0x03; |
| 430 | 427 | } |
| 431 | 428 | |
| 432 | | draw_background(machine(), bitmap, cliprect, m_btime_tilemap, 0); |
| 433 | | draw_chars(machine(), bitmap, cliprect, TRUE, 0, -1); |
| 429 | draw_background(bitmap, cliprect, m_btime_tilemap, 0); |
| 430 | draw_chars(bitmap, cliprect, TRUE, 0, -1); |
| 434 | 431 | } |
| 435 | 432 | else |
| 436 | | draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1); |
| 433 | draw_chars(bitmap, cliprect, FALSE, 0, -1); |
| 437 | 434 | |
| 438 | | draw_sprites(machine(), bitmap, cliprect, 0, 1, 0, m_videoram, 0x20); |
| 435 | draw_sprites(bitmap, cliprect, 0, 1, 0, m_videoram, 0x20); |
| 439 | 436 | |
| 440 | 437 | return 0; |
| 441 | 438 | } |
| r20741 | r20742 | |
| 443 | 440 | |
| 444 | 441 | UINT32 btime_state::screen_update_eggs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 445 | 442 | { |
| 446 | | draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1); |
| 447 | | draw_sprites(machine(), bitmap, cliprect, 0, 0, 0, m_videoram, 0x20); |
| 443 | draw_chars(bitmap, cliprect, FALSE, 0, -1); |
| 444 | draw_sprites(bitmap, cliprect, 0, 0, 0, m_videoram, 0x20); |
| 448 | 445 | |
| 449 | 446 | return 0; |
| 450 | 447 | } |
| r20741 | r20742 | |
| 452 | 449 | |
| 453 | 450 | UINT32 btime_state::screen_update_lnc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 454 | 451 | { |
| 455 | | draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1); |
| 456 | | draw_sprites(machine(), bitmap, cliprect, 0, 1, 2, m_videoram, 0x20); |
| 452 | draw_chars(bitmap, cliprect, FALSE, 0, -1); |
| 453 | draw_sprites(bitmap, cliprect, 0, 1, 2, m_videoram, 0x20); |
| 457 | 454 | |
| 458 | 455 | return 0; |
| 459 | 456 | } |
| r20741 | r20742 | |
| 463 | 460 | { |
| 464 | 461 | if (m_bnj_scroll1 & 0x04) |
| 465 | 462 | { |
| 466 | | draw_background(machine(), bitmap, cliprect, m_zoar_scrollram, m_btime_palette); |
| 467 | | draw_chars(machine(), bitmap, cliprect, TRUE, m_btime_palette + 1, -1); |
| 463 | draw_background(bitmap, cliprect, m_zoar_scrollram, m_btime_palette); |
| 464 | draw_chars(bitmap, cliprect, TRUE, m_btime_palette + 1, -1); |
| 468 | 465 | } |
| 469 | 466 | else |
| 470 | | draw_chars(machine(), bitmap, cliprect, FALSE, m_btime_palette + 1, -1); |
| 467 | draw_chars(bitmap, cliprect, FALSE, m_btime_palette + 1, -1); |
| 471 | 468 | |
| 472 | 469 | /* The order is important for correct priorities */ |
| 473 | | draw_sprites(machine(), bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram + 0x1f, 0x20); |
| 474 | | draw_sprites(machine(), bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram, 0x20); |
| 470 | draw_sprites(bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram + 0x1f, 0x20); |
| 471 | draw_sprites(bitmap, cliprect, m_btime_palette + 1, 1, 2, m_videoram, 0x20); |
| 475 | 472 | |
| 476 | 473 | return 0; |
| 477 | 474 | } |
| r20741 | r20742 | |
| 512 | 509 | |
| 513 | 510 | /* copy the low priority characters followed by the sprites |
| 514 | 511 | then the high priority characters */ |
| 515 | | draw_chars(machine(), bitmap, cliprect, TRUE, 0, 1); |
| 516 | | draw_sprites(machine(), bitmap, cliprect, 0, 0, 0, m_videoram, 0x20); |
| 517 | | draw_chars(machine(), bitmap, cliprect, TRUE, 0, 0); |
| 512 | draw_chars(bitmap, cliprect, TRUE, 0, 1); |
| 513 | draw_sprites(bitmap, cliprect, 0, 0, 0, m_videoram, 0x20); |
| 514 | draw_chars(bitmap, cliprect, TRUE, 0, 0); |
| 518 | 515 | } |
| 519 | 516 | else |
| 520 | 517 | { |
| 521 | | draw_chars(machine(), bitmap, cliprect, FALSE, 0, -1); |
| 522 | | draw_sprites(machine(), bitmap, cliprect, 0, 0, 0, m_videoram, 0x20); |
| 518 | draw_chars(bitmap, cliprect, FALSE, 0, -1); |
| 519 | draw_sprites(bitmap, cliprect, 0, 0, 0, m_videoram, 0x20); |
| 523 | 520 | } |
| 524 | 521 | |
| 525 | 522 | return 0; |
| r20741 | r20742 | |
| 550 | 547 | 8*sx,8*sy); |
| 551 | 548 | } |
| 552 | 549 | |
| 553 | | draw_chars(machine(), bitmap, cliprect, TRUE, 0, -1); |
| 554 | | draw_sprites(machine(), bitmap, cliprect, 0, 1, 0, m_videoram, 0x20); |
| 550 | draw_chars(bitmap, cliprect, TRUE, 0, -1); |
| 551 | draw_sprites(bitmap, cliprect, 0, 1, 0, m_videoram, 0x20); |
| 555 | 552 | |
| 556 | 553 | return 0; |
| 557 | 554 | } |
| r20741 | r20742 | |
| 559 | 556 | |
| 560 | 557 | UINT32 btime_state::screen_update_disco(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 561 | 558 | { |
| 562 | | draw_chars(machine(), bitmap, cliprect, FALSE, m_btime_palette, -1); |
| 563 | | draw_sprites(machine(), bitmap, cliprect, m_btime_palette, 0, 0, m_spriteram, 1); |
| 559 | draw_chars(bitmap, cliprect, FALSE, m_btime_palette, -1); |
| 560 | draw_sprites(bitmap, cliprect, m_btime_palette, 0, 0, m_spriteram, 1); |
| 564 | 561 | |
| 565 | 562 | return 0; |
| 566 | 563 | } |
trunk/src/mame/video/bbusters.c
| r20741 | r20742 | |
| 105 | 105 | else if (dy&0x40) code+=32; \ |
| 106 | 106 | else if (dx&0x40) code+=16 |
| 107 | 107 | |
| 108 | | INLINE const UINT8 *get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int dy, int block) |
| 108 | inline const UINT8 *bbusters_state::get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int dy, int block) |
| 109 | 109 | { |
| 110 | 110 | int code=0; |
| 111 | 111 | |
| r20741 | r20742 | |
| 143 | 143 | return gfx->get_data((sprite+code) % gfx->elements()) + ((dy%16) * gfx->rowbytes()); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | | static void bbusters_draw_block(running_machine &machine, bitmap_ind16 &dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block) |
| 146 | void bbusters_state::bbusters_draw_block(bitmap_ind16 &dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block) |
| 147 | 147 | { |
| 148 | | bbusters_state *state = machine.driver_data<bbusters_state>(); |
| 149 | | gfx_element *gfx = machine.gfx[bank]; |
| 148 | gfx_element *gfx = machine().gfx[bank]; |
| 150 | 149 | pen_t pen_base = gfx->colorbase() + gfx->granularity() * (color % gfx->colors()); |
| 151 | | UINT32 xinc=(state->m_scale_line_count * 0x10000 ) / size; |
| 150 | UINT32 xinc=(m_scale_line_count * 0x10000 ) / size; |
| 152 | 151 | UINT8 pixel; |
| 153 | 152 | int x_index; |
| 154 | 153 | int dy=y; |
| 155 | | int sx, ex = state->m_scale_line_count; |
| 154 | int sx, ex = m_scale_line_count; |
| 156 | 155 | |
| 157 | | while (state->m_scale_line_count) { |
| 156 | while (m_scale_line_count) { |
| 158 | 157 | if (dy>=16 && dy<240) { |
| 159 | 158 | UINT16 *destline = &dest.pix16(dy); |
| 160 | | UINT8 srcline=*state->m_scale_table_ptr; |
| 159 | UINT8 srcline=*m_scale_table_ptr; |
| 161 | 160 | const UINT8 *srcptr=0; |
| 162 | 161 | |
| 163 | 162 | if (!flipy) |
| r20741 | r20742 | |
| 184 | 183 | } |
| 185 | 184 | |
| 186 | 185 | dy++; |
| 187 | | state->m_scale_table_ptr--; |
| 188 | | state->m_scale_line_count--; |
| 186 | m_scale_table_ptr--; |
| 187 | m_scale_line_count--; |
| 189 | 188 | } |
| 190 | 189 | } |
| 191 | 190 | |
| 192 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const UINT16 *source, int bank, int colval, int colmask) |
| 191 | void bbusters_state::draw_sprites(bitmap_ind16 &bitmap, const UINT16 *source, int bank, int colval, int colmask) |
| 193 | 192 | { |
| 194 | | bbusters_state *state = machine.driver_data<bbusters_state>(); |
| 195 | | const UINT8 *scale_table=state->memregion("user1")->base(); |
| 193 | const UINT8 *scale_table=memregion("user1")->base(); |
| 196 | 194 | int offs; |
| 197 | 195 | |
| 198 | 196 | for (offs = 0;offs <0x800 ;offs += 4) { |
| r20741 | r20742 | |
| 237 | 235 | switch ((source[offs+0]>>8)&0x3) { |
| 238 | 236 | case 0: |
| 239 | 237 | scale=source[offs+0]&0x7; |
| 240 | | state->m_scale_table_ptr = scale_table+0x387f+(0x80*scale); |
| 241 | | state->m_scale_line_count = 0x10-scale; |
| 242 | | bbusters_draw_block(machine,bitmap,x,y,16,fx,fy,sprite,colour,bank,block); |
| 238 | m_scale_table_ptr = scale_table+0x387f+(0x80*scale); |
| 239 | m_scale_line_count = 0x10-scale; |
| 240 | bbusters_draw_block(bitmap,x,y,16,fx,fy,sprite,colour,bank,block); |
| 243 | 241 | break; |
| 244 | 242 | case 1: /* 2 x 2 */ |
| 245 | 243 | scale=source[offs+0]&0xf; |
| 246 | | state->m_scale_table_ptr = scale_table+0x707f+(0x80*scale); |
| 247 | | state->m_scale_line_count = 0x20-scale; |
| 248 | | bbusters_draw_block(machine,bitmap,x,y,32,fx,fy,sprite,colour,bank,block); |
| 244 | m_scale_table_ptr = scale_table+0x707f+(0x80*scale); |
| 245 | m_scale_line_count = 0x20-scale; |
| 246 | bbusters_draw_block(bitmap,x,y,32,fx,fy,sprite,colour,bank,block); |
| 249 | 247 | break; |
| 250 | 248 | case 2: /* 64 by 64 block (2 x 2) x 2 */ |
| 251 | 249 | scale=source[offs+0]&0x1f; |
| 252 | | state->m_scale_table_ptr = scale_table+0xa07f+(0x80*scale); |
| 253 | | state->m_scale_line_count = 0x40-scale; |
| 254 | | bbusters_draw_block(machine,bitmap,x,y,64,fx,fy,sprite,colour,bank,block); |
| 250 | m_scale_table_ptr = scale_table+0xa07f+(0x80*scale); |
| 251 | m_scale_line_count = 0x40-scale; |
| 252 | bbusters_draw_block(bitmap,x,y,64,fx,fy,sprite,colour,bank,block); |
| 255 | 253 | break; |
| 256 | 254 | case 3: /* 2 x 2 x 2 x 2 */ |
| 257 | 255 | scale=source[offs+0]&0x3f; |
| 258 | | state->m_scale_table_ptr = scale_table+0xc07f+(0x80*scale); |
| 259 | | state->m_scale_line_count = 0x80-scale; |
| 260 | | bbusters_draw_block(machine,bitmap,x,y,128,fx,fy,sprite,colour,bank,block); |
| 256 | m_scale_table_ptr = scale_table+0xc07f+(0x80*scale); |
| 257 | m_scale_line_count = 0x80-scale; |
| 258 | bbusters_draw_block(bitmap,x,y,128,fx,fy,sprite,colour,bank,block); |
| 261 | 259 | break; |
| 262 | 260 | } |
| 263 | 261 | } |
| r20741 | r20742 | |
| 275 | 273 | m_pf2_tilemap->draw(bitmap, cliprect, 0, 0); |
| 276 | 274 | //draw_sprites(machine(), bitmap, m_spriteram2->buffer(), 2, 0x8, 0x8); |
| 277 | 275 | m_pf1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 278 | | draw_sprites(machine(), bitmap, m_spriteram2->buffer(), 2, 0, 0); |
| 279 | | draw_sprites(machine(), bitmap, m_spriteram->buffer(), 1, 0, 0); |
| 276 | draw_sprites(bitmap, m_spriteram2->buffer(), 2, 0, 0); |
| 277 | draw_sprites(bitmap, m_spriteram->buffer(), 1, 0, 0); |
| 280 | 278 | m_fix_tilemap->draw(bitmap, cliprect, 0, 0); |
| 281 | 279 | return 0; |
| 282 | 280 | } |
| r20741 | r20742 | |
| 290 | 288 | |
| 291 | 289 | m_pf2_tilemap->draw(bitmap, cliprect, 0, 0); |
| 292 | 290 | m_pf1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 293 | | draw_sprites(machine(), bitmap, m_spriteram->buffer(), 1, 0, 0); |
| 291 | draw_sprites(bitmap, m_spriteram->buffer(), 1, 0, 0); |
| 294 | 292 | m_fix_tilemap->draw(bitmap, cliprect, 0, 0); |
| 295 | 293 | return 0; |
| 296 | 294 | } |
trunk/src/mame/video/alpha68k.c
| r20741 | r20742 | |
| 8 | 8 | #include "includes/alpha68k.h" |
| 9 | 9 | |
| 10 | 10 | |
| 11 | | void alpha68k_flipscreen_w( running_machine &machine, int flip ) |
| 11 | void alpha68k_state::alpha68k_flipscreen_w( int flip ) |
| 12 | 12 | { |
| 13 | | alpha68k_state *state = machine.driver_data<alpha68k_state>(); |
| 14 | | state->m_flipscreen = flip; |
| 13 | m_flipscreen = flip; |
| 15 | 14 | } |
| 16 | 15 | |
| 17 | | void alpha68k_V_video_bank_w( running_machine &machine, int bank ) |
| 16 | void alpha68k_state::alpha68k_V_video_bank_w( int bank ) |
| 18 | 17 | { |
| 19 | | alpha68k_state *state = machine.driver_data<alpha68k_state>(); |
| 20 | | state->m_bank_base = bank & 0xf; |
| 18 | m_bank_base = bank & 0xf; |
| 21 | 19 | } |
| 22 | 20 | |
| 23 | 21 | WRITE16_MEMBER(alpha68k_state::alpha68k_paletteram_w) |
| r20741 | r20742 | |
| 70 | 68 | /******************************************************************************/ |
| 71 | 69 | |
| 72 | 70 | //AT |
| 73 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e ) |
| 71 | void alpha68k_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e ) |
| 74 | 72 | { |
| 75 | | alpha68k_state *state = machine.driver_data<alpha68k_state>(); |
| 76 | | UINT16 *spriteram = state->m_spriteram; |
| 73 | UINT16 *spriteram = m_spriteram; |
| 77 | 74 | int offs, mx, my, color, tile, fx, fy, i; |
| 78 | 75 | |
| 79 | 76 | for (offs = s; offs < e; offs += 0x40) |
| r20741 | r20742 | |
| 85 | 82 | if (j == 0 && s == 0x7c0) |
| 86 | 83 | my++; |
| 87 | 84 | //ZT |
| 88 | | if (state->m_flipscreen) |
| 85 | if (m_flipscreen) |
| 89 | 86 | { |
| 90 | 87 | mx = 240 - mx; |
| 91 | 88 | my = 240 - my; |
| r20741 | r20742 | |
| 100 | 97 | fx = tile & 0x4000; |
| 101 | 98 | tile &= 0x3fff; |
| 102 | 99 | |
| 103 | | if (state->m_flipscreen) |
| 100 | if (m_flipscreen) |
| 104 | 101 | { |
| 105 | 102 | if (fx) fx = 0; else fx = 1; |
| 106 | 103 | if (fy) fy = 0; else fy = 1; |
| 107 | 104 | } |
| 108 | 105 | |
| 109 | 106 | if (color) |
| 110 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 107 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 111 | 108 | tile, |
| 112 | 109 | color, |
| 113 | 110 | fx,fy, |
| 114 | 111 | mx,my,0); |
| 115 | 112 | |
| 116 | | if (state->m_flipscreen) |
| 113 | if (m_flipscreen) |
| 117 | 114 | my = (my - 16) & 0x1ff; |
| 118 | 115 | else |
| 119 | 116 | my = (my + 16) & 0x1ff; |
| r20741 | r20742 | |
| 133 | 130 | |
| 134 | 131 | bitmap.fill(2047, cliprect); |
| 135 | 132 | //AT |
| 136 | | draw_sprites(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800); |
| 137 | | draw_sprites(machine(), bitmap, cliprect, 1, 0x0000, 0x0800); |
| 138 | | draw_sprites(machine(), bitmap, cliprect, 2, 0x0000, 0x0800); |
| 139 | | draw_sprites(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0); |
| 133 | draw_sprites(bitmap, cliprect, 0, 0x07c0, 0x0800); |
| 134 | draw_sprites(bitmap, cliprect, 1, 0x0000, 0x0800); |
| 135 | draw_sprites(bitmap, cliprect, 2, 0x0000, 0x0800); |
| 136 | draw_sprites(bitmap, cliprect, 0, 0x0000, 0x07c0); |
| 140 | 137 | //ZT |
| 141 | 138 | m_fix_tilemap->draw(bitmap, cliprect, 0, 0); |
| 142 | 139 | return 0; |
| r20741 | r20742 | |
| 213 | 210 | } |
| 214 | 211 | } |
| 215 | 212 | |
| 216 | | static void draw_sprites_V( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e, int fx_mask, int fy_mask, int sprite_mask ) |
| 213 | void alpha68k_state::draw_sprites_V( bitmap_ind16 &bitmap, const rectangle &cliprect, int j, int s, int e, int fx_mask, int fy_mask, int sprite_mask ) |
| 217 | 214 | { |
| 218 | | alpha68k_state *state = machine.driver_data<alpha68k_state>(); |
| 219 | | UINT16 *spriteram = state->m_spriteram; |
| 215 | UINT16 *spriteram = m_spriteram; |
| 220 | 216 | int offs, mx, my, color, tile, fx, fy, i; |
| 221 | 217 | |
| 222 | 218 | for (offs = s; offs < e; offs += 0x40) |
| r20741 | r20742 | |
| 229 | 225 | if (j == 0 && s == 0x7c0) |
| 230 | 226 | my++; |
| 231 | 227 | //ZT |
| 232 | | if (state->m_flipscreen) |
| 228 | if (m_flipscreen) |
| 233 | 229 | { |
| 234 | 230 | mx = 240 - mx; |
| 235 | 231 | my = 240 - my; |
| r20741 | r20742 | |
| 246 | 242 | if (tile > 0x4fff) |
| 247 | 243 | continue; |
| 248 | 244 | |
| 249 | | if (state->m_flipscreen) |
| 245 | if (m_flipscreen) |
| 250 | 246 | { |
| 251 | 247 | if (fx) fx = 0; else fx = 1; |
| 252 | 248 | if (fy) fy = 0; else fy = 1; |
| 253 | 249 | } |
| 254 | 250 | |
| 255 | 251 | if (color) |
| 256 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 252 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 257 | 253 | tile, |
| 258 | 254 | color, |
| 259 | 255 | fx,fy, |
| 260 | 256 | mx,my,0); |
| 261 | 257 | |
| 262 | | if (state->m_flipscreen) |
| 258 | if (m_flipscreen) |
| 263 | 259 | my = (my - 16) & 0x1ff; |
| 264 | 260 | else |
| 265 | 261 | my = (my + 16) & 0x1ff; |
| r20741 | r20742 | |
| 282 | 278 | /* This appears to be correct priority */ |
| 283 | 279 | if (m_microcontroller_id == 0x8814) /* Sky Adventure */ |
| 284 | 280 | { |
| 285 | | draw_sprites_V(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800, 0, 0x8000, 0x7fff); |
| 286 | | draw_sprites_V(machine(), bitmap, cliprect, 1, 0x0000, 0x0800, 0, 0x8000, 0x7fff); |
| 281 | draw_sprites_V(bitmap, cliprect, 0, 0x07c0, 0x0800, 0, 0x8000, 0x7fff); |
| 282 | draw_sprites_V(bitmap, cliprect, 1, 0x0000, 0x0800, 0, 0x8000, 0x7fff); |
| 287 | 283 | //AT: *KLUDGE* fixes priest priority in level 1(could be a game bug) |
| 288 | 284 | if (spriteram[0x1bde] == 0x24 && (spriteram[0x1bdf] >> 8) == 0x3b) |
| 289 | 285 | { |
| 290 | | draw_sprites_V(machine(), bitmap, cliprect, 2, 0x03c0, 0x0800, 0, 0x8000, 0x7fff); |
| 291 | | draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x03c0, 0, 0x8000, 0x7fff); |
| 286 | draw_sprites_V(bitmap, cliprect, 2, 0x03c0, 0x0800, 0, 0x8000, 0x7fff); |
| 287 | draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x03c0, 0, 0x8000, 0x7fff); |
| 292 | 288 | } |
| 293 | 289 | else |
| 294 | | draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x0800, 0, 0x8000, 0x7fff); |
| 290 | draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x0800, 0, 0x8000, 0x7fff); |
| 295 | 291 | |
| 296 | | draw_sprites_V(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0, 0, 0x8000, 0x7fff); |
| 292 | draw_sprites_V(bitmap, cliprect, 0, 0x0000, 0x07c0, 0, 0x8000, 0x7fff); |
| 297 | 293 | } |
| 298 | 294 | else /* gangwars */ |
| 299 | 295 | { |
| 300 | | draw_sprites_V(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800, 0x8000, 0, 0x7fff); |
| 301 | | draw_sprites_V(machine(), bitmap, cliprect, 1, 0x0000, 0x0800, 0x8000, 0, 0x7fff); |
| 302 | | draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x0800, 0x8000, 0, 0x7fff); |
| 303 | | draw_sprites_V(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0, 0x8000, 0, 0x7fff); |
| 296 | draw_sprites_V(bitmap, cliprect, 0, 0x07c0, 0x0800, 0x8000, 0, 0x7fff); |
| 297 | draw_sprites_V(bitmap, cliprect, 1, 0x0000, 0x0800, 0x8000, 0, 0x7fff); |
| 298 | draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x0800, 0x8000, 0, 0x7fff); |
| 299 | draw_sprites_V(bitmap, cliprect, 0, 0x0000, 0x07c0, 0x8000, 0, 0x7fff); |
| 304 | 300 | } |
| 305 | 301 | |
| 306 | 302 | m_fix_tilemap->draw(bitmap, cliprect, 0, 0); |
| r20741 | r20742 | |
| 318 | 314 | bitmap.fill(4095, cliprect); |
| 319 | 315 | |
| 320 | 316 | /* This appears to be correct priority */ |
| 321 | | draw_sprites_V(machine(), bitmap, cliprect, 0, 0x07c0, 0x0800, 0x4000, 0x8000, 0x3fff); |
| 322 | | draw_sprites_V(machine(), bitmap, cliprect, 1, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff); |
| 323 | | draw_sprites_V(machine(), bitmap, cliprect, 2, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff); |
| 324 | | draw_sprites_V(machine(), bitmap, cliprect, 0, 0x0000, 0x07c0, 0x4000, 0x8000, 0x3fff); |
| 317 | draw_sprites_V(bitmap, cliprect, 0, 0x07c0, 0x0800, 0x4000, 0x8000, 0x3fff); |
| 318 | draw_sprites_V(bitmap, cliprect, 1, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff); |
| 319 | draw_sprites_V(bitmap, cliprect, 2, 0x0000, 0x0800, 0x4000, 0x8000, 0x3fff); |
| 320 | draw_sprites_V(bitmap, cliprect, 0, 0x0000, 0x07c0, 0x4000, 0x8000, 0x3fff); |
| 325 | 321 | |
| 326 | 322 | m_fix_tilemap->draw(bitmap, cliprect, 0, 0); |
| 327 | 323 | return 0; |
| r20741 | r20742 | |
| 329 | 325 | |
| 330 | 326 | /******************************************************************************/ |
| 331 | 327 | //AT |
| 332 | | static void draw_sprites_I( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d, int yshift ) |
| 328 | void alpha68k_state::draw_sprites_I( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d, int yshift ) |
| 333 | 329 | { |
| 334 | | alpha68k_state *state = machine.driver_data<alpha68k_state>(); |
| 335 | | UINT16 *spriteram = state->m_spriteram; |
| 330 | UINT16 *spriteram = m_spriteram; |
| 336 | 331 | int data, offs, mx, my, tile, color, fy, i; |
| 337 | | UINT8 *color_prom = state->memregion("user1")->base(); |
| 338 | | gfx_element *gfx = machine.gfx[0]; |
| 332 | UINT8 *color_prom = memregion("user1")->base(); |
| 333 | gfx_element *gfx = machine().gfx[0]; |
| 339 | 334 | |
| 340 | 335 | for (offs = 0; offs < 0x400; offs += 0x20) |
| 341 | 336 | { |
| r20741 | r20742 | |
| 364 | 359 | bitmap.fill(get_black_pen(machine()), cliprect); |
| 365 | 360 | |
| 366 | 361 | /* This appears to be correct priority */ |
| 367 | | draw_sprites_I(machine(), bitmap, cliprect, 2, 0x0800, yshift); |
| 368 | | draw_sprites_I(machine(), bitmap, cliprect, 3, 0x0c00, yshift); |
| 369 | | draw_sprites_I(machine(), bitmap, cliprect, 1, 0x0400, yshift); |
| 362 | draw_sprites_I(bitmap, cliprect, 2, 0x0800, yshift); |
| 363 | draw_sprites_I(bitmap, cliprect, 3, 0x0c00, yshift); |
| 364 | draw_sprites_I(bitmap, cliprect, 1, 0x0400, yshift); |
| 370 | 365 | return 0; |
| 371 | 366 | } |
| 372 | 367 | //ZT |
| r20741 | r20742 | |
| 428 | 423 | } |
| 429 | 424 | } |
| 430 | 425 | |
| 431 | | static void kyros_video_banking(int *bank, int data) |
| 426 | void alpha68k_state::kyros_video_banking(int *bank, int data) |
| 432 | 427 | { |
| 433 | 428 | *bank = (data >> 13 & 4) | (data >> 10 & 3); |
| 434 | 429 | } |
| 435 | 430 | |
| 436 | | static void jongbou_video_banking(int *bank, int data) |
| 431 | void alpha68k_state::jongbou_video_banking(int *bank, int data) |
| 437 | 432 | { |
| 438 | 433 | *bank = (data >> 11 & 4) | (data >> 10 & 3); |
| 439 | 434 | } |
| 440 | 435 | |
| 441 | | static void kyros_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d ) |
| 436 | void alpha68k_state::kyros_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d ) |
| 442 | 437 | { |
| 443 | | alpha68k_state *state = machine.driver_data<alpha68k_state>(); |
| 444 | | UINT16 *spriteram = state->m_spriteram; |
| 438 | UINT16 *spriteram = m_spriteram; |
| 445 | 439 | int offs, mx, my, color, tile, i, bank, fy, fx; |
| 446 | 440 | int data; |
| 447 | | UINT8 *color_prom = state->memregion("user1")->base(); |
| 441 | UINT8 *color_prom = memregion("user1")->base(); |
| 448 | 442 | |
| 449 | 443 | //AT |
| 450 | 444 | for (offs = 0; offs < 0x400; offs += 0x20) |
| r20741 | r20742 | |
| 453 | 447 | my = -(mx >> 8) & 0xff; |
| 454 | 448 | mx &= 0xff; |
| 455 | 449 | |
| 456 | | if (state->m_flipscreen) |
| 450 | if (m_flipscreen) |
| 457 | 451 | my = 249 - my; |
| 458 | 452 | |
| 459 | 453 | for (i = 0; i < 0x20; i++) |
| r20741 | r20742 | |
| 467 | 461 | fy = data & 0x1000; |
| 468 | 462 | fx = 0; |
| 469 | 463 | |
| 470 | | if(state->m_flipscreen) |
| 464 | if(m_flipscreen) |
| 471 | 465 | { |
| 472 | 466 | if (fy) fy = 0; else fy = 1; |
| 473 | 467 | fx = 1; |
| 474 | 468 | } |
| 475 | 469 | |
| 476 | 470 | tile = (data >> 3 & 0x400) | (data & 0x3ff); |
| 477 | | if (state->m_game_id == ALPHA68K_KYROS) |
| 471 | if (m_game_id == ALPHA68K_KYROS) |
| 478 | 472 | kyros_video_banking(&bank, data); |
| 479 | 473 | else |
| 480 | 474 | jongbou_video_banking(&bank, data); |
| 481 | 475 | |
| 482 | | drawgfx_transpen(bitmap, cliprect, machine.gfx[bank], tile, color, fx, fy, mx, my, 0); |
| 476 | drawgfx_transpen(bitmap, cliprect, machine().gfx[bank], tile, color, fx, fy, mx, my, 0); |
| 483 | 477 | } |
| 484 | 478 | } |
| 485 | 479 | //ZT |
| 486 | | if (state->m_flipscreen) |
| 480 | if (m_flipscreen) |
| 487 | 481 | my = (my - 8) & 0xff; |
| 488 | 482 | else |
| 489 | 483 | my = (my + 8) & 0xff; |
| r20741 | r20742 | |
| 496 | 490 | colortable_entry_set_value(machine().colortable, 0x100, *m_videoram & 0xff); |
| 497 | 491 | bitmap.fill(0x100, cliprect); //AT |
| 498 | 492 | |
| 499 | | kyros_draw_sprites(machine(), bitmap, cliprect, 2, 0x0800); |
| 500 | | kyros_draw_sprites(machine(), bitmap, cliprect, 3, 0x0c00); |
| 501 | | kyros_draw_sprites(machine(), bitmap, cliprect, 1, 0x0400); |
| 493 | kyros_draw_sprites(bitmap, cliprect, 2, 0x0800); |
| 494 | kyros_draw_sprites(bitmap, cliprect, 3, 0x0c00); |
| 495 | kyros_draw_sprites(bitmap, cliprect, 1, 0x0400); |
| 502 | 496 | return 0; |
| 503 | 497 | } |
| 504 | 498 | |
| 505 | 499 | /******************************************************************************/ |
| 506 | 500 | |
| 507 | | static void sstingry_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d ) |
| 501 | void alpha68k_state::sstingry_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d ) |
| 508 | 502 | { |
| 509 | 503 | //AT |
| 510 | | alpha68k_state *state = machine.driver_data<alpha68k_state>(); |
| 511 | | UINT16 *spriteram = state->m_spriteram; |
| 504 | UINT16 *spriteram = m_spriteram; |
| 512 | 505 | int data, offs, mx, my, color, tile, i, bank, fy, fx; |
| 513 | 506 | |
| 514 | 507 | for (offs = 0; offs < 0x400; offs += 0x20) |
| r20741 | r20742 | |
| 519 | 512 | if (mx > 0xf8) |
| 520 | 513 | mx -= 0x100; |
| 521 | 514 | |
| 522 | | if (state->m_flipscreen) |
| 515 | if (m_flipscreen) |
| 523 | 516 | my = 249 - my; |
| 524 | 517 | |
| 525 | 518 | for (i = 0; i < 0x20; i++) |
| r20741 | r20742 | |
| 530 | 523 | fy = data & 0x1000; |
| 531 | 524 | fx = 0; |
| 532 | 525 | |
| 533 | | if(state->m_flipscreen) |
| 526 | if(m_flipscreen) |
| 534 | 527 | { |
| 535 | 528 | if (fy) fy = 0; else fy = 1; |
| 536 | 529 | fx = 1; |
| r20741 | r20742 | |
| 539 | 532 | color = (data >> 7 & 0x18) | (data >> 13 & 7); |
| 540 | 533 | tile = data & 0x3ff; |
| 541 | 534 | bank = data >> 10 & 3; |
| 542 | | drawgfx_transpen(bitmap, cliprect, machine.gfx[bank], tile, color, fx, fy, mx, my, 0); |
| 535 | drawgfx_transpen(bitmap, cliprect, machine().gfx[bank], tile, color, fx, fy, mx, my, 0); |
| 543 | 536 | } |
| 544 | 537 | //ZT |
| 545 | | if(state->m_flipscreen) |
| 538 | if(m_flipscreen) |
| 546 | 539 | my = (my - 8) & 0xff; |
| 547 | 540 | else |
| 548 | 541 | my = (my + 8) & 0xff; |
| r20741 | r20742 | |
| 555 | 548 | colortable_entry_set_value(machine().colortable, 0x100, *m_videoram & 0xff); |
| 556 | 549 | bitmap.fill(0x100, cliprect); //AT |
| 557 | 550 | |
| 558 | | sstingry_draw_sprites(machine(), bitmap, cliprect, 2, 0x0800); |
| 559 | | sstingry_draw_sprites(machine(), bitmap, cliprect, 3, 0x0c00); |
| 560 | | sstingry_draw_sprites(machine(), bitmap, cliprect, 1, 0x0400); |
| 551 | sstingry_draw_sprites(bitmap, cliprect, 2, 0x0800); |
| 552 | sstingry_draw_sprites(bitmap, cliprect, 3, 0x0c00); |
| 553 | sstingry_draw_sprites(bitmap, cliprect, 1, 0x0400); |
| 561 | 554 | return 0; |
| 562 | 555 | } |
trunk/src/mame/video/atarisy1.c
| r20741 | r20742 | |
| 72 | 72 | 8*8 /* every sprite takes 8 consecutive bytes */ |
| 73 | 73 | }; |
| 74 | 74 | |
| 75 | | |
| 76 | | |
| 77 | 75 | /************************************* |
| 78 | 76 | * |
| 79 | | * Prototypes |
| 80 | | * |
| 81 | | *************************************/ |
| 82 | | |
| 83 | | static void update_timers(running_machine &machine, int scanline); |
| 84 | | static void decode_gfx(running_machine &machine, UINT16 *pflookup, UINT16 *molookup); |
| 85 | | static int get_bank(running_machine &machine, UINT8 prom1, UINT8 prom2, int bpp); |
| 86 | | |
| 87 | | |
| 88 | | |
| 89 | | /************************************* |
| 90 | | * |
| 91 | 77 | * Tilemap callbacks |
| 92 | 78 | * |
| 93 | 79 | *************************************/ |
| r20741 | r20742 | |
| 165 | 151 | int i, size; |
| 166 | 152 | |
| 167 | 153 | /* first decode the graphics */ |
| 168 | | decode_gfx(machine(), m_playfield_lookup, motable); |
| 154 | decode_gfx(m_playfield_lookup, motable); |
| 169 | 155 | |
| 170 | 156 | /* initialize the playfield */ |
| 171 | 157 | m_playfield_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(atarisy1_state::get_playfield_tile_info),this), TILEMAP_SCAN_ROWS, 8,8, 64,64); |
| r20741 | r20742 | |
| 233 | 219 | |
| 234 | 220 | /* motion object bank select */ |
| 235 | 221 | atarimo_set_bank(0, (newselect >> 3) & 7); |
| 236 | | update_timers(space.machine(), scanline); |
| 222 | state->update_timers(scanline); |
| 237 | 223 | |
| 238 | 224 | /* playfield bank select */ |
| 239 | 225 | if (diff & 0x0004) |
| r20741 | r20742 | |
| 344 | 330 | |
| 345 | 331 | WRITE16_HANDLER( atarisy1_spriteram_w ) |
| 346 | 332 | { |
| 333 | atarisy1_state *state = space.machine().driver_data<atarisy1_state>(); |
| 347 | 334 | int active_bank = atarimo_get_bank(0); |
| 348 | 335 | int oldword = atarimo_0_spriteram_r(space, offset, mem_mask); |
| 349 | 336 | int newword = oldword; |
| r20741 | r20742 | |
| 358 | 345 | { |
| 359 | 346 | /* if the timer is in the active bank, update the display list */ |
| 360 | 347 | atarimo_0_spriteram_w(space, offset, data, 0xffff); |
| 361 | | update_timers(space.machine(), space.machine().primary_screen->vpos()); |
| 348 | state->update_timers(space.machine().primary_screen->vpos()); |
| 362 | 349 | } |
| 363 | 350 | |
| 364 | 351 | /* if we're about to modify data in the active sprite bank, make sure the video is up-to-date */ |
| r20741 | r20742 | |
| 402 | 389 | |
| 403 | 390 | /* determine the time of the next one */ |
| 404 | 391 | m_next_timer_scanline = -1; |
| 405 | | update_timers(machine(), scanline); |
| 392 | update_timers(scanline); |
| 406 | 393 | } |
| 407 | 394 | |
| 408 | 395 | |
| r20741 | r20742 | |
| 427 | 414 | * |
| 428 | 415 | *************************************/ |
| 429 | 416 | |
| 430 | | static void update_timers(running_machine &machine, int scanline) |
| 417 | void atarisy1_state::update_timers(int scanline) |
| 431 | 418 | { |
| 432 | | atarisy1_state *state = machine.driver_data<atarisy1_state>(); |
| 433 | | address_space &space = state->generic_space(); |
| 419 | address_space &space = generic_space(); |
| 434 | 420 | UINT16 mem_mask = 0xffff; |
| 435 | 421 | int offset = atarimo_get_bank(0) * 64 * 4; |
| 436 | 422 | int link = 0, best = scanline, found = 0; |
| r20741 | r20742 | |
| 475 | 461 | best = -1; |
| 476 | 462 | |
| 477 | 463 | /* update the timer */ |
| 478 | | if (best != state->m_next_timer_scanline) |
| 464 | if (best != m_next_timer_scanline) |
| 479 | 465 | { |
| 480 | | state->m_next_timer_scanline = best; |
| 466 | m_next_timer_scanline = best; |
| 481 | 467 | |
| 482 | 468 | /* set a new one */ |
| 483 | 469 | if (best != -1) |
| 484 | | state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(best), best); |
| 470 | m_scanline_timer->adjust(machine().primary_screen->time_until_pos(best), best); |
| 485 | 471 | else |
| 486 | | state->m_scanline_timer->reset(); |
| 472 | m_scanline_timer->reset(); |
| 487 | 473 | } |
| 488 | 474 | } |
| 489 | 475 | |
| r20741 | r20742 | |
| 548 | 534 | * |
| 549 | 535 | *************************************/ |
| 550 | 536 | |
| 551 | | static void decode_gfx(running_machine &machine, UINT16 *pflookup, UINT16 *molookup) |
| 537 | void atarisy1_state::decode_gfx(UINT16 *pflookup, UINT16 *molookup) |
| 552 | 538 | { |
| 553 | | atarisy1_state *state = machine.driver_data<atarisy1_state>(); |
| 554 | | UINT8 *prom1 = &state->memregion("proms")->u8(0x000); |
| 555 | | UINT8 *prom2 = &state->memregion("proms")->u8(0x200); |
| 539 | UINT8 *prom1 = &memregion("proms")->u8(0x000); |
| 540 | UINT8 *prom2 = &memregion("proms")->u8(0x200); |
| 556 | 541 | int obj, i; |
| 557 | 542 | |
| 558 | 543 | /* reset the globals */ |
| 559 | | memset(&state->m_bank_gfx[0][0], 0, sizeof(state->m_bank_gfx)); |
| 544 | memset(&m_bank_gfx[0][0], 0, sizeof(m_bank_gfx)); |
| 560 | 545 | |
| 561 | 546 | /* loop for two sets of objects */ |
| 562 | 547 | for (obj = 0; obj < 2; obj++) |
| r20741 | r20742 | |
| 579 | 564 | offset = *prom1 & PROM1_OFFSET_MASK; |
| 580 | 565 | |
| 581 | 566 | /* determine the bank */ |
| 582 | | bank = get_bank(machine, *prom1, *prom2, bpp); |
| 567 | bank = get_bank(*prom1, *prom2, bpp); |
| 583 | 568 | |
| 584 | 569 | /* set the value */ |
| 585 | 570 | if (obj == 0) |
| r20741 | r20742 | |
| 611 | 596 | * |
| 612 | 597 | *************************************/ |
| 613 | 598 | |
| 614 | | static int get_bank(running_machine &machine, UINT8 prom1, UINT8 prom2, int bpp) |
| 599 | int atarisy1_state::get_bank(UINT8 prom1, UINT8 prom2, int bpp) |
| 615 | 600 | { |
| 616 | | atarisy1_state *state = machine.driver_data<atarisy1_state>(); |
| 617 | 601 | const UINT8 *srcdata; |
| 618 | 602 | int bank_index, gfx_index; |
| 619 | 603 | |
| r20741 | r20742 | |
| 639 | 623 | return 0; |
| 640 | 624 | |
| 641 | 625 | /* find the bank */ |
| 642 | | if (state->m_bank_gfx[bpp - 4][bank_index]) |
| 643 | | return state->m_bank_gfx[bpp - 4][bank_index]; |
| 626 | if (m_bank_gfx[bpp - 4][bank_index]) |
| 627 | return m_bank_gfx[bpp - 4][bank_index]; |
| 644 | 628 | |
| 645 | 629 | /* if the bank is out of range, call it 0 */ |
| 646 | | memory_region *tiles = machine.root_device().memregion("tiles"); |
| 630 | memory_region *tiles = machine().root_device().memregion("tiles"); |
| 647 | 631 | if (0x80000 * (bank_index - 1) >= tiles->bytes()) |
| 648 | 632 | return 0; |
| 649 | 633 | |
| 650 | 634 | /* don't have one? let's make it ... first find any empty slot */ |
| 651 | 635 | for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) |
| 652 | | if (machine.gfx[gfx_index] == NULL) |
| 636 | if (machine().gfx[gfx_index] == NULL) |
| 653 | 637 | break; |
| 654 | 638 | assert(gfx_index != MAX_GFX_ELEMENTS); |
| 655 | 639 | |
| r20741 | r20742 | |
| 658 | 642 | switch (bpp) |
| 659 | 643 | { |
| 660 | 644 | case 4: |
| 661 | | machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, objlayout_4bpp, srcdata, 0x40, 256)); |
| 645 | machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), objlayout_4bpp, srcdata, 0x40, 256)); |
| 662 | 646 | break; |
| 663 | 647 | |
| 664 | 648 | case 5: |
| 665 | | machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, objlayout_5bpp, srcdata, 0x40, 256)); |
| 649 | machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), objlayout_5bpp, srcdata, 0x40, 256)); |
| 666 | 650 | break; |
| 667 | 651 | |
| 668 | 652 | case 6: |
| 669 | | machine.gfx[gfx_index] = auto_alloc(machine, gfx_element(machine, objlayout_6bpp, srcdata, 0x40, 256)); |
| 653 | machine().gfx[gfx_index] = auto_alloc(machine(), gfx_element(machine(), objlayout_6bpp, srcdata, 0x40, 256)); |
| 670 | 654 | break; |
| 671 | 655 | |
| 672 | 656 | default: |
| r20741 | r20742 | |
| 674 | 658 | } |
| 675 | 659 | |
| 676 | 660 | /* set the color information */ |
| 677 | | machine.gfx[gfx_index]->set_granularity(8); |
| 678 | | state->m_bank_color_shift[gfx_index] = bpp - 3; |
| 661 | machine().gfx[gfx_index]->set_granularity(8); |
| 662 | m_bank_color_shift[gfx_index] = bpp - 3; |
| 679 | 663 | |
| 680 | 664 | /* set the entry and return it */ |
| 681 | | return state->m_bank_gfx[bpp - 4][bank_index] = gfx_index; |
| 665 | return m_bank_gfx[bpp - 4][bank_index] = gfx_index; |
| 682 | 666 | } |
trunk/src/mame/video/astrocde.c
| r20741 | r20742 | |
| 22 | 22 | #define VERT_OFFSET (22) /* pixels from top of screen to top of game area */ |
| 23 | 23 | #define HORZ_OFFSET (16) /* pixels from left of screen to left of game area */ |
| 24 | 24 | |
| 25 | | |
| 26 | | |
| 27 | 25 | /************************************* |
| 28 | 26 | * |
| 29 | | * Function prototypes |
| 30 | | * |
| 31 | | *************************************/ |
| 32 | | |
| 33 | | static void init_savestate(running_machine &machine); |
| 34 | | |
| 35 | | |
| 36 | | static void init_sparklestar(running_machine &machine); |
| 37 | | |
| 38 | | |
| 39 | | |
| 40 | | /************************************* |
| 41 | | * |
| 42 | 27 | * Scanline conversion |
| 43 | 28 | * |
| 44 | 29 | *************************************/ |
| 45 | 30 | |
| 46 | | INLINE int mame_vpos_to_astrocade_vpos(int scanline) |
| 31 | inline int astrocde_state::mame_vpos_to_astrocade_vpos(int scanline) |
| 47 | 32 | { |
| 48 | 33 | scanline -= VERT_OFFSET; |
| 49 | 34 | if (scanline < 0) |
| r20741 | r20742 | |
| 168 | 153 | m_intoff_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(astrocde_state::interrupt_off),this)); |
| 169 | 154 | |
| 170 | 155 | /* register for save states */ |
| 171 | | init_savestate(machine()); |
| 156 | init_savestate(); |
| 172 | 157 | |
| 173 | 158 | /* initialize the sparkle and stars */ |
| 174 | 159 | if (m_video_config & AC_STARS) |
| 175 | | init_sparklestar(machine()); |
| 160 | init_sparklestar(); |
| 176 | 161 | } |
| 177 | 162 | |
| 178 | 163 | |
| r20741 | r20742 | |
| 187 | 172 | m_profpac_videoram = auto_alloc_array(machine(), UINT16, 0x4000 * 4); |
| 188 | 173 | |
| 189 | 174 | /* register for save states */ |
| 190 | | init_savestate(machine()); |
| 175 | init_savestate(); |
| 191 | 176 | |
| 192 | 177 | /* register our specific save state data */ |
| 193 | 178 | state_save_register_global_pointer(machine(), m_profpac_videoram, 0x4000 * 4); |
| r20741 | r20742 | |
| 204 | 189 | } |
| 205 | 190 | |
| 206 | 191 | |
| 207 | | static void init_savestate(running_machine &machine) |
| 192 | void astrocde_state::init_savestate() |
| 208 | 193 | { |
| 209 | | astrocde_state *state = machine.driver_data<astrocde_state>(); |
| 210 | | state_save_register_global_array(machine, state->m_sparkle); |
| 194 | state_save_register_global_array(machine(), m_sparkle); |
| 211 | 195 | |
| 212 | | state_save_register_global(machine, state->m_interrupt_enabl); |
| 213 | | state_save_register_global(machine, state->m_interrupt_vector); |
| 214 | | state_save_register_global(machine, state->m_interrupt_scanline); |
| 215 | | state_save_register_global(machine, state->m_vertical_feedback); |
| 216 | | state_save_register_global(machine, state->m_horizontal_feedback); |
| 196 | state_save_register_global(machine(), m_interrupt_enabl); |
| 197 | state_save_register_global(machine(), m_interrupt_vector); |
| 198 | state_save_register_global(machine(), m_interrupt_scanline); |
| 199 | state_save_register_global(machine(), m_vertical_feedback); |
| 200 | state_save_register_global(machine(), m_horizontal_feedback); |
| 217 | 201 | |
| 218 | | state_save_register_global_array(machine, state->m_colors); |
| 219 | | state_save_register_global(machine, state->m_colorsplit); |
| 220 | | state_save_register_global(machine, state->m_bgdata); |
| 221 | | state_save_register_global(machine, state->m_vblank); |
| 222 | | state_save_register_global(machine, state->m_video_mode); |
| 202 | state_save_register_global_array(machine(), m_colors); |
| 203 | state_save_register_global(machine(), m_colorsplit); |
| 204 | state_save_register_global(machine(), m_bgdata); |
| 205 | state_save_register_global(machine(), m_vblank); |
| 206 | state_save_register_global(machine(), m_video_mode); |
| 223 | 207 | |
| 224 | | state_save_register_global_array(machine, state->m_funcgen_expand_color); |
| 225 | | state_save_register_global(machine, state->m_funcgen_control); |
| 226 | | state_save_register_global(machine, state->m_funcgen_expand_count); |
| 227 | | state_save_register_global(machine, state->m_funcgen_rotate_count); |
| 228 | | state_save_register_global_array(machine, state->m_funcgen_rotate_data); |
| 229 | | state_save_register_global(machine, state->m_funcgen_shift_prev_data); |
| 230 | | state_save_register_global(machine, state->m_funcgen_intercept); |
| 208 | state_save_register_global_array(machine(), m_funcgen_expand_color); |
| 209 | state_save_register_global(machine(), m_funcgen_control); |
| 210 | state_save_register_global(machine(), m_funcgen_expand_count); |
| 211 | state_save_register_global(machine(), m_funcgen_rotate_count); |
| 212 | state_save_register_global_array(machine(), m_funcgen_rotate_data); |
| 213 | state_save_register_global(machine(), m_funcgen_shift_prev_data); |
| 214 | state_save_register_global(machine(), m_funcgen_intercept); |
| 231 | 215 | |
| 232 | | state_save_register_global(machine, state->m_pattern_source); |
| 233 | | state_save_register_global(machine, state->m_pattern_mode); |
| 234 | | state_save_register_global(machine, state->m_pattern_dest); |
| 235 | | state_save_register_global(machine, state->m_pattern_skip); |
| 236 | | state_save_register_global(machine, state->m_pattern_width); |
| 237 | | state_save_register_global(machine, state->m_pattern_height); |
| 216 | state_save_register_global(machine(), m_pattern_source); |
| 217 | state_save_register_global(machine(), m_pattern_mode); |
| 218 | state_save_register_global(machine(), m_pattern_dest); |
| 219 | state_save_register_global(machine(), m_pattern_skip); |
| 220 | state_save_register_global(machine(), m_pattern_width); |
| 221 | state_save_register_global(machine(), m_pattern_height); |
| 238 | 222 | } |
| 239 | 223 | |
| 240 | 224 | |
| r20741 | r20742 | |
| 377 | 361 | } |
| 378 | 362 | |
| 379 | 363 | |
| 380 | | static void astrocade_trigger_lightpen(running_machine &machine, UINT8 vfeedback, UINT8 hfeedback) |
| 364 | void astrocde_state::astrocade_trigger_lightpen(UINT8 vfeedback, UINT8 hfeedback) |
| 381 | 365 | { |
| 382 | | astrocde_state *state = machine.driver_data<astrocde_state>(); |
| 383 | 366 | /* both bits 1 and 4 enable lightpen interrupts; bit 4 enables them even in horizontal */ |
| 384 | 367 | /* blanking regions; we treat them both the same here */ |
| 385 | | if ((state->m_interrupt_enabl & 0x12) != 0) |
| 368 | if ((m_interrupt_enabl & 0x12) != 0) |
| 386 | 369 | { |
| 387 | 370 | /* bit 0 controls the interrupt mode: mode 0 means assert until acknowledged */ |
| 388 | | if ((state->m_interrupt_enabl & 0x01) == 0) |
| 371 | if ((m_interrupt_enabl & 0x01) == 0) |
| 389 | 372 | { |
| 390 | | machine.device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE, state->m_interrupt_vector & 0xf0); |
| 391 | | state->m_intoff_timer->adjust(machine.primary_screen->time_until_pos(vfeedback)); |
| 373 | machine().device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE, m_interrupt_vector & 0xf0); |
| 374 | m_intoff_timer->adjust(machine().primary_screen->time_until_pos(vfeedback)); |
| 392 | 375 | } |
| 393 | 376 | |
| 394 | 377 | /* mode 1 means assert for 1 instruction */ |
| 395 | 378 | else |
| 396 | 379 | { |
| 397 | | machine.device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, state->m_interrupt_vector & 0xf0); |
| 398 | | state->m_intoff_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1)); |
| 380 | machine().device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, m_interrupt_vector & 0xf0); |
| 381 | m_intoff_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(1)); |
| 399 | 382 | } |
| 400 | 383 | |
| 401 | 384 | /* latch the feedback registers */ |
| 402 | | state->m_vertical_feedback = vfeedback; |
| 403 | | state->m_horizontal_feedback = hfeedback; |
| 385 | m_vertical_feedback = vfeedback; |
| 386 | m_horizontal_feedback = hfeedback; |
| 404 | 387 | } |
| 405 | 388 | } |
| 406 | 389 | |
| r20741 | r20742 | |
| 441 | 424 | |
| 442 | 425 | /* on some games, the horizontal drive line is conected to the lightpen interrupt */ |
| 443 | 426 | else if (m_video_config & AC_LIGHTPEN_INTS) |
| 444 | | astrocade_trigger_lightpen(machine(), astrocade_scanline, 8); |
| 427 | astrocade_trigger_lightpen(astrocade_scanline, 8); |
| 445 | 428 | |
| 446 | 429 | /* advance to the next scanline */ |
| 447 | 430 | scanline++; |
| r20741 | r20742 | |
| 706 | 689 | * |
| 707 | 690 | *************************************/ |
| 708 | 691 | |
| 709 | | INLINE void increment_source(astrocde_state *state, UINT8 curwidth, UINT8 *u13ff) |
| 692 | inline void astrocde_state::increment_source(UINT8 curwidth, UINT8 *u13ff) |
| 710 | 693 | { |
| 711 | 694 | /* if the flip-flop at U13 is high and mode.d2 is 1 we can increment */ |
| 712 | 695 | /* however, if mode.d3 is set and we're on the last byte of a row, the increment is suppressed */ |
| 713 | | if (*u13ff && (state->m_pattern_mode & 0x04) != 0 && (curwidth != 0 || (state->m_pattern_mode & 0x08) == 0)) |
| 714 | | state->m_pattern_source++; |
| 696 | if (*u13ff && (m_pattern_mode & 0x04) != 0 && (curwidth != 0 || (m_pattern_mode & 0x08) == 0)) |
| 697 | m_pattern_source++; |
| 715 | 698 | |
| 716 | 699 | /* if mode.d1 is 1, toggle the flip-flop; otherwise leave it preset */ |
| 717 | | if ((state->m_pattern_mode & 0x02) != 0) |
| 700 | if ((m_pattern_mode & 0x02) != 0) |
| 718 | 701 | *u13ff ^= 1; |
| 719 | 702 | } |
| 720 | 703 | |
| 721 | 704 | |
| 722 | | INLINE void increment_dest(astrocde_state *state, UINT8 curwidth) |
| 705 | inline void astrocde_state::increment_dest(UINT8 curwidth) |
| 723 | 706 | { |
| 724 | 707 | /* increment is suppressed for the last byte in a row */ |
| 725 | 708 | if (curwidth != 0) |
| 726 | 709 | { |
| 727 | 710 | /* if mode.d5 is 1, we increment */ |
| 728 | | if ((state->m_pattern_mode & 0x20) != 0) |
| 729 | | state->m_pattern_dest++; |
| 711 | if ((m_pattern_mode & 0x20) != 0) |
| 712 | m_pattern_dest++; |
| 730 | 713 | |
| 731 | 714 | /* otherwise, we decrement */ |
| 732 | 715 | else |
| 733 | | state->m_pattern_dest--; |
| 716 | m_pattern_dest--; |
| 734 | 717 | } |
| 735 | 718 | } |
| 736 | 719 | |
| 737 | 720 | |
| 738 | | static void execute_blit(address_space &space) |
| 721 | void astrocde_state::execute_blit(address_space &space) |
| 739 | 722 | { |
| 740 | | astrocde_state *state = space.machine().driver_data<astrocde_state>(); |
| 741 | 723 | /* |
| 742 | | state->m_pattern_source = counter set U7/U16/U25/U34 |
| 743 | | state->m_pattern_dest = counter set U9/U18/U30/U39 |
| 744 | | state->m_pattern_mode = latch U21 |
| 745 | | state->m_pattern_skip = latch set U30/U39 |
| 746 | | state->m_pattern_width = latch set U32/U41 |
| 747 | | state->m_pattern_height = counter set U31/U40 |
| 724 | m_pattern_source = counter set U7/U16/U25/U34 |
| 725 | m_pattern_dest = counter set U9/U18/U30/U39 |
| 726 | m_pattern_mode = latch U21 |
| 727 | m_pattern_skip = latch set U30/U39 |
| 728 | m_pattern_width = latch set U32/U41 |
| 729 | m_pattern_height = counter set U31/U40 |
| 748 | 730 | |
| 749 | | state->m_pattern_mode bits: |
| 731 | m_pattern_mode bits: |
| 750 | 732 | d0 = direction (0 = read from src, write to dest, 1 = read from dest, write to src) |
| 751 | 733 | d1 = expand (0 = increment src each pixel, 1 = increment src every other pixel) |
| 752 | 734 | d2 = constant (0 = never increment src, 1 = normal src increment) |
| r20741 | r20742 | |
| 760 | 742 | int cycles = 0; |
| 761 | 743 | |
| 762 | 744 | /* logerror("Blit: src=%04X mode=%02X dest=%04X skip=%02X width=%02X height=%02X\n", |
| 763 | | state->m_pattern_source, state->m_pattern_mode, state->m_pattern_dest, state->m_pattern_skip, state->m_pattern_width, state->m_pattern_height);*/ |
| 745 | m_pattern_source, m_pattern_mode, m_pattern_dest, m_pattern_skip, m_pattern_width, m_pattern_height);*/ |
| 764 | 746 | |
| 765 | 747 | /* flip-flop at U13 is cleared at the beginning */ |
| 766 | 748 | u13ff = 0; |
| 767 | 749 | |
| 768 | 750 | /* it is also forced preset if mode.d1 == 0 */ |
| 769 | | if ((state->m_pattern_mode & 0x02) == 0) |
| 751 | if ((m_pattern_mode & 0x02) == 0) |
| 770 | 752 | u13ff = 1; |
| 771 | 753 | |
| 772 | 754 | /* loop over height */ |
| r20741 | r20742 | |
| 775 | 757 | UINT16 carry; |
| 776 | 758 | |
| 777 | 759 | /* loop over width */ |
| 778 | | curwidth = state->m_pattern_width; |
| 760 | curwidth = m_pattern_width; |
| 779 | 761 | do |
| 780 | 762 | { |
| 781 | 763 | UINT16 busaddr; |
| r20741 | r20742 | |
| 784 | 766 | /* ----- read phase ----- */ |
| 785 | 767 | |
| 786 | 768 | /* address is selected between source/dest based on mode.d0 */ |
| 787 | | busaddr = ((state->m_pattern_mode & 0x01) == 0) ? state->m_pattern_source : state->m_pattern_dest; |
| 769 | busaddr = ((m_pattern_mode & 0x01) == 0) ? m_pattern_source : m_pattern_dest; |
| 788 | 770 | |
| 789 | 771 | /* if mode.d3 is set, then the last byte fetched per row is forced to 0 */ |
| 790 | | if (curwidth == 0 && (state->m_pattern_mode & 0x08) != 0) |
| 772 | if (curwidth == 0 && (m_pattern_mode & 0x08) != 0) |
| 791 | 773 | busdata = 0; |
| 792 | 774 | else |
| 793 | 775 | busdata = space.read_byte(busaddr); |
| 794 | 776 | |
| 795 | 777 | /* increment the appropriate address */ |
| 796 | | if ((state->m_pattern_mode & 0x01) == 0) |
| 797 | | increment_source(state, curwidth, &u13ff); |
| 778 | if ((m_pattern_mode & 0x01) == 0) |
| 779 | increment_source(curwidth, &u13ff); |
| 798 | 780 | else |
| 799 | | increment_dest(state, curwidth); |
| 781 | increment_dest(curwidth); |
| 800 | 782 | |
| 801 | 783 | /* ----- write phase ----- */ |
| 802 | 784 | |
| 803 | 785 | /* address is selected between source/dest based on mode.d0 */ |
| 804 | | busaddr = ((state->m_pattern_mode & 0x01) != 0) ? state->m_pattern_source : state->m_pattern_dest; |
| 786 | busaddr = ((m_pattern_mode & 0x01) != 0) ? m_pattern_source : m_pattern_dest; |
| 805 | 787 | space.write_byte(busaddr, busdata); |
| 806 | 788 | |
| 807 | 789 | /* increment the appropriate address */ |
| 808 | | if ((state->m_pattern_mode & 0x01) == 0) |
| 809 | | increment_dest(state, curwidth); |
| 790 | if ((m_pattern_mode & 0x01) == 0) |
| 791 | increment_dest(curwidth); |
| 810 | 792 | else |
| 811 | | increment_source(state, curwidth, &u13ff); |
| 793 | increment_source(curwidth, &u13ff); |
| 812 | 794 | |
| 813 | 795 | /* count 4 cycles (two read, two write) */ |
| 814 | 796 | cycles += 4; |
| r20741 | r20742 | |
| 816 | 798 | } while (curwidth-- != 0); |
| 817 | 799 | |
| 818 | 800 | /* at the end of each row, the skip value is added to the dest value */ |
| 819 | | carry = ((state->m_pattern_dest & 0xff) + state->m_pattern_skip) & 0x100; |
| 820 | | state->m_pattern_dest = (state->m_pattern_dest & 0xff00) | ((state->m_pattern_dest + state->m_pattern_skip) & 0xff); |
| 801 | carry = ((m_pattern_dest & 0xff) + m_pattern_skip) & 0x100; |
| 802 | m_pattern_dest = (m_pattern_dest & 0xff00) | ((m_pattern_dest + m_pattern_skip) & 0xff); |
| 821 | 803 | |
| 822 | 804 | /* carry behavior into the top byte is controlled by mode.d4 */ |
| 823 | | if ((state->m_pattern_mode & 0x10) == 0) |
| 824 | | state->m_pattern_dest += carry; |
| 805 | if ((m_pattern_mode & 0x10) == 0) |
| 806 | m_pattern_dest += carry; |
| 825 | 807 | else |
| 826 | | state->m_pattern_dest -= carry ^ 0x100; |
| 808 | m_pattern_dest -= carry ^ 0x100; |
| 827 | 809 | |
| 828 | | } while (state->m_pattern_height-- != 0); |
| 810 | } while (m_pattern_height-- != 0); |
| 829 | 811 | |
| 830 | 812 | /* count cycles we ran the bus */ |
| 831 | 813 | space.device().execute().adjust_icount(-cycles); |
| r20741 | r20742 | |
| 905 | 887 | relative to the beginning of time and use that, mod RNG_PERIOD. |
| 906 | 888 | */ |
| 907 | 889 | |
| 908 | | static void init_sparklestar(running_machine &machine) |
| 890 | void astrocde_state::init_sparklestar() |
| 909 | 891 | { |
| 910 | | astrocde_state *state = machine.driver_data<astrocde_state>(); |
| 911 | 892 | UINT32 shiftreg; |
| 912 | 893 | int i; |
| 913 | 894 | |
| 914 | 895 | /* reset global sparkle state */ |
| 915 | | state->m_sparkle[0] = state->m_sparkle[1] = state->m_sparkle[2] = state->m_sparkle[3] = 0; |
| 896 | m_sparkle[0] = m_sparkle[1] = m_sparkle[2] = m_sparkle[3] = 0; |
| 916 | 897 | |
| 917 | 898 | /* allocate memory for the sparkle/star array */ |
| 918 | | state->m_sparklestar = auto_alloc_array(machine, UINT8, RNG_PERIOD); |
| 899 | m_sparklestar = auto_alloc_array(machine(), UINT8, RNG_PERIOD); |
| 919 | 900 | |
| 920 | 901 | /* generate the data for the sparkle/star array */ |
| 921 | 902 | for (shiftreg = i = 0; i < RNG_PERIOD; i++) |
| r20741 | r20742 | |
| 928 | 909 | |
| 929 | 910 | /* extract the sparkle/star intensity here */ |
| 930 | 911 | /* this is controlled by the shift register at U17/U19/U18 */ |
| 931 | | state->m_sparklestar[i] = (((shiftreg >> 4) & 1) << 3) | |
| 912 | m_sparklestar[i] = (((shiftreg >> 4) & 1) << 3) | |
| 932 | 913 | (((shiftreg >> 12) & 1) << 2) | |
| 933 | 914 | (((shiftreg >> 16) & 1) << 1) | |
| 934 | 915 | (((shiftreg >> 8) & 1) << 0); |
| r20741 | r20742 | |
| 936 | 917 | /* determine the star enable here */ |
| 937 | 918 | /* this is controlled by the shift register at U17/U12/U11 */ |
| 938 | 919 | if ((shiftreg & 0xff) == 0xfe) |
| 939 | | state->m_sparklestar[i] |= 0x10; |
| 920 | m_sparklestar[i] |= 0x10; |
| 940 | 921 | } |
| 941 | 922 | } |
| 942 | 923 | |
trunk/src/mame/video/40love.c
| r20741 | r20742 | |
| 131 | 131 | |
| 132 | 132 | ***************************************************************************/ |
| 133 | 133 | |
| 134 | | static void fortyl_set_scroll_x( running_machine &machine, int offset ) |
| 134 | void fortyl_state::fortyl_set_scroll_x( int offset ) |
| 135 | 135 | { |
| 136 | | fortyl_state *state = machine.driver_data<fortyl_state>(); |
| 137 | 136 | int i = offset & ~1; |
| 138 | | int x = ((state->m_colorram[i] & 0x80) << 1) | state->m_colorram[i + 1]; /* 9 bits signed */ |
| 137 | int x = ((m_colorram[i] & 0x80) << 1) | m_colorram[i + 1]; /* 9 bits signed */ |
| 139 | 138 | |
| 140 | | if (state->m_flipscreen) |
| 139 | if (m_flipscreen) |
| 141 | 140 | x += 0x51; |
| 142 | 141 | else |
| 143 | 142 | x -= 0x50; |
| r20741 | r20742 | |
| 145 | 144 | x &= 0x1ff; |
| 146 | 145 | if (x & 0x100) x -= 0x200; /* sign extend */ |
| 147 | 146 | |
| 148 | | state->m_bg_tilemap->set_scrollx(offset / 2, x); |
| 147 | m_bg_tilemap->set_scrollx(offset / 2, x); |
| 149 | 148 | } |
| 150 | 149 | |
| 151 | 150 | WRITE8_MEMBER(fortyl_state::fortyl_pixram_sel_w) |
| r20741 | r20742 | |
| 162 | 161 | m_pix_redraw = 1; |
| 163 | 162 | |
| 164 | 163 | for (offs = 0; offs < 32; offs++) |
| 165 | | fortyl_set_scroll_x(machine(), offs * 2); |
| 164 | fortyl_set_scroll_x(offs * 2); |
| 166 | 165 | } |
| 167 | 166 | } |
| 168 | 167 | |
| r20741 | r20742 | |
| 174 | 173 | return m_pixram1[offset]; |
| 175 | 174 | } |
| 176 | 175 | |
| 177 | | static void fortyl_plot_pix( running_machine &machine, int offset ) |
| 176 | void fortyl_state::fortyl_plot_pix( int offset ) |
| 178 | 177 | { |
| 179 | | fortyl_state *state = machine.driver_data<fortyl_state>(); |
| 180 | 178 | int x, y, i, c, d1, d2; |
| 181 | 179 | |
| 182 | 180 | x = (offset & 0x1f) * 8; |
| 183 | 181 | y = (offset >> 5) & 0xff; |
| 184 | 182 | |
| 185 | | if (state->m_pixram_sel) |
| 183 | if (m_pixram_sel) |
| 186 | 184 | { |
| 187 | | d1 = state->m_pixram2[offset]; |
| 188 | | d2 = state->m_pixram2[offset + 0x2000]; |
| 185 | d1 = m_pixram2[offset]; |
| 186 | d2 = m_pixram2[offset + 0x2000]; |
| 189 | 187 | } |
| 190 | 188 | else |
| 191 | 189 | { |
| 192 | | d1 = state->m_pixram1[offset]; |
| 193 | | d2 = state->m_pixram1[offset + 0x2000]; |
| 190 | d1 = m_pixram1[offset]; |
| 191 | d2 = m_pixram1[offset + 0x2000]; |
| 194 | 192 | } |
| 195 | 193 | |
| 196 | 194 | for (i = 0; i < 8; i++) |
| 197 | 195 | { |
| 198 | 196 | c = ((d2 >> i) & 1) + ((d1 >> i) & 1) * 2; |
| 199 | | if (state->m_pixram_sel) |
| 200 | | state->m_tmp_bitmap2->pix16(y, x + i) = state->m_pix_color[c]; |
| 197 | if (m_pixram_sel) |
| 198 | m_tmp_bitmap2->pix16(y, x + i) = m_pix_color[c]; |
| 201 | 199 | else |
| 202 | | state->m_tmp_bitmap1->pix16(y, x + i) = state->m_pix_color[c]; |
| 200 | m_tmp_bitmap1->pix16(y, x + i) = m_pix_color[c]; |
| 203 | 201 | } |
| 204 | 202 | } |
| 205 | 203 | |
| r20741 | r20742 | |
| 210 | 208 | else |
| 211 | 209 | m_pixram1[offset] = data; |
| 212 | 210 | |
| 213 | | fortyl_plot_pix(machine(), offset & 0x1fff); |
| 211 | fortyl_plot_pix(offset & 0x1fff); |
| 214 | 212 | } |
| 215 | 213 | |
| 216 | 214 | |
| r20741 | r20742 | |
| 235 | 233 | for (i = (offset / 2) * 64; i < (offset / 2) * 64 + 64; i++) |
| 236 | 234 | m_bg_tilemap->mark_tile_dirty(i); |
| 237 | 235 | |
| 238 | | fortyl_set_scroll_x(machine(), offset); |
| 236 | fortyl_set_scroll_x(offset); |
| 239 | 237 | } |
| 240 | 238 | } |
| 241 | 239 | |
| r20741 | r20742 | |
| 265 | 263 | offset 3 xxxxxxxx x position |
| 266 | 264 | */ |
| 267 | 265 | |
| 268 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 266 | void fortyl_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 269 | 267 | { |
| 270 | | fortyl_state *state = machine.driver_data<fortyl_state>(); |
| 271 | | UINT8 *spriteram = state->m_spriteram; |
| 272 | | UINT8 *spriteram_2 = state->m_spriteram2; |
| 268 | UINT8 *spriteram = m_spriteram; |
| 269 | UINT8 *spriteram_2 = m_spriteram2; |
| 273 | 270 | int offs; |
| 274 | 271 | |
| 275 | 272 | /* spriteram #1 */ |
| 276 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4) |
| 273 | for (offs = 0; offs < m_spriteram.bytes(); offs += 4) |
| 277 | 274 | { |
| 278 | 275 | int code, color, sx, sy, flipx, flipy; |
| 279 | 276 | |
| 280 | 277 | sx = spriteram[offs + 3]; |
| 281 | 278 | sy = spriteram[offs + 0] +1; |
| 282 | 279 | |
| 283 | | if (state->m_flipscreen) |
| 280 | if (m_flipscreen) |
| 284 | 281 | sx = 240 - sx; |
| 285 | 282 | else |
| 286 | 283 | sy = 242 - sy; |
| 287 | 284 | |
| 288 | 285 | code = (spriteram[offs + 1] & 0x3f) + ((spriteram[offs + 2] & 0x18) << 3); |
| 289 | | flipx = ((spriteram[offs + 1] & 0x40) >> 6) ^ state->m_flipscreen; |
| 290 | | flipy = ((spriteram[offs + 1] & 0x80) >> 7) ^ state->m_flipscreen; |
| 286 | flipx = ((spriteram[offs + 1] & 0x40) >> 6) ^ m_flipscreen; |
| 287 | flipy = ((spriteram[offs + 1] & 0x80) >> 7) ^ m_flipscreen; |
| 291 | 288 | color = (spriteram[offs + 2] & 0x07) + 0x08; |
| 292 | 289 | |
| 293 | 290 | if (spriteram[offs + 2] & 0xe0) |
| 294 | | color = machine.rand() & 0xf; |
| 291 | color = machine().rand() & 0xf; |
| 295 | 292 | |
| 296 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 293 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 297 | 294 | code, |
| 298 | 295 | color, |
| 299 | 296 | flipx,flipy, |
| 300 | | sx+state->m_xoffset,sy,0); |
| 297 | sx+m_xoffset,sy,0); |
| 301 | 298 | } |
| 302 | 299 | |
| 303 | 300 | /* spriteram #2 */ |
| 304 | | for (offs = 0; offs < state->m_spriteram2.bytes(); offs += 4) |
| 301 | for (offs = 0; offs < m_spriteram2.bytes(); offs += 4) |
| 305 | 302 | { |
| 306 | 303 | int code, color, sx, sy, flipx, flipy; |
| 307 | 304 | |
| 308 | 305 | sx = spriteram_2[offs + 3]; |
| 309 | 306 | sy = spriteram_2[offs + 0] +1; |
| 310 | 307 | |
| 311 | | if (state->m_flipscreen) |
| 308 | if (m_flipscreen) |
| 312 | 309 | sx = 240 - sx; |
| 313 | 310 | else |
| 314 | 311 | sy = 242 - sy; |
| 315 | 312 | |
| 316 | 313 | code = (spriteram_2[offs + 1] & 0x3f) + ((spriteram_2[offs + 2] & 0x18) << 3); |
| 317 | | flipx = ((spriteram_2[offs + 1] & 0x40) >> 6) ^ state->m_flipscreen; |
| 318 | | flipy = ((spriteram_2[offs + 1] & 0x80) >> 7) ^ state->m_flipscreen; |
| 314 | flipx = ((spriteram_2[offs + 1] & 0x40) >> 6) ^ m_flipscreen; |
| 315 | flipy = ((spriteram_2[offs + 1] & 0x80) >> 7) ^ m_flipscreen; |
| 319 | 316 | color = (spriteram_2[offs + 2] & 0x07) + 0x08; |
| 320 | 317 | |
| 321 | 318 | if (spriteram_2[offs + 2] & 0xe0) |
| 322 | | color = machine.rand() & 0xf; |
| 319 | color = machine().rand() & 0xf; |
| 323 | 320 | |
| 324 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 321 | drawgfx_transpen(bitmap,cliprect,machine().gfx[1], |
| 325 | 322 | code, |
| 326 | 323 | color, |
| 327 | 324 | flipx,flipy, |
| 328 | | sx+state->m_xoffset,sy,0); |
| 325 | sx+m_xoffset,sy,0); |
| 329 | 326 | } |
| 330 | 327 | } |
| 331 | 328 | |
| 332 | | static void draw_pixram( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 329 | void fortyl_state::draw_pixram( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 333 | 330 | { |
| 334 | | fortyl_state *state = machine.driver_data<fortyl_state>(); |
| 335 | 331 | int offs; |
| 336 | | int f = state->m_flipscreen ^ 1; |
| 332 | int f = m_flipscreen ^ 1; |
| 337 | 333 | |
| 338 | | if (state->m_pix_redraw) |
| 334 | if (m_pix_redraw) |
| 339 | 335 | { |
| 340 | | state->m_pix_redraw = 0; |
| 336 | m_pix_redraw = 0; |
| 341 | 337 | |
| 342 | 338 | for (offs = 0; offs < 0x2000; offs++) |
| 343 | | fortyl_plot_pix(machine, offs); |
| 339 | fortyl_plot_pix(offs); |
| 344 | 340 | } |
| 345 | 341 | |
| 346 | | if (state->m_pixram_sel) |
| 347 | | copybitmap(bitmap, *state->m_tmp_bitmap1, f, f, state->m_xoffset, 0, cliprect); |
| 342 | if (m_pixram_sel) |
| 343 | copybitmap(bitmap, *m_tmp_bitmap1, f, f, m_xoffset, 0, cliprect); |
| 348 | 344 | else |
| 349 | | copybitmap(bitmap, *state->m_tmp_bitmap2, f, f, state->m_xoffset, 0, cliprect); |
| 345 | copybitmap(bitmap, *m_tmp_bitmap2, f, f, m_xoffset, 0, cliprect); |
| 350 | 346 | } |
| 351 | 347 | |
| 352 | 348 | UINT32 fortyl_state::screen_update_fortyl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 353 | 349 | { |
| 354 | | draw_pixram(machine(), bitmap, cliprect); |
| 350 | draw_pixram(bitmap, cliprect); |
| 355 | 351 | |
| 356 | 352 | m_bg_tilemap->set_scrolldy(- m_video_ctrl[1] + 1, - m_video_ctrl[1] - 1 ); |
| 357 | 353 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 358 | 354 | |
| 359 | | draw_sprites(machine(), bitmap, cliprect); |
| 355 | draw_sprites(bitmap, cliprect); |
| 360 | 356 | return 0; |
| 361 | 357 | } |
trunk/src/mame/video/8080bw.c
| r20741 | r20742 | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | | static void invadpt2_get_pens( pen_t *pens ) |
| 29 | void _8080bw_state::invadpt2_get_pens( pen_t *pens ) |
| 30 | 30 | { |
| 31 | 31 | offs_t i; |
| 32 | 32 | |
| r20741 | r20742 | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | | static void sflush_get_pens( pen_t *pens ) |
| 40 | void _8080bw_state::sflush_get_pens( pen_t *pens ) |
| 41 | 41 | { |
| 42 | 42 | offs_t i; |
| 43 | 43 | |
| r20741 | r20742 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
| 53 | | static void cosmo_get_pens( pen_t *pens ) |
| 53 | void _8080bw_state::cosmo_get_pens( pen_t *pens ) |
| 54 | 54 | { |
| 55 | 55 | offs_t i; |
| 56 | 56 | |
| r20741 | r20742 | |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
| 64 | | INLINE void set_pixel( running_machine &machine, bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color ) |
| 64 | inline void _8080bw_state::set_pixel( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color ) |
| 65 | 65 | { |
| 66 | | _8080bw_state *state = machine.driver_data<_8080bw_state>(); |
| 67 | | |
| 68 | 66 | if (y >= MW8080BW_VCOUNTER_START_NO_VBLANK) |
| 69 | 67 | { |
| 70 | | if (state->m_flip_screen) |
| 68 | if (m_flip_screen) |
| 71 | 69 | bitmap.pix32(MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - x) = pens[color]; |
| 72 | 70 | else |
| 73 | 71 | bitmap.pix32(y - MW8080BW_VCOUNTER_START_NO_VBLANK, x) = pens[color]; |
| r20741 | r20742 | |
| 75 | 73 | } |
| 76 | 74 | |
| 77 | 75 | |
| 78 | | INLINE void set_8_pixels( running_machine &machine, bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, pen_t *pens, UINT8 fore_color, UINT8 back_color ) |
| 76 | inline void _8080bw_state::set_8_pixels( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, pen_t *pens, UINT8 fore_color, UINT8 back_color ) |
| 79 | 77 | { |
| 80 | 78 | int i; |
| 81 | 79 | |
| 82 | 80 | for (i = 0; i < 8; i++) |
| 83 | 81 | { |
| 84 | | set_pixel(machine, bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color); |
| 82 | set_pixel(bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color); |
| 85 | 83 | |
| 86 | 84 | x = x + 1; |
| 87 | 85 | data = data >> 1; |
| r20741 | r20742 | |
| 90 | 88 | |
| 91 | 89 | |
| 92 | 90 | /* this is needed as this driver doesn't emulate the shift register like mw8080bw does */ |
| 93 | | static void clear_extra_columns( running_machine &machine, bitmap_rgb32 &bitmap, pen_t *pens, UINT8 color ) |
| 91 | void _8080bw_state::clear_extra_columns( bitmap_rgb32 &bitmap, pen_t *pens, UINT8 color ) |
| 94 | 92 | { |
| 95 | | _8080bw_state *state = machine.driver_data<_8080bw_state>(); |
| 96 | 93 | UINT8 x; |
| 97 | 94 | |
| 98 | 95 | for (x = 0; x < 4; x++) |
| r20741 | r20742 | |
| 101 | 98 | |
| 102 | 99 | for (y = MW8080BW_VCOUNTER_START_NO_VBLANK; y != 0; y++) |
| 103 | 100 | { |
| 104 | | if (state->m_flip_screen) |
| 101 | if (m_flip_screen) |
| 105 | 102 | bitmap.pix32(MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - (256 + x)) = pens[color]; |
| 106 | 103 | else |
| 107 | 104 | bitmap.pix32(y - MW8080BW_VCOUNTER_START_NO_VBLANK, 256 + x) = pens[color]; |
| r20741 | r20742 | |
| 132 | 129 | UINT8 data = m_main_ram[offs]; |
| 133 | 130 | UINT8 fore_color = m_screen_red ? 1 : color_map_base[color_address] & 0x07; |
| 134 | 131 | |
| 135 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0); |
| 132 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); |
| 136 | 133 | } |
| 137 | 134 | |
| 138 | | clear_extra_columns(machine(), bitmap, pens, 0); |
| 135 | clear_extra_columns(bitmap, pens, 0); |
| 139 | 136 | |
| 140 | 137 | return 0; |
| 141 | 138 | } |
| r20741 | r20742 | |
| 164 | 161 | UINT8 fore_color = m_screen_red ? 1 : color_map_base[color_address] & 0x07; |
| 165 | 162 | |
| 166 | 163 | /* blue background */ |
| 167 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 2); |
| 164 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 2); |
| 168 | 165 | } |
| 169 | 166 | |
| 170 | | clear_extra_columns(machine(), bitmap, pens, 2); |
| 167 | clear_extra_columns(bitmap, pens, 2); |
| 171 | 168 | |
| 172 | 169 | return 0; |
| 173 | 170 | } |
| r20741 | r20742 | |
| 204 | 201 | back_color = (((back_data & 0x0c) == 0x0c) && m_schaser_background_select) ? 4 : 2; |
| 205 | 202 | } |
| 206 | 203 | |
| 207 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, back_color); |
| 204 | set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color); |
| 208 | 205 | } |
| 209 | 206 | |
| 210 | | clear_extra_columns(machine(), bitmap, pens, m_schaser_background_disable ? 0 : 2); |
| 207 | clear_extra_columns(bitmap, pens, m_schaser_background_disable ? 0 : 2); |
| 211 | 208 | |
| 212 | 209 | return 0; |
| 213 | 210 | } |
| r20741 | r20742 | |
| 229 | 226 | UINT8 fore_color = m_colorram[offs & 0x1f9f] & 0x07; |
| 230 | 227 | |
| 231 | 228 | /* blue background */ |
| 232 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 2); |
| 229 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 2); |
| 233 | 230 | } |
| 234 | 231 | |
| 235 | | clear_extra_columns(machine(), bitmap, pens, 2); |
| 232 | clear_extra_columns(bitmap, pens, 2); |
| 236 | 233 | |
| 237 | 234 | return 0; |
| 238 | 235 | } |
| r20741 | r20742 | |
| 253 | 250 | UINT8 data = m_main_ram[offs]; |
| 254 | 251 | UINT8 fore_color = m_colorram[offs & 0x1f1f] & 0x07; |
| 255 | 252 | |
| 256 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0); |
| 253 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); |
| 257 | 254 | } |
| 258 | 255 | |
| 259 | | clear_extra_columns(machine(), bitmap, pens, 0); |
| 256 | clear_extra_columns(bitmap, pens, 0); |
| 260 | 257 | |
| 261 | 258 | return 0; |
| 262 | 259 | } |
| r20741 | r20742 | |
| 296 | 293 | |
| 297 | 294 | if ((color_map_base[color_address] & 0x08) || (cloud_y >= 64)) |
| 298 | 295 | { |
| 299 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, back_color); |
| 296 | set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color); |
| 300 | 297 | } |
| 301 | 298 | else |
| 302 | 299 | { |
| r20741 | r20742 | |
| 319 | 316 | color = (cloud_gfx[cloud_gfx_offs] & bit) ? 7 : back_color; |
| 320 | 317 | } |
| 321 | 318 | |
| 322 | | set_pixel(machine(), bitmap, y, x, pens, color); |
| 319 | set_pixel(bitmap, y, x, pens, color); |
| 323 | 320 | |
| 324 | 321 | x = x + 1; |
| 325 | 322 | data = data >> 1; |
| r20741 | r20742 | |
| 327 | 324 | } |
| 328 | 325 | } |
| 329 | 326 | |
| 330 | | clear_extra_columns(machine(), bitmap, pens, 6); |
| 327 | clear_extra_columns(bitmap, pens, 6); |
| 331 | 328 | |
| 332 | 329 | return 0; |
| 333 | 330 | } |
| r20741 | r20742 | |
| 348 | 345 | UINT8 data = m_main_ram[offs]; |
| 349 | 346 | UINT8 fore_color = ~m_colorram[offs & 0x1f9f] & 0x07; |
| 350 | 347 | |
| 351 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0); |
| 348 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); |
| 352 | 349 | } |
| 353 | 350 | |
| 354 | | clear_extra_columns(machine(), bitmap, pens, 0); |
| 351 | clear_extra_columns(bitmap, pens, 0); |
| 355 | 352 | |
| 356 | 353 | return 0; |
| 357 | 354 | } |
| r20741 | r20742 | |
| 374 | 371 | UINT8 data = m_main_ram[offs]; |
| 375 | 372 | UINT8 fore_color = m_colorram[color_address] & 0x07; |
| 376 | 373 | |
| 377 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0); |
| 374 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); |
| 378 | 375 | } |
| 379 | 376 | |
| 380 | | clear_extra_columns(machine(), bitmap, pens, 0); |
| 377 | clear_extra_columns(bitmap, pens, 0); |
| 381 | 378 | |
| 382 | 379 | return 0; |
| 383 | 380 | } |
| r20741 | r20742 | |
| 405 | 402 | UINT8 data = m_main_ram[offs]; |
| 406 | 403 | UINT8 fore_color = color_map_base[color_address] & 0x07; |
| 407 | 404 | |
| 408 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0); |
| 405 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); |
| 409 | 406 | } |
| 410 | 407 | |
| 411 | | clear_extra_columns(machine(), bitmap, pens, 0); |
| 408 | clear_extra_columns(bitmap, pens, 0); |
| 412 | 409 | |
| 413 | 410 | return 0; |
| 414 | 411 | } |
| r20741 | r20742 | |
| 429 | 426 | UINT8 data = m_main_ram[offs]; |
| 430 | 427 | UINT8 fore_color = m_colorram[offs & 0x1f9f] & 0x07; |
| 431 | 428 | |
| 432 | | set_8_pixels(machine(), bitmap, y, x, data, pens, fore_color, 0); |
| 429 | set_8_pixels(bitmap, y, x, data, pens, fore_color, 0); |
| 433 | 430 | } |
| 434 | 431 | |
| 435 | | clear_extra_columns(machine(), bitmap, pens, 0); |
| 432 | clear_extra_columns(bitmap, pens, 0); |
| 436 | 433 | |
| 437 | 434 | return 0; |
| 438 | 435 | } |
trunk/src/mame/video/atarifb.c
| r20741 | r20742 | |
| 14 | 14 | * |
| 15 | 15 | *************************************/ |
| 16 | 16 | |
| 17 | | static void get_tile_info_common( running_machine &machine, tile_data &tileinfo, tilemap_memory_index tile_index, UINT8 *alpha_videoram ) |
| 17 | void atarifb_state::get_tile_info_common( tile_data &tileinfo, tilemap_memory_index tile_index, UINT8 *alpha_videoram ) |
| 18 | 18 | { |
| 19 | 19 | int code = alpha_videoram[tile_index] & 0x3f; |
| 20 | 20 | int flip = alpha_videoram[tile_index] & 0x40; |
| r20741 | r20742 | |
| 23 | 23 | if (disable) |
| 24 | 24 | code = 0; /* I *know* this is a space */ |
| 25 | 25 | |
| 26 | | SET_TILE_INFO(0, code, 0, (flip ? TILE_FLIPX | TILE_FLIPY : 0)); |
| 26 | SET_TILE_INFO_MEMBER(0, code, 0, (flip ? TILE_FLIPX | TILE_FLIPY : 0)); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | TILE_GET_INFO_MEMBER(atarifb_state::alpha1_get_tile_info) |
| 31 | 31 | { |
| 32 | | get_tile_info_common(machine(), tileinfo, tile_index, m_alphap1_videoram); |
| 32 | get_tile_info_common(tileinfo, tile_index, m_alphap1_videoram); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | TILE_GET_INFO_MEMBER(atarifb_state::alpha2_get_tile_info) |
| 37 | 37 | { |
| 38 | | get_tile_info_common(machine(), tileinfo, tile_index, m_alphap2_videoram); |
| 38 | get_tile_info_common(tileinfo, tile_index, m_alphap2_videoram); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
| r20741 | r20742 | |
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | |
| 96 | | static void draw_playfield_and_alpha( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int playfield_x_offset, int playfield_y_offset ) |
| 96 | void atarifb_state::draw_playfield_and_alpha( bitmap_ind16 &bitmap, const rectangle &cliprect, int playfield_x_offset, int playfield_y_offset ) |
| 97 | 97 | { |
| 98 | | atarifb_state *state = machine.driver_data<atarifb_state>(); |
| 99 | 98 | const rectangle bigfield_area(4 * 8, 34 * 8 - 1, 0 * 8, 32 * 8 - 1); |
| 100 | 99 | |
| 101 | 100 | int scroll_x[1]; |
| 102 | 101 | int scroll_y[1]; |
| 103 | 102 | |
| 104 | | scroll_x[0] = - *state->m_scroll_register + 32 + playfield_x_offset; |
| 103 | scroll_x[0] = - *m_scroll_register + 32 + playfield_x_offset; |
| 105 | 104 | scroll_y[0] = 8 + playfield_y_offset; |
| 106 | 105 | |
| 107 | | copybitmap(bitmap, state->m_alpha1_tilemap->pixmap(), 0, 0, 35*8, 1*8, cliprect); |
| 108 | | copybitmap(bitmap, state->m_alpha2_tilemap->pixmap(), 0, 0, 0*8, 1*8, cliprect); |
| 109 | | copyscrollbitmap(bitmap, state->m_field_tilemap->pixmap(), 1, scroll_x, 1, scroll_y, bigfield_area); |
| 106 | copybitmap(bitmap, m_alpha1_tilemap->pixmap(), 0, 0, 35*8, 1*8, cliprect); |
| 107 | copybitmap(bitmap, m_alpha2_tilemap->pixmap(), 0, 0, 0*8, 1*8, cliprect); |
| 108 | copyscrollbitmap(bitmap, m_field_tilemap->pixmap(), 1, scroll_x, 1, scroll_y, bigfield_area); |
| 110 | 109 | } |
| 111 | 110 | |
| 112 | 111 | |
| 113 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int gfx, int is_soccer ) |
| 112 | void atarifb_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int gfx, int is_soccer ) |
| 114 | 113 | { |
| 115 | | atarifb_state *state = machine.driver_data<atarifb_state>(); |
| 116 | 114 | const rectangle bigfield_area(4 * 8, 34 * 8 - 1, 0 * 8, 32 * 8 - 1); |
| 117 | 115 | |
| 118 | 116 | int obj; |
| r20741 | r20742 | |
| 124 | 122 | int sx, sy; |
| 125 | 123 | int shade = 0; |
| 126 | 124 | |
| 127 | | sy = 255 - state->m_spriteram[obj * 2 + 1]; |
| 125 | sy = 255 - m_spriteram[obj * 2 + 1]; |
| 128 | 126 | if (sy == 255) |
| 129 | 127 | continue; |
| 130 | 128 | |
| 131 | | charcode = state->m_spriteram[obj * 2] & 0x3f; |
| 132 | | flipx = (state->m_spriteram[obj * 2] & 0x40); |
| 133 | | flipy = (state->m_spriteram[obj * 2] & 0x80); |
| 134 | | sx = state->m_spriteram[obj * 2 + 0x20] + 8 * 3; |
| 129 | charcode = m_spriteram[obj * 2] & 0x3f; |
| 130 | flipx = (m_spriteram[obj * 2] & 0x40); |
| 131 | flipy = (m_spriteram[obj * 2] & 0x80); |
| 132 | sx = m_spriteram[obj * 2 + 0x20] + 8 * 3; |
| 135 | 133 | |
| 136 | 134 | /* Note on Atari Soccer: */ |
| 137 | 135 | /* There are 3 sets of 2 bits each, where the 2 bits represent */ |
| r20741 | r20742 | |
| 139 | 137 | /* color of each bit in the sprite, but I haven't implemented it that way. */ |
| 140 | 138 | if (is_soccer) |
| 141 | 139 | { |
| 142 | | shade = ((state->m_spriteram[obj * 2 + 1 + 0x20]) & 0x07); |
| 140 | shade = ((m_spriteram[obj * 2 + 1 + 0x20]) & 0x07); |
| 143 | 141 | |
| 144 | | drawgfx_transpen(bitmap, bigfield_area, machine.gfx[gfx + 1], |
| 142 | drawgfx_transpen(bitmap, bigfield_area, machine().gfx[gfx + 1], |
| 145 | 143 | charcode, shade, |
| 146 | 144 | flipx, flipy, sx, sy, 0); |
| 147 | 145 | |
| 148 | | shade = ((state->m_spriteram[obj * 2 + 1 + 0x20]) & 0x08) >> 3; |
| 146 | shade = ((m_spriteram[obj * 2 + 1 + 0x20]) & 0x08) >> 3; |
| 149 | 147 | } |
| 150 | 148 | |
| 151 | | drawgfx_transpen(bitmap, bigfield_area, machine.gfx[gfx], |
| 149 | drawgfx_transpen(bitmap, bigfield_area, machine().gfx[gfx], |
| 152 | 150 | charcode, shade, |
| 153 | 151 | flipx, flipy, sx, sy, 0); |
| 154 | 152 | |
| r20741 | r20742 | |
| 160 | 158 | if ((charcode == 0x11) && (sy == 0x07)) |
| 161 | 159 | { |
| 162 | 160 | sy = 0xf1; /* When multiplexed, it's 0x10...why? */ |
| 163 | | drawgfx_transpen(bitmap, bigfield_area, machine.gfx[gfx], |
| 161 | drawgfx_transpen(bitmap, bigfield_area, machine().gfx[gfx], |
| 164 | 162 | charcode, 0, |
| 165 | 163 | flipx, flipy, sx, sy, 0); |
| 166 | 164 | } |
| r20741 | r20742 | |
| 171 | 169 | |
| 172 | 170 | UINT32 atarifb_state::screen_update_atarifb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 173 | 171 | { |
| 174 | | draw_playfield_and_alpha(machine(), bitmap, cliprect, 0, 0); |
| 172 | draw_playfield_and_alpha(bitmap, cliprect, 0, 0); |
| 175 | 173 | |
| 176 | | draw_sprites(machine(), bitmap, cliprect, 1, 0); |
| 174 | draw_sprites(bitmap, cliprect, 1, 0); |
| 177 | 175 | |
| 178 | 176 | return 0; |
| 179 | 177 | } |
| r20741 | r20742 | |
| 181 | 179 | |
| 182 | 180 | UINT32 atarifb_state::screen_update_abaseb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 183 | 181 | { |
| 184 | | draw_playfield_and_alpha(machine(), bitmap, cliprect, -8, 0); |
| 182 | draw_playfield_and_alpha(bitmap, cliprect, -8, 0); |
| 185 | 183 | |
| 186 | | draw_sprites(machine(), bitmap, cliprect, 1, 0); |
| 184 | draw_sprites(bitmap, cliprect, 1, 0); |
| 187 | 185 | |
| 188 | 186 | return 0; |
| 189 | 187 | } |
| r20741 | r20742 | |
| 191 | 189 | |
| 192 | 190 | UINT32 atarifb_state::screen_update_soccer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 193 | 191 | { |
| 194 | | draw_playfield_and_alpha(machine(), bitmap, cliprect, 0, 8); |
| 192 | draw_playfield_and_alpha(bitmap, cliprect, 0, 8); |
| 195 | 193 | |
| 196 | | draw_sprites(machine(), bitmap, cliprect, 2, 1); |
| 194 | draw_sprites(bitmap, cliprect, 2, 1); |
| 197 | 195 | |
| 198 | 196 | return 0; |
| 199 | 197 | } |
trunk/src/mame/video/buggychl.c
| r20741 | r20742 | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | | static void draw_sky( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 76 | void buggychl_state::draw_sky( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 77 | 77 | { |
| 78 | 78 | int x, y; |
| 79 | 79 | |
| r20741 | r20742 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
| 86 | | static void draw_bg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 86 | void buggychl_state::draw_bg( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 87 | 87 | { |
| 88 | | buggychl_state *state = machine.driver_data<buggychl_state>(); |
| 89 | 88 | int offs; |
| 90 | 89 | int scroll[256]; |
| 91 | 90 | |
| 92 | 91 | /* prevent wraparound */ |
| 93 | 92 | rectangle clip = cliprect; |
| 94 | | if (state->flip_screen_x()) clip.min_x += 8*8; |
| 93 | if (flip_screen_x()) clip.min_x += 8*8; |
| 95 | 94 | else clip.max_x -= 8*8; |
| 96 | 95 | |
| 97 | 96 | for (offs = 0; offs < 0x400; offs++) |
| 98 | 97 | { |
| 99 | | int code = state->m_videoram[0x400 + offs]; |
| 98 | int code = m_videoram[0x400 + offs]; |
| 100 | 99 | |
| 101 | 100 | int sx = offs % 32; |
| 102 | 101 | int sy = offs / 32; |
| 103 | 102 | |
| 104 | | if (state->flip_screen_x()) |
| 103 | if (flip_screen_x()) |
| 105 | 104 | sx = 31 - sx; |
| 106 | | if (state->flip_screen_y()) |
| 105 | if (flip_screen_y()) |
| 107 | 106 | sy = 31 - sy; |
| 108 | 107 | |
| 109 | | drawgfx_opaque(state->m_tmp_bitmap1, state->m_tmp_bitmap1.cliprect(), machine.gfx[0], |
| 108 | drawgfx_opaque(m_tmp_bitmap1, m_tmp_bitmap1.cliprect(), machine().gfx[0], |
| 110 | 109 | code, |
| 111 | 110 | 2, |
| 112 | | state->flip_screen_x(),state->flip_screen_y(), |
| 111 | flip_screen_x(),flip_screen_y(), |
| 113 | 112 | 8*sx,8*sy); |
| 114 | 113 | } |
| 115 | 114 | |
| 116 | 115 | /* first copy to a temp bitmap doing column scroll */ |
| 117 | 116 | for (offs = 0; offs < 256; offs++) |
| 118 | | scroll[offs] = -state->m_scrollv[offs / 8]; |
| 117 | scroll[offs] = -m_scrollv[offs / 8]; |
| 119 | 118 | |
| 120 | | copyscrollbitmap(state->m_tmp_bitmap2, state->m_tmp_bitmap1, 1, &state->m_bg_scrollx, 256, scroll, state->m_tmp_bitmap2.cliprect()); |
| 119 | copyscrollbitmap(m_tmp_bitmap2, m_tmp_bitmap1, 1, &m_bg_scrollx, 256, scroll, m_tmp_bitmap2.cliprect()); |
| 121 | 120 | |
| 122 | 121 | /* then copy to the screen doing row scroll */ |
| 123 | 122 | for (offs = 0; offs < 256; offs++) |
| 124 | | scroll[offs] = -state->m_scrollh[offs]; |
| 123 | scroll[offs] = -m_scrollh[offs]; |
| 125 | 124 | |
| 126 | | copyscrollbitmap_trans(bitmap, state->m_tmp_bitmap2, 256, scroll, 0, 0, clip, 32); |
| 125 | copyscrollbitmap_trans(bitmap, m_tmp_bitmap2, 256, scroll, 0, 0, clip, 32); |
| 127 | 126 | } |
| 128 | 127 | |
| 129 | 128 | |
| 130 | | static void draw_fg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 129 | void buggychl_state::draw_fg( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 131 | 130 | { |
| 132 | | buggychl_state *state = machine.driver_data<buggychl_state>(); |
| 133 | 131 | int offs; |
| 134 | 132 | |
| 135 | 133 | for (offs = 0; offs < 0x400; offs++) |
| 136 | 134 | { |
| 137 | 135 | int sx = offs % 32; |
| 138 | 136 | int sy = offs / 32; |
| 139 | | int flipx = state->flip_screen_x(); |
| 140 | | int flipy = state->flip_screen_y(); |
| 137 | int flipx = flip_screen_x(); |
| 138 | int flipy = flip_screen_y(); |
| 141 | 139 | |
| 142 | | int code = state->m_videoram[offs]; |
| 140 | int code = m_videoram[offs]; |
| 143 | 141 | |
| 144 | 142 | if (flipx) |
| 145 | 143 | sx = 31 - sx; |
| 146 | 144 | if (flipy) |
| 147 | 145 | sy = 31 - sy; |
| 148 | 146 | |
| 149 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0], |
| 147 | drawgfx_transpen(bitmap,cliprect,machine().gfx[0], |
| 150 | 148 | code, |
| 151 | 149 | 0, |
| 152 | 150 | flipx,flipy, |
| r20741 | r20742 | |
| 156 | 154 | } |
| 157 | 155 | |
| 158 | 156 | |
| 159 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 157 | void buggychl_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 160 | 158 | { |
| 161 | | buggychl_state *state = machine.driver_data<buggychl_state>(); |
| 162 | | UINT8 *spriteram = state->m_spriteram; |
| 159 | UINT8 *spriteram = m_spriteram; |
| 163 | 160 | int offs; |
| 164 | 161 | const UINT8 *gfx; |
| 165 | 162 | |
| 166 | 163 | g_profiler.start(PROFILER_USER1); |
| 167 | 164 | |
| 168 | | gfx = state->memregion("gfx2")->base(); |
| 169 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4) |
| 165 | gfx = memregion("gfx2")->base(); |
| 166 | for (offs = 0; offs < m_spriteram.bytes(); offs += 4) |
| 170 | 167 | { |
| 171 | 168 | int sx, sy, flipy, zoom, ch, x, px, y; |
| 172 | 169 | const UINT8 *lookup; |
| r20741 | r20742 | |
| 179 | 176 | zoomy_rom = gfx + (zoom << 6); |
| 180 | 177 | zoomx_rom = gfx + 0x2000 + (zoom << 3); |
| 181 | 178 | |
| 182 | | lookup = state->m_sprite_lookup + ((spriteram[offs + 2] & 0x7f) << 6); |
| 179 | lookup = m_sprite_lookup + ((spriteram[offs + 2] & 0x7f) << 6); |
| 183 | 180 | |
| 184 | 181 | for (y = 0; y < 64; y++) |
| 185 | 182 | { |
| 186 | | int dy = state->flip_screen_y() ? (255 - sy - y) : (sy + y); |
| 183 | int dy = flip_screen_y() ? (255 - sy - y) : (sy + y); |
| 187 | 184 | |
| 188 | 185 | if ((dy & ~0xff) == 0) |
| 189 | 186 | { |
| r20741 | r20742 | |
| 204 | 201 | code = 8 * (lookup[pos] | ((lookup[pos + 1] & 0x07) << 8)); |
| 205 | 202 | realflipy = (lookup[pos + 1] & 0x80) ? !flipy : flipy; |
| 206 | 203 | code += (realflipy ? (charline ^ 7) : charline); |
| 207 | | pendata = machine.gfx[1]->get_data(code); |
| 204 | pendata = machine().gfx[1]->get_data(code); |
| 208 | 205 | |
| 209 | 206 | for (x = 0; x < 16; x++) |
| 210 | 207 | { |
| 211 | 208 | int col = pendata[x]; |
| 212 | 209 | if (col) |
| 213 | 210 | { |
| 214 | | int dx = state->flip_screen_x() ? (255 - sx - px) : (sx + px); |
| 211 | int dx = flip_screen_x() ? (255 - sx - px) : (sx + px); |
| 215 | 212 | if ((dx & ~0xff) == 0) |
| 216 | | bitmap.pix16(dy, dx) = state->m_sprite_color_base + col; |
| 213 | bitmap.pix16(dy, dx) = m_sprite_color_base + col; |
| 217 | 214 | } |
| 218 | 215 | |
| 219 | 216 | /* the following line is almost certainly wrong */ |
| r20741 | r20742 | |
| 237 | 234 | bitmap.fill(0, cliprect); |
| 238 | 235 | |
| 239 | 236 | if (m_bg_on) |
| 240 | | draw_bg(machine(), bitmap, cliprect); |
| 237 | draw_bg(bitmap, cliprect); |
| 241 | 238 | |
| 242 | | draw_sprites(machine(), bitmap, cliprect); |
| 239 | draw_sprites(bitmap, cliprect); |
| 243 | 240 | |
| 244 | | draw_fg(machine(), bitmap, cliprect); |
| 241 | draw_fg(bitmap, cliprect); |
| 245 | 242 | |
| 246 | 243 | return 0; |
| 247 | 244 | } |
trunk/src/mame/video/brkthru.c
| r20741 | r20742 | |
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | #if 0 |
| 150 | | static void show_register( bitmap_ind16 &bitmap, int x, int y, UINT32 data ) |
| 150 | void brkthru_state::show_register( bitmap_ind16 &bitmap, int x, int y, UINT32 data ) |
| 151 | 151 | { |
| 152 | 152 | char buf[5]; |
| 153 | 153 | |
| r20741 | r20742 | |
| 157 | 157 | #endif |
| 158 | 158 | |
| 159 | 159 | |
| 160 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int prio ) |
| 160 | void brkthru_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int prio ) |
| 161 | 161 | { |
| 162 | | brkthru_state *state = machine.driver_data<brkthru_state>(); |
| 163 | 162 | int offs; |
| 164 | 163 | /* Draw the sprites. Note that it is important to draw them exactly in this */ |
| 165 | 164 | /* order, to have the correct priorities. */ |
| r20741 | r20742 | |
| 176 | 175 | ---- ---- ---- ---- ---- ---- xxxx xxxx = X position |
| 177 | 176 | */ |
| 178 | 177 | |
| 179 | | for (offs = 0;offs < state->m_spriteram.bytes(); offs += 4) |
| 178 | for (offs = 0;offs < m_spriteram.bytes(); offs += 4) |
| 180 | 179 | { |
| 181 | | if ((state->m_spriteram[offs] & 0x09) == prio) /* Enable && Low Priority */ |
| 180 | if ((m_spriteram[offs] & 0x09) == prio) /* Enable && Low Priority */ |
| 182 | 181 | { |
| 183 | 182 | int sx, sy, code, color; |
| 184 | 183 | |
| 185 | | sx = 240 - state->m_spriteram[offs + 3]; |
| 184 | sx = 240 - m_spriteram[offs + 3]; |
| 186 | 185 | if (sx < -7) |
| 187 | 186 | sx += 256; |
| 188 | 187 | |
| 189 | | sy = 240 - state->m_spriteram[offs + 2]; |
| 190 | | code = state->m_spriteram[offs + 1] + 128 * (state->m_spriteram[offs] & 0x06); |
| 191 | | color = (state->m_spriteram[offs] & 0xe0) >> 5; |
| 192 | | if (state->m_flipscreen) |
| 188 | sy = 240 - m_spriteram[offs + 2]; |
| 189 | code = m_spriteram[offs + 1] + 128 * (m_spriteram[offs] & 0x06); |
| 190 | color = (m_spriteram[offs] & 0xe0) >> 5; |
| 191 | if (m_flipscreen) |
| 193 | 192 | { |
| 194 | 193 | sx = 240 - sx; |
| 195 | 194 | sy = 240 - sy; |
| 196 | 195 | } |
| 197 | 196 | |
| 198 | | if (state->m_spriteram[offs] & 0x10) /* double height */ |
| 197 | if (m_spriteram[offs] & 0x10) /* double height */ |
| 199 | 198 | { |
| 200 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[9], |
| 199 | drawgfx_transpen(bitmap,cliprect,machine().gfx[9], |
| 201 | 200 | code & ~1, |
| 202 | 201 | color, |
| 203 | | state->m_flipscreen, state->m_flipscreen, |
| 204 | | sx, state->m_flipscreen ? sy + 16 : sy - 16,0); |
| 205 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[9], |
| 202 | m_flipscreen, m_flipscreen, |
| 203 | sx, m_flipscreen ? sy + 16 : sy - 16,0); |
| 204 | drawgfx_transpen(bitmap,cliprect,machine().gfx[9], |
| 206 | 205 | code | 1, |
| 207 | 206 | color, |
| 208 | | state->m_flipscreen, state->m_flipscreen, |
| 207 | m_flipscreen, m_flipscreen, |
| 209 | 208 | sx,sy,0); |
| 210 | 209 | |
| 211 | 210 | /* redraw with wraparound */ |
| 212 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[9], |
| 211 | drawgfx_transpen(bitmap,cliprect,machine().gfx[9], |
| 213 | 212 | code & ~1, |
| 214 | 213 | color, |
| 215 | | state->m_flipscreen, state->m_flipscreen, |
| 216 | | sx,(state->m_flipscreen ? sy + 16 : sy - 16) + 256,0); |
| 217 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[9], |
| 214 | m_flipscreen, m_flipscreen, |
| 215 | sx,(m_flipscreen ? sy + 16 : sy - 16) + 256,0); |
| 216 | drawgfx_transpen(bitmap,cliprect,machine().gfx[9], |
| 218 | 217 | code | 1, |
| 219 | 218 | color, |
| 220 | | state->m_flipscreen, state->m_flipscreen, |
| 219 | m_flipscreen, m_flipscreen, |
| 221 | 220 | sx,sy + 256,0); |
| 222 | 221 | |
| 223 | 222 | } |
| 224 | 223 | else |
| 225 | 224 | { |
| 226 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[9], |
| 225 | drawgfx_transpen(bitmap,cliprect,machine().gfx[9], |
| 227 | 226 | code, |
| 228 | 227 | color, |
| 229 | | state->m_flipscreen, state->m_flipscreen, |
| 228 | m_flipscreen, m_flipscreen, |
| 230 | 229 | sx,sy,0); |
| 231 | 230 | |
| 232 | 231 | /* redraw with wraparound */ |
| 233 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[9], |
| 232 | drawgfx_transpen(bitmap,cliprect,machine().gfx[9], |
| 234 | 233 | code, |
| 235 | 234 | color, |
| 236 | | state->m_flipscreen, state->m_flipscreen, |
| 235 | m_flipscreen, m_flipscreen, |
| 237 | 236 | sx,sy + 256,0); |
| 238 | 237 | |
| 239 | 238 | } |
| r20741 | r20742 | |
| 247 | 246 | m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 248 | 247 | |
| 249 | 248 | /* low priority sprites */ |
| 250 | | draw_sprites(machine(), bitmap, cliprect, 0x01); |
| 249 | draw_sprites(bitmap, cliprect, 0x01); |
| 251 | 250 | |
| 252 | 251 | /* draw background over low priority sprites */ |
| 253 | 252 | m_bg_tilemap->draw(bitmap, cliprect, 0, 0); |
| 254 | 253 | |
| 255 | 254 | /* high priority sprites */ |
| 256 | | draw_sprites(machine(), bitmap, cliprect, 0x09); |
| 255 | draw_sprites(bitmap, cliprect, 0x09); |
| 257 | 256 | |
| 258 | 257 | /* fg layer */ |
| 259 | 258 | m_fg_tilemap->draw(bitmap, cliprect, 0, 0); |
trunk/src/mame/video/aerofgt.c
| r20741 | r20742 | |
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | |
| 83 | | static void aerofgt_register_state_globals( running_machine &machine ) |
| 83 | void aerofgt_state::aerofgt_register_state_globals( ) |
| 84 | 84 | { |
| 85 | | aerofgt_state *state = machine.driver_data<aerofgt_state>(); |
| 86 | | state->save_item(NAME(state->m_gfxbank)); |
| 87 | | state->save_item(NAME(state->m_bank)); |
| 88 | | state->save_item(NAME(state->m_bg1scrollx)); |
| 89 | | state->save_item(NAME(state->m_bg1scrolly)); |
| 90 | | state->save_item(NAME(state->m_bg2scrollx)); |
| 91 | | state->save_item(NAME(state->m_bg2scrolly)); |
| 92 | | state->save_item(NAME(state->m_charpalettebank)); |
| 93 | | state->save_item(NAME(state->m_spritepalettebank)); |
| 85 | save_item(NAME(m_gfxbank)); |
| 86 | save_item(NAME(m_bank)); |
| 87 | save_item(NAME(m_bg1scrollx)); |
| 88 | save_item(NAME(m_bg1scrolly)); |
| 89 | save_item(NAME(m_bg2scrollx)); |
| 90 | save_item(NAME(m_bg2scrolly)); |
| 91 | save_item(NAME(m_charpalettebank)); |
| 92 | save_item(NAME(m_spritepalettebank)); |
| 94 | 93 | } |
| 95 | 94 | |
| 96 | 95 | VIDEO_START_MEMBER(aerofgt_state,pspikes) |
| r20741 | r20742 | |
| 100 | 99 | |
| 101 | 100 | m_sprite_gfx = 1; |
| 102 | 101 | |
| 103 | | aerofgt_register_state_globals(machine()); |
| 102 | aerofgt_register_state_globals(); |
| 104 | 103 | save_item(NAME(m_spikes91_lookup)); |
| 105 | 104 | } |
| 106 | 105 | |
| r20741 | r20742 | |
| 114 | 113 | m_spritepalettebank = 0; |
| 115 | 114 | m_sprite_gfx = 2; |
| 116 | 115 | |
| 117 | | aerofgt_register_state_globals(machine()); |
| 116 | aerofgt_register_state_globals(); |
| 118 | 117 | } |
| 119 | 118 | |
| 120 | 119 | VIDEO_START_MEMBER(aerofgt_state,spinlbrk) |
| r20741 | r20742 | |
| 132 | 131 | /* enemy sprites use ROM instead of RAM */ |
| 133 | 132 | m_spriteram2.set_target(reinterpret_cast<UINT16 *>(memregion("gfx5")->base()), 0x20000); |
| 134 | 133 | |
| 135 | | aerofgt_register_state_globals(machine()); |
| 134 | aerofgt_register_state_globals(); |
| 136 | 135 | } |
| 137 | 136 | |
| 138 | 137 | VIDEO_START_MEMBER(aerofgt_state,turbofrc) |
| r20741 | r20742 | |
| 145 | 144 | m_spritepalettebank = 0; |
| 146 | 145 | m_sprite_gfx = 2; |
| 147 | 146 | |
| 148 | | aerofgt_register_state_globals(machine()); |
| 147 | aerofgt_register_state_globals(); |
| 149 | 148 | } |
| 150 | 149 | |
| 151 | 150 | |
| r20741 | r20742 | |
| 190 | 189 | } |
| 191 | 190 | |
| 192 | 191 | |
| 193 | | static void setbank( running_machine &machine, tilemap_t *tmap, int num, int bank ) |
| 192 | void aerofgt_state::setbank( tilemap_t *tmap, int num, int bank ) |
| 194 | 193 | { |
| 195 | | aerofgt_state *state = machine.driver_data<aerofgt_state>(); |
| 196 | | if (state->m_gfxbank[num] != bank) |
| 194 | if (m_gfxbank[num] != bank) |
| 197 | 195 | { |
| 198 | | state->m_gfxbank[num] = bank; |
| 196 | m_gfxbank[num] = bank; |
| 199 | 197 | tmap->mark_all_dirty(); |
| 200 | 198 | } |
| 201 | 199 | } |
| r20741 | r20742 | |
| 204 | 202 | { |
| 205 | 203 | if (ACCESSING_BITS_0_7) |
| 206 | 204 | { |
| 207 | | setbank(machine(), m_bg1_tilemap, 0, (data & 0xf0) >> 4); |
| 208 | | setbank(machine(), m_bg1_tilemap, 1, data & 0x0f); |
| 205 | setbank(m_bg1_tilemap, 0, (data & 0xf0) >> 4); |
| 206 | setbank(m_bg1_tilemap, 1, data & 0x0f); |
| 209 | 207 | } |
| 210 | 208 | } |
| 211 | 209 | |
| r20741 | r20742 | |
| 214 | 212 | { |
| 215 | 213 | if (ACCESSING_BITS_8_15) |
| 216 | 214 | { |
| 217 | | setbank(machine(), m_bg1_tilemap, 0, (data & 0x0100) >> 8); |
| 218 | | setbank(machine(), m_bg2_tilemap, 1, (data & 0x0800) >> 11); |
| 215 | setbank(m_bg1_tilemap, 0, (data & 0x0100) >> 8); |
| 216 | setbank(m_bg2_tilemap, 1, (data & 0x0800) >> 11); |
| 219 | 217 | } |
| 220 | 218 | } |
| 221 | 219 | |
| r20741 | r20742 | |
| 223 | 221 | { |
| 224 | 222 | if (ACCESSING_BITS_0_7) |
| 225 | 223 | { |
| 226 | | setbank(machine(), m_bg1_tilemap, 0, (data & 0x07)); |
| 227 | | setbank(machine(), m_bg2_tilemap, 1, (data & 0x38) >> 3); |
| 224 | setbank(m_bg1_tilemap, 0, (data & 0x07)); |
| 225 | setbank(m_bg2_tilemap, 1, (data & 0x38) >> 3); |
| 228 | 226 | } |
| 229 | 227 | } |
| 230 | 228 | |
| r20741 | r20742 | |
| 234 | 232 | |
| 235 | 233 | data = COMBINE_DATA(&m_bank[offset]); |
| 236 | 234 | |
| 237 | | setbank(machine(), tmap, 4 * offset + 0, (data >> 0) & 0x0f); |
| 238 | | setbank(machine(), tmap, 4 * offset + 1, (data >> 4) & 0x0f); |
| 239 | | setbank(machine(), tmap, 4 * offset + 2, (data >> 8) & 0x0f); |
| 240 | | setbank(machine(), tmap, 4 * offset + 3, (data >> 12) & 0x0f); |
| 235 | setbank(tmap, 4 * offset + 0, (data >> 0) & 0x0f); |
| 236 | setbank(tmap, 4 * offset + 1, (data >> 4) & 0x0f); |
| 237 | setbank(tmap, 4 * offset + 2, (data >> 8) & 0x0f); |
| 238 | setbank(tmap, 4 * offset + 3, (data >> 12) & 0x0f); |
| 241 | 239 | } |
| 242 | 240 | |
| 243 | 241 | WRITE16_MEMBER(aerofgt_state::aerofgt_gfxbank_w) |
| r20741 | r20742 | |
| 246 | 244 | |
| 247 | 245 | data = COMBINE_DATA(&m_bank[offset]); |
| 248 | 246 | |
| 249 | | setbank(machine(), tmap, 2 * offset + 0, (data >> 8) & 0xff); |
| 250 | | setbank(machine(), tmap, 2 * offset + 1, (data >> 0) & 0xff); |
| 247 | setbank(tmap, 2 * offset + 0, (data >> 8) & 0xff); |
| 248 | setbank(tmap, 2 * offset + 1, (data >> 0) & 0xff); |
| 251 | 249 | } |
| 252 | 250 | |
| 253 | 251 | WRITE16_MEMBER(aerofgt_state::aerofgt_bg1scrollx_w) |
| r20741 | r20742 | |
| 422 | 420 | |
| 423 | 421 | m_sprite_gfx = 1; |
| 424 | 422 | |
| 425 | | aerofgt_register_state_globals(machine()); |
| 423 | aerofgt_register_state_globals(); |
| 426 | 424 | |
| 427 | 425 | save_item(NAME(m_wbbc97_bitmap_enable)); |
| 428 | 426 | } |
| r20741 | r20742 | |
| 432 | 430 | { |
| 433 | 431 | COMBINE_DATA(&m_rasterram[0x200 / 2]); |
| 434 | 432 | |
| 435 | | setbank(machine(), m_bg1_tilemap, 0, (data & 0xf000) >> 12); |
| 436 | | setbank(machine(), m_bg1_tilemap, 1, (data & 0x0f00) >> 8); |
| 433 | setbank(m_bg1_tilemap, 0, (data & 0xf000) >> 12); |
| 434 | setbank(m_bg1_tilemap, 1, (data & 0x0f00) >> 8); |
| 437 | 435 | } |
| 438 | 436 | |
| 439 | 437 | // BOOTLEG |
| r20741 | r20742 | |
| 449 | 447 | } |
| 450 | 448 | |
| 451 | 449 | // BOOTLEG |
| 452 | | static void aerfboo2_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri ) |
| 450 | void aerofgt_state::aerfboo2_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri ) |
| 453 | 451 | { |
| 454 | | aerofgt_state *state = machine.driver_data<aerofgt_state>(); |
| 455 | 452 | int attr_start, base, first; |
| 456 | 453 | |
| 457 | 454 | base = chip * 0x0200; |
| 458 | | // first = 4 * state->m_spriteram3[0x1fe + base]; |
| 455 | // first = 4 * m_spriteram3[0x1fe + base]; |
| 459 | 456 | first = 0; |
| 460 | 457 | |
| 461 | 458 | for (attr_start = base + 0x0200 - 4; attr_start >= first + base; attr_start -= 4) |
| r20741 | r20742 | |
| 465 | 462 | // some other drivers still use this wrong table, they have to be upgraded |
| 466 | 463 | // int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 }; |
| 467 | 464 | |
| 468 | | if (!(state->m_spriteram3[attr_start + 2] & 0x0080)) |
| 465 | if (!(m_spriteram3[attr_start + 2] & 0x0080)) |
| 469 | 466 | continue; |
| 470 | 467 | |
| 471 | | pri = state->m_spriteram3[attr_start + 2] & 0x0010; |
| 468 | pri = m_spriteram3[attr_start + 2] & 0x0010; |
| 472 | 469 | |
| 473 | 470 | if ( chip_disabled_pri & !pri) |
| 474 | 471 | continue; |
| 475 | 472 | if ((!chip_disabled_pri) & (pri >> 4)) |
| 476 | 473 | continue; |
| 477 | | ox = state->m_spriteram3[attr_start + 1] & 0x01ff; |
| 478 | | xsize = (state->m_spriteram3[attr_start + 2] & 0x0700) >> 8; |
| 479 | | zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12; |
| 480 | | oy = state->m_spriteram3[attr_start + 0] & 0x01ff; |
| 481 | | ysize = (state->m_spriteram3[attr_start + 2] & 0x7000) >> 12; |
| 482 | | zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12; |
| 483 | | flipx = state->m_spriteram3[attr_start + 2] & 0x0800; |
| 484 | | flipy = state->m_spriteram3[attr_start + 2] & 0x8000; |
| 485 | | color = (state->m_spriteram3[attr_start + 2] & 0x000f) + 16 * state->m_spritepalettebank; |
| 474 | ox = m_spriteram3[attr_start + 1] & 0x01ff; |
| 475 | xsize = (m_spriteram3[attr_start + 2] & 0x0700) >> 8; |
| 476 | zoomx = (m_spriteram3[attr_start + 1] & 0xf000) >> 12; |
| 477 | oy = m_spriteram3[attr_start + 0] & 0x01ff; |
| 478 | ysize = (m_spriteram3[attr_start + 2] & 0x7000) >> 12; |
| 479 | zoomy = (m_spriteram3[attr_start + 0] & 0xf000) >> 12; |
| 480 | flipx = m_spriteram3[attr_start + 2] & 0x0800; |
| 481 | flipy = m_spriteram3[attr_start + 2] & 0x8000; |
| 482 | color = (m_spriteram3[attr_start + 2] & 0x000f) + 16 * m_spritepalettebank; |
| 486 | 483 | |
| 487 | | map_start = state->m_spriteram3[attr_start + 3]; |
| 484 | map_start = m_spriteram3[attr_start + 3]; |
| 488 | 485 | |
| 489 | 486 | // aerofgt has this adjustment, but doing it here would break turbo force title screen |
| 490 | 487 | // ox += (xsize*zoomx+2)/4; |
| r20741 | r20742 | |
| 512 | 509 | sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16; |
| 513 | 510 | |
| 514 | 511 | if (chip == 0) |
| 515 | | code = state->m_spriteram1[map_start % (state->m_spriteram1.bytes()/2)]; |
| 512 | code = m_spriteram1[map_start % (m_spriteram1.bytes()/2)]; |
| 516 | 513 | else |
| 517 | | code = state->m_spriteram2[map_start % (state->m_spriteram2.bytes()/2)]; |
| 514 | code = m_spriteram2[map_start % (m_spriteram2.bytes()/2)]; |
| 518 | 515 | |
| 519 | | pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + chip], |
| 516 | pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx + chip], |
| 520 | 517 | code, |
| 521 | 518 | color, |
| 522 | 519 | flipx,flipy, |
| 523 | 520 | sx,sy, |
| 524 | 521 | zoomx << 11, zoomy << 11, |
| 525 | | machine.priority_bitmap,pri ? 0 : 2,15); |
| 522 | machine().priority_bitmap,pri ? 0 : 2,15); |
| 526 | 523 | map_start++; |
| 527 | 524 | } |
| 528 | 525 | |
| r20741 | r20742 | |
| 535 | 532 | } |
| 536 | 533 | |
| 537 | 534 | // BOOTLEG |
| 538 | | static void pspikesb_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 535 | void aerofgt_state::pspikesb_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 539 | 536 | { |
| 540 | | aerofgt_state *state = machine.driver_data<aerofgt_state>(); |
| 541 | 537 | int i; |
| 542 | 538 | |
| 543 | | for (i = 4; i < state->m_spriteram3.bytes() / 2; i += 4) |
| 539 | for (i = 4; i < m_spriteram3.bytes() / 2; i += 4) |
| 544 | 540 | { |
| 545 | 541 | int xpos, ypos, color, flipx, flipy, code; |
| 546 | 542 | |
| 547 | | if (state->m_spriteram3[i + 3 - 4] & 0x8000) |
| 543 | if (m_spriteram3[i + 3 - 4] & 0x8000) |
| 548 | 544 | break; |
| 549 | 545 | |
| 550 | | xpos = (state->m_spriteram3[i + 2] & 0x1ff) - 34; |
| 551 | | ypos = 256 - (state->m_spriteram3[i + 3 - 4] & 0x1ff) - 33; |
| 552 | | code = state->m_spriteram3[i + 0] & 0x1fff; |
| 546 | xpos = (m_spriteram3[i + 2] & 0x1ff) - 34; |
| 547 | ypos = 256 - (m_spriteram3[i + 3 - 4] & 0x1ff) - 33; |
| 548 | code = m_spriteram3[i + 0] & 0x1fff; |
| 553 | 549 | flipy = 0; |
| 554 | | flipx = state->m_spriteram3[i + 1] & 0x0800; |
| 555 | | color = state->m_spriteram3[i + 1] & 0x000f; |
| 550 | flipx = m_spriteram3[i + 1] & 0x0800; |
| 551 | color = m_spriteram3[i + 1] & 0x000f; |
| 556 | 552 | |
| 557 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx], |
| 553 | drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx], |
| 558 | 554 | code, |
| 559 | 555 | color, |
| 560 | 556 | flipx,flipy, |
| 561 | 557 | xpos,ypos,15); |
| 562 | 558 | |
| 563 | 559 | /* wrap around y */ |
| 564 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx], |
| 560 | drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx], |
| 565 | 561 | code, |
| 566 | 562 | color, |
| 567 | 563 | flipx,flipy, |
| r20741 | r20742 | |
| 571 | 567 | } |
| 572 | 568 | |
| 573 | 569 | // BOOTLEG |
| 574 | | static void spikes91_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 570 | void aerofgt_state::spikes91_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 575 | 571 | { |
| 576 | | aerofgt_state *state = machine.driver_data<aerofgt_state>(); |
| 577 | 572 | int i; |
| 578 | 573 | UINT8 *lookup; |
| 579 | | lookup = state->memregion("user1")->base(); |
| 580 | | state->m_spritepalettebank = 1; |
| 574 | lookup = memregion("user1")->base(); |
| 575 | m_spritepalettebank = 1; |
| 581 | 576 | |
| 582 | | for (i = state->m_spriteram3.bytes() / 2 - 4; i >= 4; i -= 4) |
| 577 | for (i = m_spriteram3.bytes() / 2 - 4; i >= 4; i -= 4) |
| 583 | 578 | { |
| 584 | 579 | int xpos, ypos, color, flipx, flipy, code, realcode; |
| 585 | 580 | |
| 586 | | code = state->m_spriteram3[i + 0] & 0x1fff; |
| 581 | code = m_spriteram3[i + 0] & 0x1fff; |
| 587 | 582 | |
| 588 | 583 | if (!code) |
| 589 | 584 | continue; |
| 590 | 585 | |
| 591 | | xpos = (state->m_spriteram3[i + 2] & 0x01ff) - 16; |
| 592 | | ypos = 256 - (state->m_spriteram3[i + 1] & 0x00ff) - 26; |
| 586 | xpos = (m_spriteram3[i + 2] & 0x01ff) - 16; |
| 587 | ypos = 256 - (m_spriteram3[i + 1] & 0x00ff) - 26; |
| 593 | 588 | flipy = 0; |
| 594 | | flipx = state->m_spriteram3[i + 3] & 0x8000; |
| 595 | | color = ((state->m_spriteram3[i + 3] & 0x00f0) >> 4); |
| 589 | flipx = m_spriteram3[i + 3] & 0x8000; |
| 590 | color = ((m_spriteram3[i + 3] & 0x00f0) >> 4); |
| 596 | 591 | |
| 597 | | code |= state->m_spikes91_lookup * 0x2000; |
| 592 | code |= m_spikes91_lookup * 0x2000; |
| 598 | 593 | |
| 599 | 594 | realcode = (lookup[code] << 8) + lookup[0x10000 + code]; |
| 600 | 595 | |
| 601 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx], |
| 596 | drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx], |
| 602 | 597 | realcode, |
| 603 | 598 | color, |
| 604 | 599 | flipx,flipy, |
| 605 | 600 | xpos,ypos,15); |
| 606 | 601 | |
| 607 | 602 | /* wrap around y */ |
| 608 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx], |
| 603 | drawgfx_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx], |
| 609 | 604 | realcode, |
| 610 | 605 | color, |
| 611 | 606 | flipx,flipy, |
| r20741 | r20742 | |
| 614 | 609 | } |
| 615 | 610 | |
| 616 | 611 | // BOOTLEG |
| 617 | | static void aerfboot_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 612 | void aerofgt_state::aerfboot_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 618 | 613 | { |
| 619 | | aerofgt_state *state = machine.driver_data<aerofgt_state>(); |
| 620 | 614 | int attr_start, last; |
| 621 | 615 | |
| 622 | | last = ((state->m_rasterram[0x404 / 2] << 5) - 0x8000) / 2; |
| 616 | last = ((m_rasterram[0x404 / 2] << 5) - 0x8000) / 2; |
| 623 | 617 | |
| 624 | | for (attr_start = state->m_spriteram3.bytes() / 2 - 4; attr_start >= last; attr_start -= 4) |
| 618 | for (attr_start = m_spriteram3.bytes() / 2 - 4; attr_start >= last; attr_start -= 4) |
| 625 | 619 | { |
| 626 | 620 | int code; |
| 627 | 621 | int ox, oy, sx, sy, zoomx, zoomy, flipx, flipy, color, pri; |
| 628 | 622 | |
| 629 | | ox = state->m_spriteram3[attr_start + 1] & 0x01ff; |
| 630 | | oy = state->m_spriteram3[attr_start + 0] & 0x01ff; |
| 631 | | flipx = state->m_spriteram3[attr_start + 2] & 0x0800; |
| 632 | | flipy = state->m_spriteram3[attr_start + 2] & 0x8000; |
| 633 | | color = state->m_spriteram3[attr_start + 2] & 0x000f; |
| 623 | ox = m_spriteram3[attr_start + 1] & 0x01ff; |
| 624 | oy = m_spriteram3[attr_start + 0] & 0x01ff; |
| 625 | flipx = m_spriteram3[attr_start + 2] & 0x0800; |
| 626 | flipy = m_spriteram3[attr_start + 2] & 0x8000; |
| 627 | color = m_spriteram3[attr_start + 2] & 0x000f; |
| 634 | 628 | |
| 635 | | zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12; |
| 636 | | zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12; |
| 637 | | pri = state->m_spriteram3[attr_start + 2] & 0x0010; |
| 638 | | code = state->m_spriteram3[attr_start + 3] & 0x1fff; |
| 629 | zoomx = (m_spriteram3[attr_start + 1] & 0xf000) >> 12; |
| 630 | zoomy = (m_spriteram3[attr_start + 0] & 0xf000) >> 12; |
| 631 | pri = m_spriteram3[attr_start + 2] & 0x0010; |
| 632 | code = m_spriteram3[attr_start + 3] & 0x1fff; |
| 639 | 633 | |
| 640 | | if (!(state->m_spriteram3[attr_start + 2] & 0x0040)) |
| 634 | if (!(m_spriteram3[attr_start + 2] & 0x0040)) |
| 641 | 635 | code |= 0x2000; |
| 642 | 636 | |
| 643 | 637 | zoomx = 32 + zoomx; |
| r20741 | r20742 | |
| 647 | 641 | |
| 648 | 642 | sx = ((ox + 16 + 3) & 0x1ff) - 16; |
| 649 | 643 | |
| 650 | | pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + (code >= 0x1000 ? 0 : 1)], |
| 644 | pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx + (code >= 0x1000 ? 0 : 1)], |
| 651 | 645 | code, |
| 652 | 646 | color, |
| 653 | 647 | flipx,flipy, |
| 654 | 648 | sx,sy, |
| 655 | 649 | zoomx << 11,zoomy << 11, |
| 656 | | machine.priority_bitmap,pri ? 0 : 2,15); |
| 650 | machine().priority_bitmap,pri ? 0 : 2,15); |
| 657 | 651 | |
| 658 | 652 | } |
| 659 | 653 | |
| 660 | | last = ((state->m_rasterram[0x402 / 2] << 5) - 0x8000) / 2; |
| 654 | last = ((m_rasterram[0x402 / 2] << 5) - 0x8000) / 2; |
| 661 | 655 | |
| 662 | | for (attr_start = ((state->m_spriteram3.bytes() / 2) / 2) - 4; attr_start >= last; attr_start -= 4) |
| 656 | for (attr_start = ((m_spriteram3.bytes() / 2) / 2) - 4; attr_start >= last; attr_start -= 4) |
| 663 | 657 | { |
| 664 | 658 | int code; |
| 665 | 659 | int ox, oy, sx, sy, zoomx, zoomy, flipx, flipy, color, pri; |
| 666 | 660 | |
| 667 | | ox = state->m_spriteram3[attr_start + 1] & 0x01ff; |
| 668 | | oy = state->m_spriteram3[attr_start + 0] & 0x01ff; |
| 669 | | flipx = state->m_spriteram3[attr_start + 2] & 0x0800; |
| 670 | | flipy = state->m_spriteram3[attr_start + 2] & 0x8000; |
| 671 | | color = state->m_spriteram3[attr_start + 2] & 0x000f; |
| 661 | ox = m_spriteram3[attr_start + 1] & 0x01ff; |
| 662 | oy = m_spriteram3[attr_start + 0] & 0x01ff; |
| 663 | flipx = m_spriteram3[attr_start + 2] & 0x0800; |
| 664 | flipy = m_spriteram3[attr_start + 2] & 0x8000; |
| 665 | color = m_spriteram3[attr_start + 2] & 0x000f; |
| 672 | 666 | |
| 673 | | zoomx = (state->m_spriteram3[attr_start + 1] & 0xf000) >> 12; |
| 674 | | zoomy = (state->m_spriteram3[attr_start + 0] & 0xf000) >> 12; |
| 675 | | pri = state->m_spriteram3[attr_start + 2] & 0x0010; |
| 676 | | code = state->m_spriteram3[attr_start + 3] & 0x1fff; |
| 667 | zoomx = (m_spriteram3[attr_start + 1] & 0xf000) >> 12; |
| 668 | zoomy = (m_spriteram3[attr_start + 0] & 0xf000) >> 12; |
| 669 | pri = m_spriteram3[attr_start + 2] & 0x0010; |
| 670 | code = m_spriteram3[attr_start + 3] & 0x1fff; |
| 677 | 671 | |
| 678 | | if (!(state->m_spriteram3[attr_start + 2] & 0x0040)) |
| 672 | if (!(m_spriteram3[attr_start + 2] & 0x0040)) |
| 679 | 673 | code |= 0x2000; |
| 680 | 674 | |
| 681 | 675 | zoomx = 32 + zoomx; |
| r20741 | r20742 | |
| 685 | 679 | |
| 686 | 680 | sx = ((ox + 16 + 3) & 0x1ff) - 16; |
| 687 | 681 | |
| 688 | | pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[state->m_sprite_gfx + (code >= 0x1000 ? 0 : 1)], |
| 682 | pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[m_sprite_gfx + (code >= 0x1000 ? 0 : 1)], |
| 689 | 683 | code, |
| 690 | 684 | color, |
| 691 | 685 | flipx,flipy, |
| 692 | 686 | sx,sy, |
| 693 | 687 | zoomx << 11,zoomy << 11, |
| 694 | | machine.priority_bitmap,pri ? 0 : 2,15); |
| 688 | machine().priority_bitmap,pri ? 0 : 2,15); |
| 695 | 689 | |
| 696 | 690 | } |
| 697 | 691 | } |
| 698 | 692 | |
| 699 | 693 | // BOOTLEG |
| 700 | | static void wbbc97_draw_bitmap( running_machine &machine, bitmap_rgb32 &bitmap ) |
| 694 | void aerofgt_state::wbbc97_draw_bitmap( bitmap_rgb32 &bitmap ) |
| 701 | 695 | { |
| 702 | | aerofgt_state *state = machine.driver_data<aerofgt_state>(); |
| 703 | 696 | int x, y, count; |
| 704 | 697 | |
| 705 | 698 | count = 16; // weird, the bitmap doesn't start at 0? |
| 706 | 699 | for (y = 0; y < 256; y++) |
| 707 | 700 | for (x = 0; x < 512; x++) |
| 708 | 701 | { |
| 709 | | int color = state->m_bitmapram[count] >> 1; |
| 702 | int color = m_bitmapram[count] >> 1; |
| 710 | 703 | |
| 711 | 704 | /* data is GRB; convert to RGB */ |
| 712 | 705 | rgb_t pen = MAKE_RGB(pal5bit((color & 0x3e0) >> 5), pal5bit((color & 0x7c00) >> 10), pal5bit(color & 0x1f)); |
| 713 | | bitmap.pix32(y, (10 + x - state->m_rasterram[(y & 0x7f)]) & 0x1ff) = pen; |
| 706 | bitmap.pix32(y, (10 + x - m_rasterram[(y & 0x7f)]) & 0x1ff) = pen; |
| 714 | 707 | |
| 715 | 708 | count++; |
| 716 | 709 | count &= 0x1ffff; |
| r20741 | r20742 | |
| 729 | 722 | m_bg1_tilemap->set_scrolly(0, scrolly); |
| 730 | 723 | |
| 731 | 724 | m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 732 | | pspikesb_draw_sprites(machine(), bitmap, cliprect); |
| 725 | pspikesb_draw_sprites(bitmap, cliprect); |
| 733 | 726 | return 0; |
| 734 | 727 | } |
| 735 | 728 | |
| r20741 | r20742 | |
| 749 | 742 | m_bg1_tilemap->set_scrolly(0, scrolly); |
| 750 | 743 | |
| 751 | 744 | m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 752 | | spikes91_draw_sprites(machine(), bitmap, cliprect); |
| 745 | spikes91_draw_sprites(bitmap, cliprect); |
| 753 | 746 | |
| 754 | 747 | /* we could use a tilemap, but it's easier to just do it here */ |
| 755 | 748 | count = 0; |
| r20741 | r20742 | |
| 793 | 786 | m_bg2_tilemap->draw(bitmap, cliprect, 0, 1); |
| 794 | 787 | |
| 795 | 788 | /* we use the priority buffer so sprites are drawn front to back */ |
| 796 | | aerfboot_draw_sprites(machine(), bitmap, cliprect); |
| 789 | aerfboot_draw_sprites(bitmap, cliprect); |
| 797 | 790 | return 0; |
| 798 | 791 | } |
| 799 | 792 | |
| r20741 | r20742 | |
| 817 | 810 | m_bg2_tilemap->draw(bitmap, cliprect, 0, 1); |
| 818 | 811 | |
| 819 | 812 | /* we use the priority buffer so sprites are drawn front to back */ |
| 820 | | aerfboo2_draw_sprites(machine(), bitmap, cliprect, 1, -1); //ship |
| 821 | | aerfboo2_draw_sprites(machine(), bitmap, cliprect, 1, 0); //intro |
| 822 | | aerfboo2_draw_sprites(machine(), bitmap, cliprect, 0, -1); //enemy |
| 823 | | aerfboo2_draw_sprites(machine(), bitmap, cliprect, 0, 0); //enemy |
| 813 | aerfboo2_draw_sprites(bitmap, cliprect, 1, -1); //ship |
| 814 | aerfboo2_draw_sprites(bitmap, cliprect, 1, 0); //intro |
| 815 | aerfboo2_draw_sprites(bitmap, cliprect, 0, -1); //enemy |
| 816 | aerfboo2_draw_sprites(bitmap, cliprect, 0, 0); //enemy |
| 824 | 817 | return 0; |
| 825 | 818 | } |
| 826 | 819 | |
| r20741 | r20742 | |
| 839 | 832 | |
| 840 | 833 | if (m_wbbc97_bitmap_enable) |
| 841 | 834 | { |
| 842 | | wbbc97_draw_bitmap(machine(), bitmap); |
| 835 | wbbc97_draw_bitmap(bitmap); |
| 843 | 836 | m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 844 | 837 | } |
| 845 | 838 | else |
trunk/src/mame/video/argus.c
| r20741 | r20742 | |
| 259 | 259 | Initialize and destroy video hardware emulation |
| 260 | 260 | ***************************************************************************/ |
| 261 | 261 | |
| 262 | | static void reset_common(running_machine &machine) |
| 262 | void argus_state::reset_common() |
| 263 | 263 | { |
| 264 | | argus_state *state = machine.driver_data<argus_state>(); |
| 265 | | state->m_bg_status = 0x01; |
| 266 | | state->m_flipscreen = 0; |
| 267 | | state->m_palette_intensity = 0; |
| 264 | m_bg_status = 0x01; |
| 265 | m_flipscreen = 0; |
| 266 | m_palette_intensity = 0; |
| 268 | 267 | } |
| 269 | 268 | |
| 270 | 269 | VIDEO_START_MEMBER(argus_state,argus) |
| r20741 | r20742 | |
| 290 | 289 | m_bg0_scrollx[0] = 0; |
| 291 | 290 | m_bg0_scrollx[1] = 0; |
| 292 | 291 | memset(m_dummy_bg0ram, 0, 0x800); |
| 293 | | reset_common(machine()); |
| 292 | reset_common(); |
| 294 | 293 | } |
| 295 | 294 | |
| 296 | 295 | VIDEO_START_MEMBER(argus_state,valtric) |
| r20741 | r20742 | |
| 309 | 308 | VIDEO_RESET_MEMBER(argus_state,valtric) |
| 310 | 309 | { |
| 311 | 310 | m_valtric_mosaic = 0x0f; |
| 312 | | reset_common(machine()); |
| 311 | reset_common(); |
| 313 | 312 | } |
| 314 | 313 | |
| 315 | 314 | VIDEO_START_MEMBER(argus_state,butasan) |
| r20741 | r20742 | |
| 339 | 338 | m_butasan_bg1_status = 0x01; |
| 340 | 339 | memset(m_butasan_pagedram[0], 0, 0x1000); |
| 341 | 340 | memset(m_butasan_pagedram[1], 0, 0x1000); |
| 342 | | reset_common(machine()); |
| 341 | reset_common(); |
| 343 | 342 | } |
| 344 | 343 | |
| 345 | 344 | |
| r20741 | r20742 | |
| 348 | 347 | ***************************************************************************/ |
| 349 | 348 | |
| 350 | 349 | /* Write bg0 pattern data to dummy bg0 ram */ |
| 351 | | static void argus_write_dummy_rams(running_machine &machine, int dramoffs, int vromoffs) |
| 350 | void argus_state::argus_write_dummy_rams(int dramoffs, int vromoffs) |
| 352 | 351 | { |
| 353 | | argus_state *state = machine.driver_data<argus_state>(); |
| 354 | 352 | int i; |
| 355 | 353 | int voffs; |
| 356 | 354 | int offs; |
| 357 | 355 | |
| 358 | | UINT8 *VROM1 = state->memregion("user1")->base(); /* "ag_15.bin" */ |
| 359 | | UINT8 *VROM2 = state->memregion("user2")->base(); /* "ag_16.bin" */ |
| 356 | UINT8 *VROM1 = memregion("user1")->base(); /* "ag_15.bin" */ |
| 357 | UINT8 *VROM2 = memregion("user2")->base(); /* "ag_16.bin" */ |
| 360 | 358 | |
| 361 | 359 | /* offset in pattern data */ |
| 362 | 360 | offs = VROM1[vromoffs] | (VROM1[vromoffs + 1] << 8); |
| r20741 | r20742 | |
| 365 | 363 | voffs = offs * 16; |
| 366 | 364 | for (i = 0; i < 8; i++) |
| 367 | 365 | { |
| 368 | | state->m_dummy_bg0ram[dramoffs] = VROM2[voffs]; |
| 369 | | state->m_dummy_bg0ram[dramoffs + 1] = VROM2[voffs + 1]; |
| 370 | | state->m_bg0_tilemap->mark_tile_dirty(dramoffs >> 1); |
| 366 | m_dummy_bg0ram[dramoffs] = VROM2[voffs]; |
| 367 | m_dummy_bg0ram[dramoffs + 1] = VROM2[voffs + 1]; |
| 368 | m_bg0_tilemap->mark_tile_dirty(dramoffs >> 1); |
| 371 | 369 | dramoffs += 2; |
| 372 | 370 | voffs += 2; |
| 373 | 371 | } |
| 374 | 372 | } |
| 375 | 373 | |
| 376 | | static void argus_change_palette(running_machine &machine, int color, int lo_offs, int hi_offs) |
| 374 | void argus_state::argus_change_palette(int color, int lo_offs, int hi_offs) |
| 377 | 375 | { |
| 378 | | argus_state *state = machine.driver_data<argus_state>(); |
| 379 | | UINT8 lo = state->m_paletteram[lo_offs]; |
| 380 | | UINT8 hi = state->m_paletteram[hi_offs]; |
| 376 | UINT8 lo = m_paletteram[lo_offs]; |
| 377 | UINT8 hi = m_paletteram[hi_offs]; |
| 381 | 378 | jal_blend_set(color, hi & 0x0f); |
| 382 | | palette_set_color_rgb(machine, color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4)); |
| 379 | palette_set_color_rgb(machine(), color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4)); |
| 383 | 380 | } |
| 384 | 381 | |
| 385 | | static void argus_change_bg_palette(running_machine &machine, int color, int lo_offs, int hi_offs) |
| 382 | void argus_state::argus_change_bg_palette(int color, int lo_offs, int hi_offs) |
| 386 | 383 | { |
| 387 | | argus_state *state = machine.driver_data<argus_state>(); |
| 388 | 384 | UINT8 r,g,b,lo,hi,ir,ig,ib,ix; |
| 389 | 385 | rgb_t rgb,irgb; |
| 390 | 386 | |
| 391 | 387 | /* red,green,blue intensities */ |
| 392 | | ir = pal4bit(state->m_palette_intensity >> 12); |
| 393 | | ig = pal4bit(state->m_palette_intensity >> 8); |
| 394 | | ib = pal4bit(state->m_palette_intensity >> 4); |
| 395 | | ix = state->m_palette_intensity & 0x0f; |
| 388 | ir = pal4bit(m_palette_intensity >> 12); |
| 389 | ig = pal4bit(m_palette_intensity >> 8); |
| 390 | ib = pal4bit(m_palette_intensity >> 4); |
| 391 | ix = m_palette_intensity & 0x0f; |
| 396 | 392 | |
| 397 | 393 | irgb = MAKE_RGB(ir,ig,ib); |
| 398 | 394 | |
| 399 | | lo = state->m_paletteram[lo_offs]; |
| 400 | | hi = state->m_paletteram[hi_offs]; |
| 395 | lo = m_paletteram[lo_offs]; |
| 396 | hi = m_paletteram[hi_offs]; |
| 401 | 397 | |
| 402 | 398 | /* red,green,blue component */ |
| 403 | 399 | r = pal4bit(lo >> 4); |
| r20741 | r20742 | |
| 405 | 401 | b = pal4bit(hi >> 4); |
| 406 | 402 | |
| 407 | 403 | /* Grey background enable */ |
| 408 | | if (state->m_bg_status & 2) |
| 404 | if (m_bg_status & 2) |
| 409 | 405 | { |
| 410 | 406 | UINT8 val = (r + g + b) / 3; |
| 411 | 407 | rgb = MAKE_RGB(val,val,val); |
| r20741 | r20742 | |
| 417 | 413 | |
| 418 | 414 | rgb = jal_blend_func(rgb,irgb,ix); |
| 419 | 415 | |
| 420 | | palette_set_color(machine,color,rgb); |
| 416 | palette_set_color(machine(),color,rgb); |
| 421 | 417 | } |
| 422 | 418 | |
| 423 | 419 | |
| r20741 | r20742 | |
| 465 | 461 | |
| 466 | 462 | for (offs = 0x400; offs < 0x500; offs++) |
| 467 | 463 | { |
| 468 | | argus_change_bg_palette(machine(), (offs - 0x400) + 0x080, offs, offs + 0x400); |
| 464 | argus_change_bg_palette((offs - 0x400) + 0x080, offs, offs + 0x400); |
| 469 | 465 | } |
| 470 | 466 | } |
| 471 | 467 | } |
| r20741 | r20742 | |
| 484 | 480 | |
| 485 | 481 | for (offs = 0x400; offs < 0x600; offs += 2) |
| 486 | 482 | { |
| 487 | | argus_change_bg_palette(machine(), ((offs - 0x400) >> 1) + 0x100, offs & ~1, offs | 1); |
| 483 | argus_change_bg_palette(((offs - 0x400) >> 1) + 0x100, offs & ~1, offs | 1); |
| 488 | 484 | } |
| 489 | 485 | } |
| 490 | 486 | } |
| r20741 | r20742 | |
| 526 | 522 | { |
| 527 | 523 | offset &= 0x07f; |
| 528 | 524 | |
| 529 | | argus_change_palette(machine(), offset, offset, offset + 0x080); |
| 525 | argus_change_palette(offset, offset, offset + 0x080); |
| 530 | 526 | |
| 531 | 527 | if (offset == 0x07f || offset == 0x0ff) |
| 532 | 528 | { |
| 533 | 529 | m_palette_intensity = m_paletteram[0x0ff] | (m_paletteram[0x07f] << 8); |
| 534 | 530 | |
| 535 | 531 | for (offs = 0x400; offs < 0x500; offs++) |
| 536 | | argus_change_bg_palette(machine(), (offs & 0xff) + 0x080, offs, offs + 0x400); |
| 532 | argus_change_bg_palette((offs & 0xff) + 0x080, offs, offs + 0x400); |
| 537 | 533 | } |
| 538 | 534 | } |
| 539 | 535 | else if ((offset >= 0x400 && offset <= 0x4ff) || |
| r20741 | r20742 | |
| 542 | 538 | offs = offset & 0xff; |
| 543 | 539 | offset = offs | 0x400; |
| 544 | 540 | |
| 545 | | argus_change_bg_palette(machine(), offs + 0x080, offset, offset + 0x400); |
| 541 | argus_change_bg_palette(offs + 0x080, offset, offset + 0x400); |
| 546 | 542 | } |
| 547 | 543 | else if ((offset >= 0x500 && offset <= 0x5ff) || |
| 548 | 544 | (offset >= 0x900 && offset <= 0x9ff)) /* BG1 color */ |
| r20741 | r20742 | |
| 550 | 546 | offs = offset & 0xff; |
| 551 | 547 | offset = offs | 0x500; |
| 552 | 548 | |
| 553 | | argus_change_palette(machine(), offs + 0x180, offset, offset + 0x400); |
| 549 | argus_change_palette(offs + 0x180, offset, offset + 0x400); |
| 554 | 550 | } |
| 555 | 551 | else if ((offset >= 0x700 && offset <= 0x7ff) || |
| 556 | 552 | (offset >= 0xb00 && offset <= 0xbff)) /* text color */ |
| r20741 | r20742 | |
| 558 | 554 | offs = offset & 0xff; |
| 559 | 555 | offset = offs | 0x700; |
| 560 | 556 | |
| 561 | | argus_change_palette(machine(), offs + 0x280, offset, offset + 0x400); |
| 557 | argus_change_palette(offs + 0x280, offset, offset + 0x400); |
| 562 | 558 | } |
| 563 | 559 | } |
| 564 | 560 | |
| r20741 | r20742 | |
| 568 | 564 | |
| 569 | 565 | if (offset <= 0x1ff) /* Sprite color */ |
| 570 | 566 | { |
| 571 | | argus_change_palette(machine(), offset >> 1, offset & ~1, offset | 1); |
| 567 | argus_change_palette(offset >> 1, offset & ~1, offset | 1); |
| 572 | 568 | |
| 573 | 569 | if (offset == 0x1fe || offset == 0x1ff) |
| 574 | 570 | { |
| r20741 | r20742 | |
| 577 | 573 | m_palette_intensity = m_paletteram[0x1ff] | (m_paletteram[0x1fe] << 8); |
| 578 | 574 | |
| 579 | 575 | for (offs = 0x400; offs < 0x600; offs += 2) |
| 580 | | argus_change_bg_palette(machine(), ((offs & 0x1ff) >> 1) + 0x100, offs & ~1, offs | 1); |
| 576 | argus_change_bg_palette(((offs & 0x1ff) >> 1) + 0x100, offs & ~1, offs | 1); |
| 581 | 577 | } |
| 582 | 578 | } |
| 583 | 579 | else if (offset >= 0x400 && offset <= 0x5ff) /* BG color */ |
| 584 | 580 | { |
| 585 | | argus_change_bg_palette(machine(), ((offset & 0x1ff) >> 1) + 0x100, offset & ~1, offset | 1); |
| 581 | argus_change_bg_palette(((offset & 0x1ff) >> 1) + 0x100, offset & ~1, offset | 1); |
| 586 | 582 | } |
| 587 | 583 | else if (offset >= 0x600 && offset <= 0x7ff) /* Text color */ |
| 588 | 584 | { |
| 589 | | argus_change_palette(machine(), ((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1); |
| 585 | argus_change_palette(((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1); |
| 590 | 586 | } |
| 591 | 587 | } |
| 592 | 588 | |
| r20741 | r20742 | |
| 596 | 592 | |
| 597 | 593 | if (offset <= 0x1ff) /* BG0 color */ |
| 598 | 594 | { |
| 599 | | argus_change_palette(machine(), (offset >> 1) + 0x100, offset & ~1, offset | 1); |
| 595 | argus_change_palette((offset >> 1) + 0x100, offset & ~1, offset | 1); |
| 600 | 596 | } |
| 601 | 597 | else if (offset <= 0x23f) /* BG1 color */ |
| 602 | 598 | { |
| 603 | | argus_change_palette(machine(), ((offset & 0x3f) >> 1) + 0x0c0, offset & ~1, offset | 1); |
| 599 | argus_change_palette(((offset & 0x3f) >> 1) + 0x0c0, offset & ~1, offset | 1); |
| 604 | 600 | } |
| 605 | 601 | else if (offset >= 0x400 && offset <= 0x47f) /* Sprite color */ |
| 606 | 602 | { /* 16 colors */ |
| 607 | | argus_change_palette(machine(), (offset & 0x7f) >> 1, offset & ~1, offset | 1); |
| 603 | argus_change_palette((offset & 0x7f) >> 1, offset & ~1, offset | 1); |
| 608 | 604 | } |
| 609 | 605 | else if (offset >= 0x480 && offset <= 0x4ff) /* Sprite color */ |
| 610 | 606 | { /* 8 colors */ |
| 611 | 607 | int offs = (offset & 0x070) | ((offset & 0x00f) >> 1); |
| 612 | 608 | |
| 613 | | argus_change_palette(machine(), offs + 0x040, offset & ~1, offset | 1); |
| 614 | | argus_change_palette(machine(), offs + 0x048, offset & ~1, offset | 1); |
| 609 | argus_change_palette(offs + 0x040, offset & ~1, offset | 1); |
| 610 | argus_change_palette(offs + 0x048, offset & ~1, offset | 1); |
| 615 | 611 | } |
| 616 | 612 | else if (offset >= 0x600 && offset <= 0x7ff) /* Text color */ |
| 617 | 613 | { |
| 618 | | argus_change_palette(machine(), ((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1); |
| 614 | argus_change_palette(((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1); |
| 619 | 615 | } |
| 620 | 616 | else if (offset >= 0x240 && offset <= 0x25f) // dummy |
| 621 | | argus_change_palette(machine(), ((offset & 0x1f) >> 1) + 0xe0, offset & ~1, offset | 1); |
| 617 | argus_change_palette(((offset & 0x1f) >> 1) + 0xe0, offset & ~1, offset | 1); |
| 622 | 618 | else if (offset >= 0x500 && offset <= 0x51f) // dummy |
| 623 | | argus_change_palette(machine(), ((offset & 0x1f) >> 1) + 0xf0, offset & ~1, offset | 1); |
| 619 | argus_change_palette(((offset & 0x1f) >> 1) + 0xf0, offset & ~1, offset | 1); |
| 624 | 620 | } |
| 625 | 621 | |
| 626 | 622 | READ8_MEMBER(argus_state::butasan_bg1ram_r) |
| r20741 | r20742 | |
| 689 | 685 | Screen refresh |
| 690 | 686 | ***************************************************************************/ |
| 691 | 687 | |
| 692 | | #define bg0_scrollx (state->m_bg0_scrollx[0] | (state->m_bg0_scrollx[1] << 8)) |
| 693 | | #define bg0_scrolly (state->m_bg0_scrolly[0] | (state->m_bg0_scrolly[1] << 8)) |
| 694 | | #define bg1_scrollx (state->m_bg1_scrollx[0] | (state->m_bg1_scrollx[1] << 8)) |
| 695 | | #define bg1_scrolly (state->m_bg1_scrolly[0] | (state->m_bg1_scrolly[1] << 8)) |
| 688 | #define bg0_scrollx (m_bg0_scrollx[0] | (m_bg0_scrollx[1] << 8)) |
| 689 | #define bg0_scrolly (m_bg0_scrolly[0] | (m_bg0_scrolly[1] << 8)) |
| 690 | #define bg1_scrollx (m_bg1_scrollx[0] | (m_bg1_scrollx[1] << 8)) |
| 691 | #define bg1_scrolly (m_bg1_scrolly[0] | (m_bg1_scrolly[1] << 8)) |
| 696 | 692 | |
| 697 | | static void bg_setting(running_machine &machine) |
| 693 | void argus_state::bg_setting() |
| 698 | 694 | { |
| 699 | | argus_state *state = machine.driver_data<argus_state>(); |
| 700 | | machine.tilemap().set_flip_all(state->m_flipscreen ? TILEMAP_FLIPY|TILEMAP_FLIPX : 0); |
| 695 | machine().tilemap().set_flip_all(m_flipscreen ? TILEMAP_FLIPY|TILEMAP_FLIPX : 0); |
| 701 | 696 | |
| 702 | | if (!state->m_flipscreen) |
| 697 | if (!m_flipscreen) |
| 703 | 698 | { |
| 704 | | if (state->m_bg0_tilemap != NULL) |
| 699 | if (m_bg0_tilemap != NULL) |
| 705 | 700 | { |
| 706 | | state->m_bg0_tilemap->set_scrollx(0, bg0_scrollx & 0x1ff); |
| 707 | | state->m_bg0_tilemap->set_scrolly(0, bg0_scrolly & 0x1ff); |
| 701 | m_bg0_tilemap->set_scrollx(0, bg0_scrollx & 0x1ff); |
| 702 | m_bg0_tilemap->set_scrolly(0, bg0_scrolly & 0x1ff); |
| 708 | 703 | } |
| 709 | | state->m_bg1_tilemap->set_scrollx(0, bg1_scrollx & 0x1ff); |
| 710 | | state->m_bg1_tilemap->set_scrolly(0, bg1_scrolly & 0x1ff); |
| 704 | m_bg1_tilemap->set_scrollx(0, bg1_scrollx & 0x1ff); |
| 705 | m_bg1_tilemap->set_scrolly(0, bg1_scrolly & 0x1ff); |
| 711 | 706 | } |
| 712 | 707 | else |
| 713 | 708 | { |
| 714 | | if (state->m_bg0_tilemap != NULL) |
| 709 | if (m_bg0_tilemap != NULL) |
| 715 | 710 | { |
| 716 | | state->m_bg0_tilemap->set_scrollx(0, (bg0_scrollx + 256) & 0x1ff); |
| 717 | | state->m_bg0_tilemap->set_scrolly(0, (bg0_scrolly + 256) & 0x1ff); |
| 711 | m_bg0_tilemap->set_scrollx(0, (bg0_scrollx + 256) & 0x1ff); |
| 712 | m_bg0_tilemap->set_scrolly(0, (bg0_scrolly + 256) & 0x1ff); |
| 718 | 713 | } |
| 719 | | state->m_bg1_tilemap->set_scrollx(0, (bg1_scrollx + 256) & 0x1ff); |
| 720 | | state->m_bg1_tilemap->set_scrolly(0, (bg1_scrolly + 256) & 0x1ff); |
| 714 | m_bg1_tilemap->set_scrollx(0, (bg1_scrollx + 256) & 0x1ff); |
| 715 | m_bg1_tilemap->set_scrolly(0, (bg1_scrolly + 256) & 0x1ff); |
| 721 | 716 | } |
| 722 | 717 | } |
| 723 | 718 | |
| 724 | | static void argus_bg0_scroll_handle(running_machine &machine) |
| 719 | void argus_state::argus_bg0_scroll_handle() |
| 725 | 720 | { |
| 726 | | argus_state *state = machine.driver_data<argus_state>(); |
| 727 | 721 | int delta; |
| 728 | 722 | int dcolumn; |
| 729 | 723 | |
| 730 | 724 | /* Deficit between previous and current scroll value */ |
| 731 | | delta = bg0_scrollx - state->m_prvscrollx; |
| 732 | | state->m_prvscrollx = bg0_scrollx; |
| 725 | delta = bg0_scrollx - m_prvscrollx; |
| 726 | m_prvscrollx = bg0_scrollx; |
| 733 | 727 | |
| 734 | 728 | if (delta == 0) |
| 735 | 729 | return; |
| 736 | 730 | |
| 737 | 731 | if (delta > 0) |
| 738 | 732 | { |
| 739 | | state->m_lowbitscroll += delta % 16; |
| 733 | m_lowbitscroll += delta % 16; |
| 740 | 734 | dcolumn = delta / 16; |
| 741 | 735 | |
| 742 | | if (state->m_lowbitscroll >= 16) |
| 736 | if (m_lowbitscroll >= 16) |
| 743 | 737 | { |
| 744 | 738 | dcolumn++; |
| 745 | | state->m_lowbitscroll -= 16; |
| 739 | m_lowbitscroll -= 16; |
| 746 | 740 | } |
| 747 | 741 | |
| 748 | 742 | if (dcolumn != 0) |
| r20741 | r20742 | |
| 761 | 755 | { |
| 762 | 756 | for (j = 0; j < 4; j++) |
| 763 | 757 | { |
| 764 | | argus_write_dummy_rams(machine, woffs, roffs); |
| 758 | argus_write_dummy_rams(woffs, roffs); |
| 765 | 759 | woffs += 16; |
| 766 | 760 | roffs += 2; |
| 767 | 761 | } |
| r20741 | r20742 | |
| 776 | 770 | } |
| 777 | 771 | else |
| 778 | 772 | { |
| 779 | | state->m_lowbitscroll += (delta % 16); |
| 773 | m_lowbitscroll += (delta % 16); |
| 780 | 774 | dcolumn = -(delta / 16); |
| 781 | 775 | |
| 782 | | if (state->m_lowbitscroll <= 0) |
| 776 | if (m_lowbitscroll <= 0) |
| 783 | 777 | { |
| 784 | 778 | dcolumn++; |
| 785 | | state->m_lowbitscroll += 16; |
| 779 | m_lowbitscroll += 16; |
| 786 | 780 | } |
| 787 | 781 | |
| 788 | 782 | if (dcolumn != 0) |
| r20741 | r20742 | |
| 803 | 797 | { |
| 804 | 798 | for (j = 0; j < 4; j++) |
| 805 | 799 | { |
| 806 | | argus_write_dummy_rams(machine, woffs, roffs); |
| 800 | argus_write_dummy_rams(woffs, roffs); |
| 807 | 801 | woffs += 16; |
| 808 | 802 | roffs += 2; |
| 809 | 803 | } |
| r20741 | r20742 | |
| 816 | 810 | } |
| 817 | 811 | } |
| 818 | 812 | |
| 819 | | static void argus_draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority) |
| 813 | void argus_state::argus_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority) |
| 820 | 814 | { |
| 821 | | argus_state *state = machine.driver_data<argus_state>(); |
| 822 | | UINT8 *spriteram = state->m_spriteram; |
| 815 | UINT8 *spriteram = m_spriteram; |
| 823 | 816 | int offs; |
| 824 | 817 | |
| 825 | 818 | /* Draw the sprites */ |
| 826 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16) |
| 819 | for (offs = 0; offs < m_spriteram.bytes(); offs += 16) |
| 827 | 820 | { |
| 828 | 821 | if (!(spriteram[offs+15] == 0 && spriteram[offs+11] == 0xf0)) |
| 829 | 822 | { |
| r20741 | r20742 | |
| 838 | 831 | color = spriteram[offs+15] & 0x07; |
| 839 | 832 | pri = (spriteram[offs+15] & 0x08) >> 3; |
| 840 | 833 | |
| 841 | | if (state->m_flipscreen) |
| 834 | if (m_flipscreen) |
| 842 | 835 | { |
| 843 | 836 | sx = 240 - sx; |
| 844 | 837 | sy = 240 - sy; |
| r20741 | r20742 | |
| 848 | 841 | |
| 849 | 842 | if (priority != pri) |
| 850 | 843 | jal_blend_drawgfx( |
| 851 | | bitmap,cliprect,machine.gfx[0], |
| 844 | bitmap,cliprect,machine().gfx[0], |
| 852 | 845 | tile, |
| 853 | 846 | color, |
| 854 | 847 | flipx, flipy, |
| r20741 | r20742 | |
| 859 | 852 | } |
| 860 | 853 | |
| 861 | 854 | #if 1 |
| 862 | | static void valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 855 | void argus_state::valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 863 | 856 | { |
| 864 | | argus_state *state = screen.machine().driver_data<argus_state>(); |
| 865 | | |
| 866 | | if (state->m_valtric_mosaic!=0x80) |
| 857 | if (m_valtric_mosaic!=0x80) |
| 867 | 858 | { |
| 868 | | state->m_mosaic=0x0f-(state->m_valtric_mosaic&0x0f); |
| 869 | | if (state->m_mosaic!=0) state->m_mosaic++; |
| 870 | | if (state->m_valtric_mosaic&0x80) state->m_mosaic*=-1; |
| 859 | m_mosaic=0x0f-(m_valtric_mosaic&0x0f); |
| 860 | if (m_mosaic!=0) m_mosaic++; |
| 861 | if (m_valtric_mosaic&0x80) m_mosaic*=-1; |
| 871 | 862 | } |
| 872 | 863 | |
| 873 | | if (state->m_mosaic==0) |
| 874 | | state->m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 864 | if (m_mosaic==0) |
| 865 | m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 875 | 866 | else |
| 876 | 867 | { |
| 877 | | state->m_bg1_tilemap->draw(state->m_mosaicbitmap, cliprect, 0, 0); |
| 868 | m_bg1_tilemap->draw(m_mosaicbitmap, cliprect, 0, 0); |
| 878 | 869 | { |
| 879 | | int step=state->m_mosaic; |
| 870 | int step=m_mosaic; |
| 880 | 871 | UINT32 *dest; |
| 881 | 872 | int x,y,xx,yy,c=0; |
| 882 | 873 | int width = screen.width(); |
| 883 | 874 | int height = screen.height(); |
| 884 | 875 | |
| 885 | | if (state->m_mosaic<0)step*=-1; |
| 876 | if (m_mosaic<0)step*=-1; |
| 886 | 877 | |
| 887 | 878 | for (y=0;y<width+step;y+=step) |
| 888 | 879 | for (x=0;x<height+step;x+=step) |
| 889 | 880 | { |
| 890 | 881 | if (y < height && x < width) |
| 891 | | c=state->m_mosaicbitmap.pix32(y, x); |
| 882 | c=m_mosaicbitmap.pix32(y, x); |
| 892 | 883 | |
| 893 | | if (state->m_mosaic<0) |
| 884 | if (m_mosaic<0) |
| 894 | 885 | if (y+step-1<height && x+step-1< width) |
| 895 | | c = state->m_mosaicbitmap.pix32(y+step-1, x+step-1); |
| 886 | c = m_mosaicbitmap.pix32(y+step-1, x+step-1); |
| 896 | 887 | |
| 897 | 888 | for (yy=0;yy<step;yy++) |
| 898 | 889 | for (xx=0;xx<step;xx++) |
| r20741 | r20742 | |
| 908 | 899 | } |
| 909 | 900 | } |
| 910 | 901 | #else |
| 911 | | static void valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 902 | void argus_state::valtric_draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 912 | 903 | { |
| 913 | 904 | argus_state *state = screen.machine().driver_data<argus_state>(); |
| 914 | | int step = 0x10 - (state->m_valtric_mosaic & 0x0f); |
| 905 | int step = 0x10 - (m_valtric_mosaic & 0x0f); |
| 915 | 906 | |
| 916 | 907 | if (step == 1) |
| 917 | | state->m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 908 | m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 918 | 909 | else |
| 919 | 910 | { |
| 920 | | state->m_bg1_tilemap->draw(state->m_mosaicbitmap, cliprect, 0, 0); |
| 911 | m_bg1_tilemap->draw(m_mosaicbitmap, cliprect, 0, 0); |
| 921 | 912 | { |
| 922 | 913 | UINT32 *dest; |
| 923 | 914 | int x,y,xx,yy,c=0; |
| r20741 | r20742 | |
| 928 | 919 | for (x = 0; x < height+step; x += step) |
| 929 | 920 | { |
| 930 | 921 | if (y < height && x < width) |
| 931 | | c = state->m_mosaicbitmap.pix32(y, x); |
| 922 | c = m_mosaicbitmap.pix32(y, x); |
| 932 | 923 | |
| 933 | | if (state->m_valtric_mosaic & 0x80) |
| 924 | if (m_valtric_mosaic & 0x80) |
| 934 | 925 | if (y+step-1 < height && x+step-1 < width) |
| 935 | | c = state->m_mosaicbitmap.pix32(y+step-1, x+step-1); |
| 926 | c = m_mosaicbitmap.pix32(y+step-1, x+step-1); |
| 936 | 927 | |
| 937 | 928 | for (yy = 0; yy < step; yy++) |
| 938 | 929 | for (xx = 0; xx < step; xx++) |
| r20741 | r20742 | |
| 949 | 940 | } |
| 950 | 941 | #endif |
| 951 | 942 | |
| 952 | | static void valtric_draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 943 | void argus_state::valtric_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 953 | 944 | { |
| 954 | | argus_state *state = machine.driver_data<argus_state>(); |
| 955 | | UINT8 *spriteram = state->m_spriteram; |
| 945 | UINT8 *spriteram = m_spriteram; |
| 956 | 946 | int offs; |
| 957 | 947 | |
| 958 | 948 | /* Draw the sprites */ |
| 959 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16) |
| 949 | for (offs = 0; offs < m_spriteram.bytes(); offs += 16) |
| 960 | 950 | { |
| 961 | 951 | if (!(spriteram[offs+15] == 0 && spriteram[offs+11] == 0xf0)) |
| 962 | 952 | { |
| r20741 | r20742 | |
| 970 | 960 | flipy = spriteram[offs+13] & 0x20; |
| 971 | 961 | color = spriteram[offs+15] & 0x0f; |
| 972 | 962 | |
| 973 | | if (state->m_flipscreen) |
| 963 | if (m_flipscreen) |
| 974 | 964 | { |
| 975 | 965 | sx = 240 - sx; |
| 976 | 966 | sy = 240 - sy; |
| r20741 | r20742 | |
| 979 | 969 | } |
| 980 | 970 | |
| 981 | 971 | jal_blend_drawgfx( |
| 982 | | bitmap,cliprect,machine.gfx[0], |
| 972 | bitmap,cliprect,machine().gfx[0], |
| 983 | 973 | tile, |
| 984 | 974 | color, |
| 985 | 975 | flipx, flipy, |
| r20741 | r20742 | |
| 989 | 979 | } |
| 990 | 980 | } |
| 991 | 981 | |
| 992 | | static void butasan_draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 982 | void argus_state::butasan_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 993 | 983 | { |
| 994 | | argus_state *state = machine.driver_data<argus_state>(); |
| 995 | | UINT8 *spriteram = state->m_spriteram; |
| 984 | UINT8 *spriteram = m_spriteram; |
| 996 | 985 | int offs; |
| 997 | 986 | |
| 998 | 987 | /* Draw the sprites */ |
| 999 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16) |
| 988 | for (offs = 0; offs < m_spriteram.bytes(); offs += 16) |
| 1000 | 989 | { |
| 1001 | 990 | int sx, sy, tile, flipx, flipy, color; |
| 1002 | 991 | int fx, fy; |
| r20741 | r20742 | |
| 1017 | 1006 | fx = flipx; |
| 1018 | 1007 | fy = flipy; |
| 1019 | 1008 | |
| 1020 | | if (state->m_flipscreen) |
| 1009 | if (m_flipscreen) |
| 1021 | 1010 | { |
| 1022 | 1011 | sx = 240 - sx; |
| 1023 | 1012 | sy = 240 - sy; |
| r20741 | r20742 | |
| 1031 | 1020 | if ((offs >= 0x100 && offs <= 0x2ff) || (offs >= 0x400 && offs <= 0x57f)) |
| 1032 | 1021 | { |
| 1033 | 1022 | jal_blend_drawgfx( |
| 1034 | | bitmap,cliprect,machine.gfx[0], |
| 1023 | bitmap,cliprect,machine().gfx[0], |
| 1035 | 1024 | tile, |
| 1036 | 1025 | color, |
| 1037 | 1026 | flipx, flipy, |
| r20741 | r20742 | |
| 1045 | 1034 | td = (fx) ? (1 - i) : i; |
| 1046 | 1035 | |
| 1047 | 1036 | jal_blend_drawgfx( |
| 1048 | | bitmap,cliprect,machine.gfx[0], |
| 1037 | bitmap,cliprect,machine().gfx[0], |
| 1049 | 1038 | tile + td, |
| 1050 | 1039 | color, |
| 1051 | 1040 | flipx, flipy, |
| r20741 | r20742 | |
| 1065 | 1054 | td = (fx) ? (i * 2) + 1 - j : i * 2 + j; |
| 1066 | 1055 | |
| 1067 | 1056 | jal_blend_drawgfx( |
| 1068 | | bitmap,cliprect,machine.gfx[0], |
| 1057 | bitmap,cliprect,machine().gfx[0], |
| 1069 | 1058 | tile + td, |
| 1070 | 1059 | color, |
| 1071 | 1060 | flipx, flipy, |
| r20741 | r20742 | |
| 1086 | 1075 | td = (fx) ? (i * 4) + 3 - j : i * 4 + j; |
| 1087 | 1076 | |
| 1088 | 1077 | jal_blend_drawgfx( |
| 1089 | | bitmap,cliprect,machine.gfx[0], |
| 1078 | bitmap,cliprect,machine().gfx[0], |
| 1090 | 1079 | tile + td, |
| 1091 | 1080 | color, |
| 1092 | 1081 | flipx, flipy, |
| r20741 | r20742 | |
| 1100 | 1089 | } |
| 1101 | 1090 | |
| 1102 | 1091 | |
| 1103 | | static void butasan_log_vram(running_machine &machine) |
| 1092 | void argus_state::butasan_log_vram() |
| 1104 | 1093 | { |
| 1105 | 1094 | #ifdef MAME_DEBUG |
| 1106 | | argus_state *state = machine.driver_data<argus_state>(); |
| 1107 | 1095 | int offs; |
| 1108 | 1096 | |
| 1109 | | if (machine.input().code_pressed(KEYCODE_M)) |
| 1097 | if (machine().input().code_pressed(KEYCODE_M)) |
| 1110 | 1098 | { |
| 1111 | | UINT8 *spriteram = state->m_spriteram; |
| 1099 | UINT8 *spriteram = m_spriteram; |
| 1112 | 1100 | int i; |
| 1113 | 1101 | logerror("\nSprite RAM\n"); |
| 1114 | 1102 | logerror("---------------------------------------\n"); |
| 1115 | 1103 | logerror(" +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +a +b +c +d +e +f\n"); |
| 1116 | | for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16) |
| 1104 | for (offs = 0; offs < m_spriteram.bytes(); offs += 16) |
| 1117 | 1105 | { |
| 1118 | 1106 | for (i = 0; i < 16; i++) |
| 1119 | 1107 | { |
| r20741 | r20742 | |
| 1140 | 1128 | if (i == 0) |
| 1141 | 1129 | { |
| 1142 | 1130 | logerror("%04x : ", offs + 0xc400); |
| 1143 | | logerror("%02x ", state->m_paletteram[offs]); |
| 1131 | logerror("%02x ", m_paletteram[offs]); |
| 1144 | 1132 | } |
| 1145 | 1133 | else if (i == 7) |
| 1146 | | logerror("%02x ", state->m_paletteram[offs + 7]); |
| 1134 | logerror("%02x ", m_paletteram[offs + 7]); |
| 1147 | 1135 | else if (i == 15) |
| 1148 | | logerror("%02x\n", state->m_paletteram[offs + 15]); |
| 1136 | logerror("%02x\n", m_paletteram[offs + 15]); |
| 1149 | 1137 | else |
| 1150 | | logerror("%02x ", state->m_paletteram[offs + i]); |
| 1138 | logerror("%02x ", m_paletteram[offs + i]); |
| 1151 | 1139 | } |
| 1152 | 1140 | } |
| 1153 | 1141 | } |
| r20741 | r20742 | |
| 1156 | 1144 | |
| 1157 | 1145 | UINT32 argus_state::screen_update_argus(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 1158 | 1146 | { |
| 1159 | | bg_setting(machine()); |
| 1147 | bg_setting(); |
| 1160 | 1148 | |
| 1161 | 1149 | /* scroll BG0 and render tile at proper position */ |
| 1162 | | argus_bg0_scroll_handle(machine()); |
| 1150 | argus_bg0_scroll_handle(); |
| 1163 | 1151 | |
| 1164 | 1152 | m_bg0_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1165 | | argus_draw_sprites(machine(), bitmap, cliprect, 0); |
| 1153 | argus_draw_sprites(bitmap, cliprect, 0); |
| 1166 | 1154 | if (m_bg_status & 1) /* Backgound enable */ |
| 1167 | 1155 | m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1168 | | argus_draw_sprites(machine(), bitmap, cliprect, 1); |
| 1156 | argus_draw_sprites(bitmap, cliprect, 1); |
| 1169 | 1157 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1170 | 1158 | return 0; |
| 1171 | 1159 | } |
| 1172 | 1160 | |
| 1173 | 1161 | UINT32 argus_state::screen_update_valtric(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 1174 | 1162 | { |
| 1175 | | bg_setting(machine()); |
| 1163 | bg_setting(); |
| 1176 | 1164 | |
| 1177 | 1165 | if (m_bg_status & 1) /* Backgound enable */ |
| 1178 | 1166 | valtric_draw_mosaic(screen, bitmap, cliprect); |
| 1179 | 1167 | else |
| 1180 | 1168 | bitmap.fill(get_black_pen(machine()), cliprect); |
| 1181 | | valtric_draw_sprites(machine(), bitmap, cliprect); |
| 1169 | valtric_draw_sprites(bitmap, cliprect); |
| 1182 | 1170 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1183 | 1171 | return 0; |
| 1184 | 1172 | } |
| 1185 | 1173 | |
| 1186 | 1174 | UINT32 argus_state::screen_update_butasan(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 1187 | 1175 | { |
| 1188 | | bg_setting(machine()); |
| 1176 | bg_setting(); |
| 1189 | 1177 | |
| 1190 | 1178 | if (m_bg_status & 1) /* Backgound enable */ |
| 1191 | 1179 | m_bg0_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1192 | 1180 | else |
| 1193 | 1181 | bitmap.fill(get_black_pen(machine()), cliprect); |
| 1194 | 1182 | if (m_butasan_bg1_status & 1) m_bg1_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1195 | | butasan_draw_sprites(machine(), bitmap, cliprect); |
| 1183 | butasan_draw_sprites(bitmap, cliprect); |
| 1196 | 1184 | m_tx_tilemap->draw(bitmap, cliprect, 0, 0); |
| 1197 | 1185 | |
| 1198 | | butasan_log_vram(machine()); |
| 1186 | butasan_log_vram(); |
| 1199 | 1187 | return 0; |
| 1200 | 1188 | } |
trunk/src/mame/drivers/balsente.c
| r20741 | r20742 | |
| 2067 | 2067 | #define EXPAND_NONE 0x3f |
| 2068 | 2068 | #define SWAP_HALVES 0x80 |
| 2069 | 2069 | |
| 2070 | | static void expand_roms(running_machine &machine, UINT8 cd_rom_mask) |
| 2070 | void balsente_state::expand_roms(UINT8 cd_rom_mask) |
| 2071 | 2071 | { |
| 2072 | 2072 | /* load AB bank data from 0x10000-0x20000 */ |
| 2073 | 2073 | /* load CD bank data from 0x20000-0x2e000 */ |
| 2074 | 2074 | /* load EF from 0x2e000-0x30000 */ |
| 2075 | 2075 | /* ROM region must be 0x40000 total */ |
| 2076 | 2076 | |
| 2077 | | UINT8 *temp = auto_alloc_array(machine, UINT8, 0x20000); |
| 2077 | UINT8 *temp = auto_alloc_array(machine(), UINT8, 0x20000); |
| 2078 | 2078 | { |
| 2079 | | UINT8 *rom = machine.root_device().memregion("maincpu")->base(); |
| 2080 | | UINT32 len = machine.root_device().memregion("maincpu")->bytes(); |
| 2079 | UINT8 *rom = machine().root_device().memregion("maincpu")->base(); |
| 2080 | UINT32 len = machine().root_device().memregion("maincpu")->bytes(); |
| 2081 | 2081 | UINT32 base; |
| 2082 | 2082 | |
| 2083 | 2083 | for (base = 0x10000; base < len; base += 0x30000) |
| r20741 | r20742 | |
| 2129 | 2129 | memcpy(&rom[base + 0x00000], &ab_base[0x0000], 0x2000); |
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | | auto_free(machine, temp); |
| 2132 | auto_free(machine(), temp); |
| 2133 | 2133 | } |
| 2134 | 2134 | } |
| 2135 | 2135 | |
| 2136 | | INLINE void config_shooter_adc(running_machine &machine, UINT8 shooter, UINT8 adc_shift) |
| 2136 | inline void balsente_state::config_shooter_adc(UINT8 shooter, UINT8 adc_shift) |
| 2137 | 2137 | { |
| 2138 | | balsente_state *state = machine.driver_data<balsente_state>(); |
| 2139 | | state->m_shooter = shooter; |
| 2140 | | state->m_adc_shift = adc_shift; |
| 2138 | m_shooter = shooter; |
| 2139 | m_adc_shift = adc_shift; |
| 2141 | 2140 | } |
| 2142 | 2141 | |
| 2143 | | DRIVER_INIT_MEMBER(balsente_state,sentetst) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); } |
| 2144 | | DRIVER_INIT_MEMBER(balsente_state,cshift) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); } |
| 2145 | | DRIVER_INIT_MEMBER(balsente_state,gghost) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 1); } |
| 2146 | | DRIVER_INIT_MEMBER(balsente_state,hattrick) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); } |
| 2147 | | DRIVER_INIT_MEMBER(balsente_state,otwalls) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 0); } |
| 2148 | | DRIVER_INIT_MEMBER(balsente_state,snakepit) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 1); } |
| 2149 | | DRIVER_INIT_MEMBER(balsente_state,snakjack) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 1); } |
| 2150 | | DRIVER_INIT_MEMBER(balsente_state,stocker) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 0); } |
| 2151 | | DRIVER_INIT_MEMBER(balsente_state,triviag1) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); } |
| 2142 | DRIVER_INIT_MEMBER(balsente_state,sentetst) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 0 /* noanalog */); } |
| 2143 | DRIVER_INIT_MEMBER(balsente_state,cshift) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 0 /* noanalog */); } |
| 2144 | DRIVER_INIT_MEMBER(balsente_state,gghost) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 1); } |
| 2145 | DRIVER_INIT_MEMBER(balsente_state,hattrick) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 0 /* noanalog */); } |
| 2146 | DRIVER_INIT_MEMBER(balsente_state,otwalls) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 0); } |
| 2147 | DRIVER_INIT_MEMBER(balsente_state,snakepit) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 1); } |
| 2148 | DRIVER_INIT_MEMBER(balsente_state,snakjack) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 1); } |
| 2149 | DRIVER_INIT_MEMBER(balsente_state,stocker) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 0); } |
| 2150 | DRIVER_INIT_MEMBER(balsente_state,triviag1) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 0 /* noanalog */); } |
| 2152 | 2151 | DRIVER_INIT_MEMBER(balsente_state,triviag2) |
| 2153 | 2152 | { |
| 2154 | 2153 | UINT8 *rom = machine().root_device().memregion("maincpu")->base(); |
| 2155 | 2154 | memcpy(&rom[0x20000], &rom[0x28000], 0x4000); |
| 2156 | 2155 | memcpy(&rom[0x24000], &rom[0x28000], 0x4000); |
| 2157 | | expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); |
| 2156 | expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 0 /* noanalog */); |
| 2158 | 2157 | } |
| 2159 | | DRIVER_INIT_MEMBER(balsente_state,triviaes) { expand_roms(machine(), EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); } |
| 2160 | | DRIVER_INIT_MEMBER(balsente_state,gimeabrk) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 1); } |
| 2161 | | DRIVER_INIT_MEMBER(balsente_state,minigolf) { expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 2); } |
| 2162 | | DRIVER_INIT_MEMBER(balsente_state,minigolf2) { expand_roms(machine(), 0x0c); config_shooter_adc(machine(), FALSE, 2); } |
| 2163 | | DRIVER_INIT_MEMBER(balsente_state,toggle) { expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); } |
| 2158 | DRIVER_INIT_MEMBER(balsente_state,triviaes) { expand_roms(EXPAND_NONE | SWAP_HALVES); config_shooter_adc(FALSE, 0 /* noanalog */); } |
| 2159 | DRIVER_INIT_MEMBER(balsente_state,gimeabrk) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 1); } |
| 2160 | DRIVER_INIT_MEMBER(balsente_state,minigolf) { expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 2); } |
| 2161 | DRIVER_INIT_MEMBER(balsente_state,minigolf2) { expand_roms(0x0c); config_shooter_adc(FALSE, 2); } |
| 2162 | DRIVER_INIT_MEMBER(balsente_state,toggle) { expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 0 /* noanalog */); } |
| 2164 | 2163 | DRIVER_INIT_MEMBER(balsente_state,nametune) |
| 2165 | 2164 | { |
| 2166 | 2165 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2167 | 2166 | space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this)); |
| 2168 | | expand_roms(machine(), EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); |
| 2167 | expand_roms(EXPAND_NONE | SWAP_HALVES); config_shooter_adc(FALSE, 0 /* noanalog */); |
| 2169 | 2168 | } |
| 2170 | 2169 | DRIVER_INIT_MEMBER(balsente_state,nstocker) |
| 2171 | 2170 | { |
| 2172 | 2171 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2173 | 2172 | space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this)); |
| 2174 | | expand_roms(machine(), EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine(), TRUE, 1); |
| 2173 | expand_roms(EXPAND_NONE | SWAP_HALVES); config_shooter_adc(TRUE, 1); |
| 2175 | 2174 | } |
| 2176 | 2175 | DRIVER_INIT_MEMBER(balsente_state,sfootbal) |
| 2177 | 2176 | { |
| 2178 | 2177 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2179 | 2178 | space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this)); |
| 2180 | | expand_roms(machine(), EXPAND_ALL | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 0); |
| 2179 | expand_roms(EXPAND_ALL | SWAP_HALVES); config_shooter_adc(FALSE, 0); |
| 2181 | 2180 | } |
| 2182 | 2181 | DRIVER_INIT_MEMBER(balsente_state,spiker) |
| 2183 | 2182 | { |
| 2184 | 2183 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2185 | 2184 | space.install_readwrite_handler(0x9f80, 0x9f8f, read8_delegate(FUNC(balsente_state::spiker_expand_r),this), write8_delegate(FUNC(balsente_state::spiker_expand_w),this)); |
| 2186 | 2185 | space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this)); |
| 2187 | | expand_roms(machine(), EXPAND_ALL | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 1); |
| 2186 | expand_roms(EXPAND_ALL | SWAP_HALVES); config_shooter_adc(FALSE, 1); |
| 2188 | 2187 | } |
| 2189 | 2188 | DRIVER_INIT_MEMBER(balsente_state,stompin) |
| 2190 | 2189 | { |
| 2191 | 2190 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2192 | 2191 | space.install_write_handler(0x9f00, 0x9f00, write8_delegate(FUNC(balsente_state::balsente_rombank2_select_w),this)); |
| 2193 | | expand_roms(machine(), 0x0c | SWAP_HALVES); config_shooter_adc(machine(), FALSE, 32); |
| 2192 | expand_roms(0x0c | SWAP_HALVES); config_shooter_adc(FALSE, 32); |
| 2194 | 2193 | } |
| 2195 | | DRIVER_INIT_MEMBER(balsente_state,rescraid) { expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 0 /* noanalog */); } |
| 2194 | DRIVER_INIT_MEMBER(balsente_state,rescraid) { expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 0 /* noanalog */); } |
| 2196 | 2195 | DRIVER_INIT_MEMBER(balsente_state,grudge) |
| 2197 | 2196 | { |
| 2198 | 2197 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2199 | 2198 | space.install_read_handler(0x9400, 0x9400, read8_delegate(FUNC(balsente_state::grudge_steering_r),this)); |
| 2200 | | expand_roms(machine(), EXPAND_NONE); config_shooter_adc(machine(), FALSE, 0); |
| 2199 | expand_roms(EXPAND_NONE); config_shooter_adc(FALSE, 0); |
| 2201 | 2200 | } |
| 2202 | 2201 | DRIVER_INIT_MEMBER(balsente_state,shrike) |
| 2203 | 2202 | { |
| r20741 | r20742 | |
| 2206 | 2205 | space.install_write_handler(0x9e01, 0x9e01, write8_delegate(FUNC(balsente_state::shrike_sprite_select_w),this)); |
| 2207 | 2206 | machine().device("68k")->memory().space(AS_PROGRAM).install_readwrite_handler(0x10000, 0x1001f, read16_delegate(FUNC(balsente_state::shrike_io_68k_r),this), write16_delegate(FUNC(balsente_state::shrike_io_68k_w),this)); |
| 2208 | 2207 | |
| 2209 | | expand_roms(machine(), EXPAND_ALL); config_shooter_adc(machine(), FALSE, 32); |
| 2208 | expand_roms(EXPAND_ALL); config_shooter_adc(FALSE, 32); |
| 2210 | 2209 | } |
| 2211 | 2210 | |
| 2212 | 2211 | |
trunk/src/mame/drivers/astrof.c
| r20741 | r20742 | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | | static rgb_t make_pen( running_machine &machine, UINT8 data ) |
| 176 | rgb_t astrof_state::make_pen( UINT8 data ) |
| 177 | 177 | { |
| 178 | | astrof_state *state = machine.driver_data<astrof_state>(); |
| 179 | | |
| 180 | | UINT8 r1_bit = state->m_red_on ? 0x01 : (data >> 0) & 0x01; |
| 181 | | UINT8 r2_bit = state->m_red_on ? 0x01 : (data >> 1) & 0x01; |
| 178 | UINT8 r1_bit = m_red_on ? 0x01 : (data >> 0) & 0x01; |
| 179 | UINT8 r2_bit = m_red_on ? 0x01 : (data >> 1) & 0x01; |
| 182 | 180 | UINT8 g1_bit = (data >> 2) & 0x01; |
| 183 | 181 | UINT8 g2_bit = (data >> 3) & 0x01; |
| 184 | 182 | UINT8 b1_bit = (data >> 4) & 0x01; |
| r20741 | r20742 | |
| 194 | 192 | } |
| 195 | 193 | |
| 196 | 194 | |
| 197 | | static void astrof_get_pens( running_machine &machine, pen_t *pens ) |
| 195 | void astrof_state::astrof_get_pens( pen_t *pens ) |
| 198 | 196 | { |
| 199 | | astrof_state *state = machine.driver_data<astrof_state>(); |
| 200 | 197 | offs_t i; |
| 201 | | UINT8 bank = (state->m_astrof_palette_bank ? 0x10 : 0x00); |
| 202 | | UINT8 config = state->ioport("FAKE")->read_safe(0x00); |
| 203 | | UINT8 *prom = state->memregion("proms")->base(); |
| 198 | UINT8 bank = (m_astrof_palette_bank ? 0x10 : 0x00); |
| 199 | UINT8 config = ioport("FAKE")->read_safe(0x00); |
| 200 | UINT8 *prom = memregion("proms")->base(); |
| 204 | 201 | |
| 205 | 202 | /* a common wire hack to the pcb causes the prom halves to be inverted */ |
| 206 | 203 | /* this results in e.g. astrof background being black */ |
| r20741 | r20742 | |
| 226 | 223 | for (i = 0; i < ASTROF_NUM_PENS; i++) |
| 227 | 224 | { |
| 228 | 225 | UINT8 data = prom[bank | i]; |
| 229 | | pens[i] = make_pen(machine, data); |
| 226 | pens[i] = make_pen(data); |
| 230 | 227 | } |
| 231 | 228 | } |
| 232 | 229 | |
| 233 | 230 | |
| 234 | | static void tomahawk_get_pens( running_machine &machine, pen_t *pens ) |
| 231 | void astrof_state::tomahawk_get_pens( pen_t *pens ) |
| 235 | 232 | { |
| 236 | 233 | offs_t i; |
| 237 | | UINT8 *prom = machine.root_device().memregion("proms")->base(); |
| 238 | | UINT8 config = machine.root_device().ioport("FAKE")->read_safe(0x00); |
| 234 | UINT8 *prom = machine().root_device().memregion("proms")->base(); |
| 235 | UINT8 config = machine().root_device().ioport("FAKE")->read_safe(0x00); |
| 239 | 236 | |
| 240 | 237 | for (i = 0; i < TOMAHAWK_NUM_PENS; i++) |
| 241 | 238 | { |
| r20741 | r20742 | |
| 266 | 263 | |
| 267 | 264 | data = prom[pen]; |
| 268 | 265 | |
| 269 | | pens[i] = make_pen(machine, data); |
| 266 | pens[i] = make_pen(data); |
| 270 | 267 | } |
| 271 | 268 | } |
| 272 | 269 | |
| r20741 | r20742 | |
| 299 | 296 | } |
| 300 | 297 | |
| 301 | 298 | |
| 302 | | static void astrof_set_video_control_2( running_machine &machine, UINT8 data ) |
| 299 | void astrof_state::astrof_set_video_control_2( UINT8 data ) |
| 303 | 300 | { |
| 304 | | astrof_state *state = machine.driver_data<astrof_state>(); |
| 305 | | |
| 306 | 301 | /* D0 - OUT0 - goes to edge conn. pin A10 - was perhaps meant to be a start lamp */ |
| 307 | 302 | /* D1 - OUT1 - goes to edge conn. pin A11 - was perhaps meant to be a start lamp */ |
| 308 | 303 | |
| 309 | 304 | /* D2 - selects one of the two palette banks */ |
| 310 | | state->m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE; |
| 305 | m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE; |
| 311 | 306 | |
| 312 | 307 | /* D3 - turns on the red color gun regardless of the value in the color PROM */ |
| 313 | | state->m_red_on = (data & 0x08) ? TRUE : FALSE; |
| 308 | m_red_on = (data & 0x08) ? TRUE : FALSE; |
| 314 | 309 | |
| 315 | 310 | /* D4-D7 - not connected */ |
| 316 | 311 | } |
| 317 | 312 | |
| 318 | 313 | WRITE8_MEMBER(astrof_state::astrof_video_control_2_w) |
| 319 | 314 | { |
| 320 | | astrof_set_video_control_2(machine(), data); |
| 315 | astrof_set_video_control_2(data); |
| 321 | 316 | machine().primary_screen->update_partial(machine().primary_screen->vpos()); |
| 322 | 317 | } |
| 323 | 318 | |
| 324 | 319 | |
| 325 | | static void spfghmk2_set_video_control_2( running_machine &machine, UINT8 data ) |
| 320 | void astrof_state::spfghmk2_set_video_control_2( UINT8 data ) |
| 326 | 321 | { |
| 327 | | astrof_state *state = machine.driver_data<astrof_state>(); |
| 328 | | |
| 329 | 322 | /* D0 - OUT0 - goes to edge conn. pin A10 - was perhaps meant to be a start lamp */ |
| 330 | 323 | /* D1 - OUT1 - goes to edge conn. pin A11 - was perhaps meant to be a start lamp */ |
| 331 | 324 | |
| 332 | 325 | /* D2 - selects one of the two palette banks */ |
| 333 | | state->m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE; |
| 326 | m_astrof_palette_bank = (data & 0x04) ? TRUE : FALSE; |
| 334 | 327 | |
| 335 | 328 | /* D3-D7 - not connected */ |
| 336 | 329 | } |
| 337 | 330 | |
| 338 | 331 | WRITE8_MEMBER(astrof_state::spfghmk2_video_control_2_w) |
| 339 | 332 | { |
| 340 | | spfghmk2_set_video_control_2(machine(), data); |
| 333 | spfghmk2_set_video_control_2(data); |
| 341 | 334 | machine().primary_screen->update_partial(machine().primary_screen->vpos()); |
| 342 | 335 | } |
| 343 | 336 | |
| 344 | 337 | |
| 345 | | static void tomahawk_set_video_control_2( running_machine &machine, UINT8 data ) |
| 338 | void astrof_state::tomahawk_set_video_control_2( UINT8 data ) |
| 346 | 339 | { |
| 347 | | astrof_state *state = machine.driver_data<astrof_state>(); |
| 348 | | |
| 349 | 340 | /* D0 - OUT0 - goes to edge conn. pin A10 - was perhaps meant to be a start lamp */ |
| 350 | 341 | /* D1 - OUT1 - goes to edge conn. pin A11 - was perhaps meant to be a start lamp */ |
| 351 | 342 | /* D2 - not connected */ |
| 352 | 343 | |
| 353 | 344 | /* D3 - turns on the red color gun regardless of the value in the color PROM */ |
| 354 | | state->m_red_on = (data & 0x08) ? TRUE : FALSE; |
| 345 | m_red_on = (data & 0x08) ? TRUE : FALSE; |
| 355 | 346 | } |
| 356 | 347 | |
| 357 | 348 | WRITE8_MEMBER(astrof_state::tomahawk_video_control_2_w) |
| 358 | 349 | { |
| 359 | | tomahawk_set_video_control_2(machine(), data); |
| 350 | tomahawk_set_video_control_2(data); |
| 360 | 351 | machine().primary_screen->update_partial(machine().primary_screen->vpos()); |
| 361 | 352 | } |
| 362 | 353 | |
| 363 | 354 | |
| 364 | | static void video_update_common( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, pen_t *pens ) |
| 355 | void astrof_state::video_update_common( bitmap_rgb32 &bitmap, const rectangle &cliprect, pen_t *pens ) |
| 365 | 356 | { |
| 366 | | astrof_state *state = machine.driver_data<astrof_state>(); |
| 367 | 357 | offs_t offs; |
| 368 | 358 | |
| 369 | | for (offs = 0; offs < state->m_videoram.bytes(); offs++) |
| 359 | for (offs = 0; offs < m_videoram.bytes(); offs++) |
| 370 | 360 | { |
| 371 | 361 | UINT8 data; |
| 372 | 362 | int i; |
| 373 | 363 | |
| 374 | | UINT8 color = state->m_colorram[offs >> 1]; |
| 364 | UINT8 color = m_colorram[offs >> 1]; |
| 375 | 365 | |
| 376 | 366 | pen_t back_pen = pens[color | 0x00]; |
| 377 | 367 | pen_t fore_pen = pens[color | 0x01]; |
| r20741 | r20742 | |
| 379 | 369 | UINT8 y = offs; |
| 380 | 370 | UINT8 x = offs >> 8 << 3; |
| 381 | 371 | |
| 382 | | if (!state->m_flipscreen) |
| 372 | if (!m_flipscreen) |
| 383 | 373 | y = ~y; |
| 384 | 374 | |
| 385 | 375 | if ((y <= cliprect.min_y) || (y >= cliprect.max_y)) |
| 386 | 376 | continue; |
| 387 | 377 | |
| 388 | | if (state->m_screen_off) |
| 378 | if (m_screen_off) |
| 389 | 379 | data = 0; |
| 390 | 380 | else |
| 391 | | data = state->m_videoram[offs]; |
| 381 | data = m_videoram[offs]; |
| 392 | 382 | |
| 393 | 383 | for (i = 0; i < 8; i++) |
| 394 | 384 | { |
| 395 | 385 | pen_t pen = (data & 0x01) ? fore_pen : back_pen; |
| 396 | 386 | |
| 397 | | if (state->m_flipscreen) |
| 387 | if (m_flipscreen) |
| 398 | 388 | bitmap.pix32(y, 255 - x) = pen; |
| 399 | 389 | else |
| 400 | 390 | bitmap.pix32(y, x) = pen; |
| r20741 | r20742 | |
| 410 | 400 | { |
| 411 | 401 | pen_t pens[ASTROF_NUM_PENS]; |
| 412 | 402 | |
| 413 | | astrof_get_pens(machine(), pens); |
| 403 | astrof_get_pens(pens); |
| 414 | 404 | |
| 415 | | video_update_common(machine(), bitmap, cliprect, pens); |
| 405 | video_update_common(bitmap, cliprect, pens); |
| 416 | 406 | |
| 417 | 407 | return 0; |
| 418 | 408 | } |
| r20741 | r20742 | |
| 422 | 412 | { |
| 423 | 413 | pen_t pens[TOMAHAWK_NUM_PENS]; |
| 424 | 414 | |
| 425 | | tomahawk_get_pens(machine(), pens); |
| 415 | tomahawk_get_pens(pens); |
| 426 | 416 | |
| 427 | | video_update_common(machine(), bitmap, cliprect, pens); |
| 417 | video_update_common(bitmap, cliprect, pens); |
| 428 | 418 | |
| 429 | 419 | return 0; |
| 430 | 420 | } |
| r20741 | r20742 | |
| 475 | 465 | MACHINE_START_MEMBER(astrof_state,astrof) |
| 476 | 466 | { |
| 477 | 467 | /* the 74175 outputs all HI's if not otherwise set */ |
| 478 | | astrof_set_video_control_2(machine(), 0xff); |
| 468 | astrof_set_video_control_2(0xff); |
| 479 | 469 | |
| 480 | 470 | m_maincpu = machine().device<cpu_device>("maincpu"); |
| 481 | 471 | m_samples = machine().device<samples_device>("samples"); |
| r20741 | r20742 | |
| 505 | 495 | MACHINE_START_MEMBER(astrof_state,spfghmk2) |
| 506 | 496 | { |
| 507 | 497 | /* the 74175 outputs all HI's if not otherwise set */ |
| 508 | | spfghmk2_set_video_control_2(machine(), 0xff); |
| 498 | spfghmk2_set_video_control_2(0xff); |
| 509 | 499 | |
| 510 | 500 | m_maincpu = machine().device<cpu_device>("maincpu"); |
| 511 | 501 | |
| r20741 | r20742 | |
| 522 | 512 | MACHINE_START_MEMBER(astrof_state,tomahawk) |
| 523 | 513 | { |
| 524 | 514 | /* the 74175 outputs all HI's if not otherwise set */ |
| 525 | | tomahawk_set_video_control_2(machine(), 0xff); |
| 515 | tomahawk_set_video_control_2(0xff); |
| 526 | 516 | |
| 527 | 517 | m_maincpu = machine().device<cpu_device>("maincpu"); |
| 528 | 518 | m_sn = machine().device("snsnd"); |