src/mess/video/fm7.c
| r5167 | r5168 | |
| 121 | 121 | fm7_video.vram_access = 0; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | static TIMER_CALLBACK( fm77av_alu_task_end ) |
| 125 | { |
| 126 | fm7_alu.busy = 0; |
| 127 | } |
| 128 | |
| 124 | 129 | static void fm7_alu_function_compare(UINT32 offset) |
| 125 | 130 | { |
| 126 | 131 | // COMPARE - compares which colors match those in the compare registers |
| r5167 | r5168 | |
| 433 | 438 | } |
| 434 | 439 | } |
| 435 | 440 | |
| 441 | static UINT32 fm7_line_set_pixel(int x, int y) |
| 442 | { |
| 443 | UINT32 addr; |
| 444 | UINT8 pixel_mask[8] = {0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe }; |
| 445 | |
| 446 | |
| 447 | if(fm7_video.modestatus & 0x40) // 320 pixels wide |
| 448 | { |
| 449 | addr = (x >> 3) + (y * 40); |
| 450 | } |
| 451 | else // 640 pixels wide |
| 452 | { |
| 453 | addr = (x >> 3) + (y * 80); |
| 454 | } |
| 455 | addr += (fm7_alu.addr_offset << 1); |
| 456 | addr &= 0x3fff; |
| 457 | if(fm7_video.active_video_page != 0) |
| 458 | addr += 0xc000; |
| 459 | |
| 460 | if(fm7_alu.command & 0x80) // ALU must be active |
| 461 | { |
| 462 | fm7_alu.mask = pixel_mask[x & 0x07]; |
| 463 | fm7_alu_function(addr); |
| 464 | } |
| 465 | |
| 466 | return addr; |
| 467 | } |
| 468 | |
| 469 | static void fm77av_line_draw(running_machine* machine) |
| 470 | { |
| 471 | int x1 = fm7_alu.x0; |
| 472 | int x2 = fm7_alu.x1; |
| 473 | int y1 = fm7_alu.y0; |
| 474 | int y2 = fm7_alu.y1; |
| 475 | int horiz,vert; |
| 476 | int dirx,diry; |
| 477 | int rep; |
| 478 | int byte_count = 0; |
| 479 | UINT16 old_addr = 0xffff; |
| 480 | UINT16 addr; |
| 481 | |
| 482 | fm7_alu.busy = 1; |
| 483 | |
| 484 | horiz = x2 - x1; |
| 485 | vert = y2 - y1; |
| 486 | |
| 487 | if(horiz < 0) |
| 488 | { |
| 489 | dirx = -1; |
| 490 | horiz = -horiz; |
| 491 | } |
| 492 | else |
| 493 | dirx = 1; |
| 494 | if(vert < 0) |
| 495 | { |
| 496 | diry = -1; |
| 497 | vert = -vert; |
| 498 | } |
| 499 | else |
| 500 | diry = 1; |
| 501 | |
| 502 | if(horiz == 0 && vert == 0) |
| 503 | { |
| 504 | fm7_line_set_pixel(x1,y1); |
| 505 | byte_count = 1; |
| 506 | } |
| 507 | else if(horiz == 0) |
| 508 | { |
| 509 | for(;;) |
| 510 | { |
| 511 | addr = fm7_line_set_pixel(x1,y1); |
| 512 | if(addr != old_addr) |
| 513 | { |
| 514 | byte_count++; |
| 515 | old_addr = addr; |
| 516 | } |
| 517 | if(y1 == y2) |
| 518 | break; |
| 519 | y1 += diry; |
| 520 | } |
| 521 | } |
| 522 | else if(vert == 0) |
| 523 | { |
| 524 | for(;;) |
| 525 | { |
| 526 | addr = fm7_line_set_pixel(x1,y1); |
| 527 | if(addr != old_addr) |
| 528 | { |
| 529 | byte_count++; |
| 530 | old_addr = addr; |
| 531 | } |
| 532 | if(x1 == x2) |
| 533 | break; |
| 534 | x1 += dirx; |
| 535 | } |
| 536 | } |
| 537 | else if(horiz >= vert) |
| 538 | { |
| 539 | rep = horiz >> 1; |
| 540 | for(;;) |
| 541 | { |
| 542 | addr = fm7_line_set_pixel(x1,y1); |
| 543 | if(addr != old_addr) |
| 544 | { |
| 545 | byte_count++; |
| 546 | old_addr = addr; |
| 547 | } |
| 548 | if(x1 == x2) |
| 549 | break; |
| 550 | x1 += dirx; |
| 551 | rep -= vert; |
| 552 | if(rep < 0) |
| 553 | { |
| 554 | rep += horiz; |
| 555 | y1 += diry; |
| 556 | } |
| 557 | } |
| 558 | } |
| 559 | else |
| 560 | { |
| 561 | rep = vert >> 1; |
| 562 | for(;;) |
| 563 | { |
| 564 | addr = fm7_line_set_pixel(x1,y1); |
| 565 | if(addr != old_addr) |
| 566 | { |
| 567 | byte_count++; |
| 568 | old_addr = addr; |
| 569 | } |
| 570 | if(y1 == y2) |
| 571 | break; |
| 572 | y1 += diry; |
| 573 | rep -= horiz; |
| 574 | if(rep < 0) |
| 575 | { |
| 576 | rep += vert; |
| 577 | x1 += dirx; |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | // set timer to disable busy flag |
| 583 | // 1/16 us for each byte changed |
| 584 | timer_set(machine,ATTOTIME_IN_USEC(byte_count/16),NULL,0,fm77av_alu_task_end); |
| 585 | } |
| 586 | |
| 436 | 587 | READ8_HANDLER( fm7_vram_r ) |
| 437 | 588 | { |
| 438 | 589 | int offs; |
| r5167 | r5168 | |
| 798 | 949 | * Sub CPU: 0xd430 - BUSY/NMI/Bank register (FM77AV series only) |
| 799 | 950 | * |
| 800 | 951 | * On read: bit 7 - 0 if in VBlank |
| 801 | | * bit 4 - busy(0)/ready(1) |
| 952 | * bit 4 - ALU busy(0)/ready(1) |
| 802 | 953 | * bit 2 - VSync status (1 if active?) |
| 803 | 954 | * bit 0 - RESET |
| 804 | 955 | * |
| r5167 | r5168 | |
| 815 | 966 | if(video_screen_get_vblank(space->machine->primary_screen)) |
| 816 | 967 | ret &= ~0x80; |
| 817 | 968 | |
| 969 | if(fm7_alu.busy != 0) |
| 970 | ret &= ~0x10; |
| 971 | |
| 818 | 972 | if(fm7_video.vsync_flag == 0) |
| 819 | 973 | ret &= ~0x04; |
| 820 | 974 | |
| r5167 | r5168 | |
| 1088 | 1242 | case 0x1b: |
| 1089 | 1243 | dat = (fm7_alu.y1 & 0xff00) | data; |
| 1090 | 1244 | fm7_alu.y1 = dat; |
| 1245 | // draw line |
| 1246 | fm77av_line_draw(space->machine); |
| 1091 | 1247 | logerror("ALU: write to Y1 (low) register - %02x (%04x)\n",data,fm7_alu.y1); |
| 1092 | 1248 | break; |
| 1093 | 1249 | default: |