trunk/src/mess/video/fm7.c
| r31152 | r31153 | |
| 517 | 517 | int x2 = m_alu.x1; |
| 518 | 518 | int y1 = m_alu.y0; |
| 519 | 519 | int y2 = m_alu.y1; |
| 520 | | int horiz,vert; |
| 521 | | int dirx,diry; |
| 522 | | int rep; |
| 520 | |
| 521 | int dx = abs(x2 - x1); |
| 522 | int dy = abs(y2 - y1); |
| 523 | int stepx, stepy; |
| 524 | int err,err2; |
| 523 | 525 | int byte_count = 0; |
| 524 | | UINT16 old_addr = 0xffff; |
| 525 | | UINT16 addr; |
| 526 | 526 | |
| 527 | | m_alu.busy = 1; |
| 528 | | |
| 529 | | horiz = x2 - x1; |
| 530 | | vert = y2 - y1; |
| 531 | | |
| 532 | | if(horiz < 0) |
| 533 | | { |
| 534 | | dirx = -1; |
| 535 | | horiz = -horiz; |
| 536 | | } |
| 527 | if(x1 < x2) |
| 528 | stepx = 1; |
| 537 | 529 | else |
| 538 | | dirx = 1; |
| 539 | | if(vert < 0) |
| 540 | | { |
| 541 | | diry = -1; |
| 542 | | vert = -vert; |
| 543 | | } |
| 530 | stepx = -1; |
| 531 | if(y1 < y2) |
| 532 | stepy = 1; |
| 544 | 533 | else |
| 545 | | diry = 1; |
| 534 | stepy = -1; |
| 546 | 535 | |
| 547 | | if(horiz == 0 && vert == 0) |
| 536 | err = dx - dy; |
| 537 | |
| 538 | for(;;) |
| 548 | 539 | { |
| 549 | 540 | fm7_line_set_pixel(x1, y1); |
| 550 | | byte_count = 1; |
| 551 | | } |
| 552 | | else if(horiz == 0) |
| 553 | | { |
| 554 | | for(;;) |
| 541 | byte_count++; |
| 542 | |
| 543 | if(x1 == x2 && y1 == y2) |
| 544 | break; |
| 545 | |
| 546 | err2 = 2*err; |
| 547 | if(err2 > -dy) |
| 555 | 548 | { |
| 556 | | addr = fm7_line_set_pixel(x1, y1); |
| 557 | | if(addr != old_addr) |
| 558 | | { |
| 559 | | byte_count++; |
| 560 | | old_addr = addr; |
| 561 | | } |
| 562 | | if(y1 == y2) |
| 563 | | break; |
| 564 | | y1 += diry; |
| 549 | err -= dy; |
| 550 | x1 += stepx; |
| 565 | 551 | } |
| 566 | | } |
| 567 | | else if(vert == 0) |
| 568 | | { |
| 569 | | for(;;) |
| 552 | if(err2 < dx) |
| 570 | 553 | { |
| 571 | | addr = fm7_line_set_pixel(x1, y1); |
| 572 | | if(addr != old_addr) |
| 573 | | { |
| 574 | | byte_count++; |
| 575 | | old_addr = addr; |
| 576 | | } |
| 577 | | if(x1 == x2) |
| 578 | | break; |
| 579 | | x1 += dirx; |
| 554 | err += dx; |
| 555 | y1 += stepy; |
| 580 | 556 | } |
| 581 | 557 | } |
| 582 | | else if(horiz >= vert) |
| 583 | | { |
| 584 | | rep = horiz >> 1; |
| 585 | | for(;;) |
| 586 | | { |
| 587 | | addr = fm7_line_set_pixel(x1, y1); |
| 588 | | if(addr != old_addr) |
| 589 | | { |
| 590 | | byte_count++; |
| 591 | | old_addr = addr; |
| 592 | | } |
| 593 | | if(x1 == x2) |
| 594 | | break; |
| 595 | | x1 += dirx; |
| 596 | | rep -= vert; |
| 597 | | if(rep < 0) |
| 598 | | { |
| 599 | | rep += horiz; |
| 600 | | y1 += diry; |
| 601 | | } |
| 602 | | } |
| 603 | | } |
| 604 | | else |
| 605 | | { |
| 606 | | rep = vert >> 1; |
| 607 | | for(;;) |
| 608 | | { |
| 609 | | addr = fm7_line_set_pixel(x1, y1); |
| 610 | | if(addr != old_addr) |
| 611 | | { |
| 612 | | byte_count++; |
| 613 | | old_addr = addr; |
| 614 | | } |
| 615 | | if(y1 == y2) |
| 616 | | break; |
| 617 | | y1 += diry; |
| 618 | | rep -= horiz; |
| 619 | | if(rep < 0) |
| 620 | | { |
| 621 | | rep += vert; |
| 622 | | x1 += dirx; |
| 623 | | } |
| 624 | | } |
| 625 | | } |
| 626 | 558 | |
| 627 | 559 | // set timer to disable busy flag |
| 628 | 560 | // 1/16 us for each byte changed |