Previous 15994 Revisions Next

r5168 Tuesday 7th July, 2009 at 05:20:43 UTC by Barry Rodewald
[FM77AV] Added ALU line drawing support.
[src/mess/drivers]fm7.c
[src/mess/video]fm7.c

src/mess/video/fm7.c
r5167r5168
121121   fm7_video.vram_access = 0;
122122}
123123
124static TIMER_CALLBACK( fm77av_alu_task_end )
125{
126   fm7_alu.busy = 0;
127}
128
124129static void fm7_alu_function_compare(UINT32 offset)
125130{
126131   // COMPARE - compares which colors match those in the compare registers
r5167r5168
433438   }
434439}
435440
441static 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
469static 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
436587READ8_HANDLER( fm7_vram_r )
437588{
438589   int offs;
r5167r5168
798949 *   Sub CPU: 0xd430 - BUSY/NMI/Bank register (FM77AV series only)
799950 *
800951 *   On read:  bit 7 - 0 if in VBlank
801 *             bit 4 - busy(0)/ready(1)
952 *             bit 4 - ALU busy(0)/ready(1)
802953 *             bit 2 - VSync status (1 if active?)
803954 *             bit 0 - RESET
804955 *
r5167r5168
815966   if(video_screen_get_vblank(space->machine->primary_screen))
816967      ret &= ~0x80;
817968   
969   if(fm7_alu.busy != 0)
970      ret &= ~0x10;
971   
818972   if(fm7_video.vsync_flag == 0)
819973      ret &= ~0x04;
820974
r5167r5168
10881242      case 0x1b:
10891243         dat = (fm7_alu.y1 & 0xff00) | data;
10901244         fm7_alu.y1 = dat;
1245         // draw line
1246         fm77av_line_draw(space->machine);
10911247         logerror("ALU: write to Y1 (low) register - %02x (%04x)\n",data,fm7_alu.y1);
10921248         break;
10931249      default:
src/mess/drivers/fm7.c
r5167r5168
12381238   }
12391239   else
12401240   {
1241//      cputag_set_input_line(device->machine,"maincpu",M6809_IRQ_LINE,CLEAR_LINE);
1241      cputag_set_input_line(device->machine,"maincpu",M6809_IRQ_LINE,CLEAR_LINE);
12421242      fm77av_ym_irq = 0;
12431243   }
12441244}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team