trunk/src/mess/machine/sns_spc7110.c
r23481 | r23482 | |
156 | 156 | save_item(NAME(m_dx_offset)); |
157 | 157 | save_item(NAME(m_ex_offset)); |
158 | 158 | save_item(NAME(m_fx_offset)); |
159 | | // TODO: save decomp-related items and fix their restore... |
160 | 159 | } |
161 | 160 | |
162 | 161 | void sns_rom_spc7110_device::device_start() |
r23481 | r23482 | |
319 | 318 | + map(3, 24) + map(2, 16) + map(1, 8) + map(0, 0); |
320 | 319 | #undef map |
321 | 320 | } |
| 321 | |
| 322 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_decomp_mode); |
| 323 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_decomp_offset); |
| 324 | state_save_register_item_pointer(machine, "SNES_SPC7110", 0, 0, m_decomp_buffer, SPC7110_DECOMP_BUFFER_SIZE); |
| 325 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_decomp_buffer_rdoffset); |
| 326 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_decomp_buffer_wroffset); |
| 327 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_decomp_buffer_length); |
| 328 | |
| 329 | for (int i = 0; i < 32; i++) |
| 330 | { |
| 331 | state_save_register_item(machine, "SNES_SPC7110", 0, i, m_context[i].index); |
| 332 | state_save_register_item(machine, "SNES_SPC7110", 0, i, m_context[i].invert); |
| 333 | } |
| 334 | |
| 335 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m0_val); |
| 336 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m0_in); |
| 337 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m0_span); |
| 338 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m0_out); |
| 339 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m0_inverts); |
| 340 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m0_lps); |
| 341 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m0_in_count); |
| 342 | |
| 343 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_pixelorder); |
| 344 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_realorder); |
| 345 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_val); |
| 346 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_in); |
| 347 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_span); |
| 348 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_out); |
| 349 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_inverts); |
| 350 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_lps); |
| 351 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m1_in_count); |
| 352 | |
| 353 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_pixelorder); |
| 354 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_realorder); |
| 355 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_bitplanebuffer); |
| 356 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_buffer_index); |
| 357 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_val); |
| 358 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_in); |
| 359 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_span); |
| 360 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_out0); |
| 361 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_out1); |
| 362 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_inverts); |
| 363 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_lps); |
| 364 | state_save_register_item(machine, "SNES_SPC7110", 0, 0, m_m2_in_count); |
322 | 365 | } |
323 | 366 | |
324 | 367 | void SPC7110_Decomp::reset() |
r23481 | r23482 | |
412 | 455 | } |
413 | 456 | |
414 | 457 | void SPC7110_Decomp::mode0(UINT8 init, UINT8 *ROM, UINT32 len) |
415 | | { |
416 | | static UINT8 val, in, span; |
417 | | static INT32 out, inverts, lps, in_count; |
418 | | |
| 458 | { |
419 | 459 | if (init == 1) |
420 | 460 | { |
421 | | out = inverts = lps = 0; |
422 | | span = 0xff; |
423 | | val = dataread(ROM, len); |
424 | | in = dataread(ROM, len); |
425 | | in_count = 8; |
| 461 | m_m0_out = m_m0_inverts = m_m0_lps = 0; |
| 462 | m_m0_span = 0xff; |
| 463 | m_m0_val = dataread(ROM, len); |
| 464 | m_m0_in = dataread(ROM, len); |
| 465 | m_m0_in_count = 8; |
426 | 466 | return; |
427 | 467 | } |
428 | 468 | |
r23481 | r23482 | |
432 | 472 | { |
433 | 473 | //get context |
434 | 474 | UINT8 mask = (1 << (bit & 3)) - 1; |
435 | | UINT8 con = mask + ((inverts & mask) ^ (lps & mask)); |
| 475 | UINT8 con = mask + ((m_m0_inverts & mask) ^ (m_m0_lps & mask)); |
436 | 476 | UINT32 prob, mps, flag_lps; |
437 | 477 | UINT32 shift = 0; |
438 | 478 | if (bit > 3) |
r23481 | r23482 | |
442 | 482 | |
443 | 483 | //get prob and mps |
444 | 484 | prob = probability(con); |
445 | | mps = (((out >> 15) & 1) ^ m_context[con].invert); |
| 485 | mps = (((m_m0_out >> 15) & 1) ^ m_context[con].invert); |
446 | 486 | |
447 | 487 | //get bit |
448 | | if (val <= span - prob) //mps |
| 488 | if (m_m0_val <= m_m0_span - prob) //mps |
449 | 489 | { |
450 | | span = span - prob; |
451 | | out = (out << 1) + mps; |
| 490 | m_m0_span = m_m0_span - prob; |
| 491 | m_m0_out = (m_m0_out << 1) + mps; |
452 | 492 | flag_lps = 0; |
453 | 493 | } |
454 | 494 | else //lps |
455 | 495 | { |
456 | | val = val - (span - (prob - 1)); |
457 | | span = prob - 1; |
458 | | out = (out << 1) + 1 - mps; |
| 496 | m_m0_val = m_m0_val - (m_m0_span - (prob - 1)); |
| 497 | m_m0_span = prob - 1; |
| 498 | m_m0_out = (m_m0_out << 1) + 1 - mps; |
459 | 499 | flag_lps = 1; |
460 | 500 | } |
461 | 501 | |
462 | 502 | //renormalize |
463 | | while (span < 0x7f) |
| 503 | while (m_m0_span < 0x7f) |
464 | 504 | { |
465 | 505 | shift++; |
466 | 506 | |
467 | | span = (span << 1) + 1; |
468 | | val = (val << 1) + (in >> 7); |
| 507 | m_m0_span = (m_m0_span << 1) + 1; |
| 508 | m_m0_val = (m_m0_val << 1) + (m_m0_in >> 7); |
469 | 509 | |
470 | | in <<= 1; |
471 | | if (--in_count == 0) |
| 510 | m_m0_in <<= 1; |
| 511 | if (--m_m0_in_count == 0) |
472 | 512 | { |
473 | | in = dataread(ROM, len); |
474 | | in_count = 8; |
| 513 | m_m0_in = dataread(ROM, len); |
| 514 | m_m0_in_count = 8; |
475 | 515 | } |
476 | 516 | } |
477 | 517 | |
478 | 518 | //update processing info |
479 | | lps = (lps << 1) + flag_lps; |
480 | | inverts = (inverts << 1) + m_context[con].invert; |
| 519 | m_m0_lps = (m_m0_lps << 1) + flag_lps; |
| 520 | m_m0_inverts = (m_m0_inverts << 1) + m_context[con].invert; |
481 | 521 | |
482 | 522 | //update context state |
483 | 523 | if (flag_lps & toggle_invert(con)) |
r23481 | r23482 | |
495 | 535 | } |
496 | 536 | |
497 | 537 | //save byte |
498 | | write(out); |
| 538 | write(m_m0_out); |
499 | 539 | } |
500 | 540 | } |
501 | 541 | |
502 | 542 | void SPC7110_Decomp::mode1(UINT8 init, UINT8 *ROM, UINT32 len) |
503 | 543 | { |
504 | | static INT32 pixelorder[4], realorder[4]; |
505 | | static UINT8 in, val, span; |
506 | | static INT32 out, inverts, lps, in_count; |
507 | | |
508 | 544 | if (init == 1) |
509 | 545 | { |
510 | 546 | for (int i = 0; i < 4; i++) |
511 | 547 | { |
512 | | pixelorder[i] = i; |
| 548 | m_m1_pixelorder[i] = i; |
513 | 549 | } |
514 | | out = inverts = lps = 0; |
515 | | span = 0xff; |
516 | | val = dataread(ROM, len); |
517 | | in = dataread(ROM, len); |
518 | | in_count = 8; |
| 550 | m_m1_out = m_m1_inverts = m_m1_lps = 0; |
| 551 | m_m1_span = 0xff; |
| 552 | m_m1_val = dataread(ROM, len); |
| 553 | m_m1_in = dataread(ROM, len); |
| 554 | m_m1_in_count = 8; |
519 | 555 | return; |
520 | 556 | } |
521 | 557 | |
r23481 | r23482 | |
525 | 561 | for (int pixel = 0; pixel < 8; pixel++) |
526 | 562 | { |
527 | 563 | //get first symbol context |
528 | | UINT32 a = ((out >> (1 * 2)) & 3); |
529 | | UINT32 b = ((out >> (7 * 2)) & 3); |
530 | | UINT32 c = ((out >> (8 * 2)) & 3); |
| 564 | UINT32 a = ((m_m1_out >> (1 * 2)) & 3); |
| 565 | UINT32 b = ((m_m1_out >> (7 * 2)) & 3); |
| 566 | UINT32 c = ((m_m1_out >> (8 * 2)) & 3); |
531 | 567 | UINT32 con = (a == b) ? (b != c) : (b == c) ? 2 : 4 - (a == c); |
532 | 568 | |
533 | 569 | //update pixel order |
534 | 570 | UINT32 m, n; |
535 | 571 | for (m = 0; m < 4; m++) |
536 | 572 | { |
537 | | if (pixelorder[m] == a) |
| 573 | if (m_m1_pixelorder[m] == a) |
538 | 574 | { |
539 | 575 | break; |
540 | 576 | } |
541 | 577 | } |
542 | 578 | for (n = m; n > 0; n--) |
543 | 579 | { |
544 | | pixelorder[n] = pixelorder[n - 1]; |
| 580 | m_m1_pixelorder[n] = m_m1_pixelorder[n - 1]; |
545 | 581 | } |
546 | | pixelorder[0] = a; |
| 582 | m_m1_pixelorder[0] = a; |
547 | 583 | |
548 | 584 | //calculate the real pixel order |
549 | 585 | for (m = 0; m < 4; m++) |
550 | 586 | { |
551 | | realorder[m] = pixelorder[m]; |
| 587 | m_m1_realorder[m] = m_m1_pixelorder[m]; |
552 | 588 | } |
553 | 589 | |
554 | 590 | //rotate reference pixel c value to top |
555 | 591 | for (m = 0; m < 4; m++) |
556 | 592 | { |
557 | | if (realorder[m] == c) |
| 593 | if (m_m1_realorder[m] == c) |
558 | 594 | { |
559 | 595 | break; |
560 | 596 | } |
561 | 597 | } |
562 | 598 | for (n = m; n > 0; n--) |
563 | 599 | { |
564 | | realorder[n] = realorder[n - 1]; |
| 600 | m_m1_realorder[n] = m_m1_realorder[n - 1]; |
565 | 601 | } |
566 | | realorder[0] = c; |
| 602 | m_m1_realorder[0] = c; |
567 | 603 | |
568 | 604 | //rotate reference pixel b value to top |
569 | 605 | for (m = 0; m < 4; m++) |
570 | 606 | { |
571 | | if (realorder[m] == b) |
| 607 | if (m_m1_realorder[m] == b) |
572 | 608 | { |
573 | 609 | break; |
574 | 610 | } |
575 | 611 | } |
576 | 612 | for (n = m; n > 0; n--) |
577 | 613 | { |
578 | | realorder[n] = realorder[n - 1]; |
| 614 | m_m1_realorder[n] = m_m1_realorder[n - 1]; |
579 | 615 | } |
580 | | realorder[0] = b; |
| 616 | m_m1_realorder[0] = b; |
581 | 617 | |
582 | 618 | //rotate reference pixel a value to top |
583 | 619 | for (m = 0; m < 4; m++) |
584 | 620 | { |
585 | | if (realorder[m] == a) |
| 621 | if (m_m1_realorder[m] == a) |
586 | 622 | { |
587 | 623 | break; |
588 | 624 | } |
589 | 625 | } |
590 | 626 | for (n = m; n > 0; n--) |
591 | 627 | { |
592 | | realorder[n] = realorder[n - 1]; |
| 628 | m_m1_realorder[n] = m_m1_realorder[n - 1]; |
593 | 629 | } |
594 | | realorder[0] = a; |
| 630 | m_m1_realorder[0] = a; |
595 | 631 | |
596 | 632 | //get 2 symbols |
597 | 633 | for (int bit = 0; bit < 2; bit++) |
r23481 | r23482 | |
602 | 638 | |
603 | 639 | //get symbol |
604 | 640 | UINT32 flag_lps; |
605 | | if (val <= span - prob) //mps |
| 641 | if (m_m1_val <= m_m1_span - prob) //mps |
606 | 642 | { |
607 | | span = span - prob; |
| 643 | m_m1_span = m_m1_span - prob; |
608 | 644 | flag_lps = 0; |
609 | 645 | } |
610 | 646 | else //lps |
611 | 647 | { |
612 | | val = val - (span - (prob - 1)); |
613 | | span = prob - 1; |
| 648 | m_m1_val = m_m1_val - (m_m1_span - (prob - 1)); |
| 649 | m_m1_span = prob - 1; |
614 | 650 | flag_lps = 1; |
615 | 651 | } |
616 | 652 | |
617 | 653 | //renormalize |
618 | | while (span < 0x7f) |
| 654 | while (m_m1_span < 0x7f) |
619 | 655 | { |
620 | 656 | shift++; |
621 | 657 | |
622 | | span = (span << 1) + 1; |
623 | | val = (val << 1) + (in >> 7); |
| 658 | m_m1_span = (m_m1_span << 1) + 1; |
| 659 | m_m1_val = (m_m1_val << 1) + (m_m1_in >> 7); |
624 | 660 | |
625 | | in <<= 1; |
626 | | if (--in_count == 0) |
| 661 | m_m1_in <<= 1; |
| 662 | if (--m_m1_in_count == 0) |
627 | 663 | { |
628 | | in = dataread(ROM, len); |
629 | | in_count = 8; |
| 664 | m_m1_in = dataread(ROM, len); |
| 665 | m_m1_in_count = 8; |
630 | 666 | } |
631 | 667 | } |
632 | 668 | |
633 | 669 | //update processing info |
634 | | lps = (lps << 1) + flag_lps; |
635 | | inverts = (inverts << 1) + m_context[con].invert; |
| 670 | m_m1_lps = (m_m1_lps << 1) + flag_lps; |
| 671 | m_m1_inverts = (m_m1_inverts << 1) + m_context[con].invert; |
636 | 672 | |
637 | 673 | //update context state |
638 | 674 | if (flag_lps & toggle_invert(con)) |
r23481 | r23482 | |
649 | 685 | } |
650 | 686 | |
651 | 687 | //get next context |
652 | | con = 5 + (con << 1) + ((lps ^ inverts) & 1); |
| 688 | con = 5 + (con << 1) + ((m_m1_lps ^ m_m1_inverts) & 1); |
653 | 689 | } |
654 | 690 | |
655 | 691 | //get pixel |
656 | | b = realorder[(lps ^ inverts) & 3]; |
657 | | out = (out << 2) + b; |
| 692 | b = m_m1_realorder[(m_m1_lps ^ m_m1_inverts) & 3]; |
| 693 | m_m1_out = (m_m1_out << 2) + b; |
658 | 694 | } |
659 | 695 | |
660 | 696 | //turn pixel data into bitplanes |
661 | | data = morton_2x8(out); |
| 697 | data = morton_2x8(m_m1_out); |
662 | 698 | write(data >> 8); |
663 | 699 | write(data >> 0); |
664 | 700 | } |
r23481 | r23482 | |
666 | 702 | |
667 | 703 | void SPC7110_Decomp::mode2(UINT8 init, UINT8 *ROM, UINT32 len) |
668 | 704 | { |
669 | | static INT32 pixelorder[16], realorder[16]; |
670 | | static UINT8 bitplanebuffer[16], buffer_index; |
671 | | static UINT8 in, val, span; |
672 | | static INT32 out0, out1, inverts, lps, in_count; |
673 | | |
674 | 705 | if (init == 1) |
675 | 706 | { |
676 | 707 | for (int i = 0; i < 16; i++) |
677 | 708 | { |
678 | | pixelorder[i] = i; |
| 709 | m_m2_pixelorder[i] = i; |
679 | 710 | } |
680 | | buffer_index = 0; |
681 | | out0 = out1 = inverts = lps = 0; |
682 | | span = 0xff; |
683 | | val = dataread(ROM, len); |
684 | | in = dataread(ROM, len); |
685 | | in_count = 8; |
| 711 | m_m2_buffer_index = 0; |
| 712 | m_m2_out0 = m_m2_out1 = m_m2_inverts = m_m2_lps = 0; |
| 713 | m_m2_span = 0xff; |
| 714 | m_m2_val = dataread(ROM, len); |
| 715 | m_m2_in = dataread(ROM, len); |
| 716 | m_m2_in_count = 8; |
686 | 717 | return; |
687 | 718 | } |
688 | 719 | |
r23481 | r23482 | |
692 | 723 | for (int pixel = 0; pixel < 8; pixel++) |
693 | 724 | { |
694 | 725 | //get first symbol context |
695 | | UINT32 a = ((out0 >> (0 * 4)) & 15); |
696 | | UINT32 b = ((out0 >> (7 * 4)) & 15); |
697 | | UINT32 c = ((out1 >> (0 * 4)) & 15); |
| 726 | UINT32 a = ((m_m2_out0 >> (0 * 4)) & 15); |
| 727 | UINT32 b = ((m_m2_out0 >> (7 * 4)) & 15); |
| 728 | UINT32 c = ((m_m2_out1 >> (0 * 4)) & 15); |
698 | 729 | UINT32 con = 0; |
699 | 730 | UINT32 refcon = (a == b) ? (b != c) : (b == c) ? 2 : 4 - (a == c); |
700 | 731 | |
r23481 | r23482 | |
702 | 733 | UINT32 m, n; |
703 | 734 | for (m = 0; m < 16; m++) |
704 | 735 | { |
705 | | if (pixelorder[m] == a) |
| 736 | if (m_m2_pixelorder[m] == a) |
706 | 737 | { |
707 | 738 | break; |
708 | 739 | } |
709 | 740 | } |
710 | 741 | for (n = m; n > 0; n--) |
711 | 742 | { |
712 | | pixelorder[n] = pixelorder[n - 1]; |
| 743 | m_m2_pixelorder[n] = m_m2_pixelorder[n - 1]; |
713 | 744 | } |
714 | | pixelorder[0] = a; |
| 745 | m_m2_pixelorder[0] = a; |
715 | 746 | |
716 | 747 | //calculate the real pixel order |
717 | 748 | for (m = 0; m < 16; m++) |
718 | 749 | { |
719 | | realorder[m] = pixelorder[m]; |
| 750 | m_m2_realorder[m] = m_m2_pixelorder[m]; |
720 | 751 | } |
721 | 752 | |
722 | 753 | //rotate reference pixel c value to top |
723 | 754 | for (m = 0; m < 16; m++) |
724 | 755 | { |
725 | | if (realorder[m] == c) |
| 756 | if (m_m2_realorder[m] == c) |
726 | 757 | { |
727 | 758 | break; |
728 | 759 | } |
729 | 760 | } |
730 | 761 | for (n = m; n > 0; n--) |
731 | 762 | { |
732 | | realorder[n] = realorder[n - 1]; |
| 763 | m_m2_realorder[n] = m_m2_realorder[n - 1]; |
733 | 764 | } |
734 | | realorder[0] = c; |
| 765 | m_m2_realorder[0] = c; |
735 | 766 | |
736 | 767 | //rotate reference pixel b value to top |
737 | 768 | for (m = 0; m < 16; m++) |
738 | 769 | { |
739 | | if (realorder[m] == b) |
| 770 | if (m_m2_realorder[m] == b) |
740 | 771 | { |
741 | 772 | break; |
742 | 773 | } |
743 | 774 | } |
744 | 775 | for (n = m; n > 0; n--) |
745 | 776 | { |
746 | | realorder[n] = realorder[n - 1]; |
| 777 | m_m2_realorder[n] = m_m2_realorder[n - 1]; |
747 | 778 | } |
748 | | realorder[0] = b; |
| 779 | m_m2_realorder[0] = b; |
749 | 780 | |
750 | 781 | //rotate reference pixel a value to top |
751 | 782 | for (m = 0; m < 16; m++) |
752 | 783 | { |
753 | | if (realorder[m] == a) |
| 784 | if (m_m2_realorder[m] == a) |
754 | 785 | { |
755 | 786 | break; |
756 | 787 | } |
757 | 788 | } |
758 | 789 | for (n = m; n > 0; n--) |
759 | 790 | { |
760 | | realorder[n] = realorder[n - 1]; |
| 791 | m_m2_realorder[n] = m_m2_realorder[n - 1]; |
761 | 792 | } |
762 | | realorder[0] = a; |
| 793 | m_m2_realorder[0] = a; |
763 | 794 | |
764 | 795 | //get 4 symbols |
765 | 796 | for (int bit = 0; bit < 4; bit++) |
r23481 | r23482 | |
771 | 802 | |
772 | 803 | //get symbol |
773 | 804 | UINT32 flag_lps; |
774 | | if (val <= span - prob) //mps |
| 805 | if (m_m2_val <= m_m2_span - prob) //mps |
775 | 806 | { |
776 | | span = span - prob; |
| 807 | m_m2_span = m_m2_span - prob; |
777 | 808 | flag_lps = 0; |
778 | 809 | } |
779 | 810 | else //lps |
780 | 811 | { |
781 | | val = val - (span - (prob - 1)); |
782 | | span = prob - 1; |
| 812 | m_m2_val = m_m2_val - (m_m2_span - (prob - 1)); |
| 813 | m_m2_span = prob - 1; |
783 | 814 | flag_lps = 1; |
784 | 815 | } |
785 | 816 | |
786 | 817 | //renormalize |
787 | 818 | shift = 0; |
788 | | while (span < 0x7f) |
| 819 | while (m_m2_span < 0x7f) |
789 | 820 | { |
790 | 821 | shift++; |
791 | 822 | |
792 | | span = (span << 1) + 1; |
793 | | val = (val << 1) + (in >> 7); |
| 823 | m_m2_span = (m_m2_span << 1) + 1; |
| 824 | m_m2_val = (m_m2_val << 1) + (m_m2_in >> 7); |
794 | 825 | |
795 | | in <<= 1; |
796 | | if (--in_count == 0) |
| 826 | m_m2_in <<= 1; |
| 827 | if (--m_m2_in_count == 0) |
797 | 828 | { |
798 | | in = dataread(ROM, len); |
799 | | in_count = 8; |
| 829 | m_m2_in = dataread(ROM, len); |
| 830 | m_m2_in_count = 8; |
800 | 831 | } |
801 | 832 | } |
802 | 833 | |
803 | 834 | //update processing info |
804 | | lps = (lps << 1) + flag_lps; |
| 835 | m_m2_lps = (m_m2_lps << 1) + flag_lps; |
805 | 836 | invertbit = m_context[con].invert; |
806 | | inverts = (inverts << 1) + invertbit; |
| 837 | m_m2_inverts = (m_m2_inverts << 1) + invertbit; |
807 | 838 | |
808 | 839 | //update context state |
809 | 840 | if (flag_lps & toggle_invert(con)) |
r23481 | r23482 | |
824 | 855 | } |
825 | 856 | |
826 | 857 | //get pixel |
827 | | b = realorder[(lps ^ inverts) & 0x0f]; |
828 | | out1 = (out1 << 4) + ((out0 >> 28) & 0x0f); |
829 | | out0 = (out0 << 4) + b; |
| 858 | b = m_m2_realorder[(m_m2_lps ^ m_m2_inverts) & 0x0f]; |
| 859 | m_m2_out1 = (m_m2_out1 << 4) + ((m_m2_out0 >> 28) & 0x0f); |
| 860 | m_m2_out0 = (m_m2_out0 << 4) + b; |
830 | 861 | } |
831 | 862 | |
832 | 863 | //convert pixel data into bitplanes |
833 | | data = morton_4x8(out0); |
| 864 | data = morton_4x8(m_m2_out0); |
834 | 865 | write(data >> 24); |
835 | 866 | write(data >> 16); |
836 | | bitplanebuffer[buffer_index++] = data >> 8; |
837 | | bitplanebuffer[buffer_index++] = data >> 0; |
| 867 | m_m2_bitplanebuffer[m_m2_buffer_index++] = data >> 8; |
| 868 | m_m2_bitplanebuffer[m_m2_buffer_index++] = data >> 0; |
838 | 869 | |
839 | | if (buffer_index == 16) |
| 870 | if (m_m2_buffer_index == 16) |
840 | 871 | { |
841 | 872 | for (int i = 0; i < 16; i++) |
842 | 873 | { |
843 | | write(bitplanebuffer[i]); |
| 874 | write(m_m2_bitplanebuffer[i]); |
844 | 875 | } |
845 | | buffer_index = 0; |
| 876 | m_m2_buffer_index = 0; |
846 | 877 | } |
847 | 878 | } |
848 | 879 | } |