Previous 15994 Revisions Next

r4422 Monday 16th March, 2009 at 11:20:41 UTC by Robbbert
[MBEE] Synchronised video and keyboard.
[src/mess/video]mbee.c

src/mess/video/mbee.c
r4421r4422
8383      colorram[offset] = data;
8484}
8585
86static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
87
88/* The "extra" keys are non-standard and will be removed eventually */
8689static int keyboard_matrix_r(running_machine *machine, int offs)
8790{
8891   int port = (offs >> 7) & 7;
8992   int bit = (offs >> 4) & 7;
9093   int extra = input_port_read(machine, "EXTRA");
9194   int data = 0;
92   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
9395
94
9596   data = (input_port_read(machine, keynames[port]) >> bit) & 1;
9697
9798   if( extra & 0x01 )   /* extra: cursor up */
r4421r4422
119120      if( port == 7 && bit == 1 ) data = 1;   /* Control */
120121      if( port == 2 && bit == 6 ) data = 1;   /* V */
121122   }
123
122124   if( data )
123125   {
124126      crt.lpen_lo = offs & 0xff;
r4421r4422
375377   }
376378}
377379
378/* The 6845 can produce a variety of cursor shapes - all are emulated here */
380/* The 6845 can produce a variety of cursor shapes - all are emulated here
381   Need to find out if the 6545 works the same way */
379382static void mc6845_cursor_configure(void)
380383{
381384   UINT8 i,curs_type=0,r9,r10,r11;
r4421r4422
447450
448451VIDEO_UPDATE( mbee )
449452{
450   UINT8 y,z,chr,gfx;
451   UINT16 mem,sy=0,sx=0,x,i;
453   UINT8 y,ra,chr,gfx;
454   UINT16 mem,sy=0,ma=0,x;
452455   UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
453456   UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
454457   UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo;      // screen home offset (usually zero)
455458
456   for( i = 0; i < 0x380; i += 0x10 ) keyboard_matrix_r(screen->machine, i);
457
458459   framecnt++;
459460
460461   for (y = 0; y < crt.vertical_displayed; y++)                  // for each row of chars
461462   {
462      for (z = 0; z < crt.scan_lines+1; z++)                  // for each scanline
463      for (ra = 0; ra < (crt.scan_lines&15)+1; ra++)               // for each scanline - RA4 is used as an update strobe for the keyboard
463464      {
464465         UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
465466
466         for (x = sx; x < sx + crt.horizontal_displayed; x++)         // for each character
467         for (x = ma; x < ma + crt.horizontal_displayed; x++)         // for each character
467468         {
468469            UINT8 inv=0;
469470            mem = (x + screen_home) & 0x7ff;
470471            chr = videoram[mem];
471
472            if ((x & 15) == 0) keyboard_matrix_r(screen->machine, x);   // actually happens for every scanline of every character, but imposes too much unnecessary overhead */
472473            /* process cursor */
473474            if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
474475               ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
475476               ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
476477               (mem == cursor))               // displaying at cursor position?
477                  inv ^= mc6845_cursor[z];         // cursor scan row
478                  inv ^= mc6845_cursor[ra];         // cursor scan row
478479
479480            /* get pattern of pixels for that character scanline */
480            gfx = mbee_pcgram[(chr<<4) | z] ^ inv;
481            gfx = mbee_pcgram[(chr<<4) | ra] ^ inv;
481482
482483            /* Display a scanline of a character (8 pixels) */
483484            *p = ( gfx & 0x80 ) ? 1 : 0; p++;
r4421r4422
490491            *p = ( gfx & 0x01 ) ? 1 : 0; p++;
491492         }
492493      }
493      sx+=crt.horizontal_displayed;
494      ma+=crt.horizontal_displayed;
494495   }
495496   return 0;
496497}
497498
498499VIDEO_UPDATE( mbeeic )
499500{
500   UINT8 y,z,chr,gfx,fg,bg;
501   UINT16 mem,sy=0,sx=0,x,i,col;
501   UINT8 y,ra,chr,gfx,fg,bg;
502   UINT16 mem,sy=0,ma=0,x,col;
502503   UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
503504   UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
504505   UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo;      // screen home offset (usually zero)
505506   UINT16 colourm = (mbee_pcg_color_latch & 0x0e) << 7;
506507
507   for( i = 0; i < 0x380; i += 0x10 ) keyboard_matrix_r(screen->machine, i);
508
509508   framecnt++;
510509
511510   for (y = 0; y < crt.vertical_displayed; y++)                  // for each row of chars
512511   {
513      for (z = 0; z < crt.scan_lines+1; z++)                  // for each scanline
512      for (ra = 0; ra < (crt.scan_lines&15)+1; ra++)               // for each scanline - RA4 is used as an update strobe for the keyboard
514513      {
515514         UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
516515
517         for (x = sx; x < sx + crt.horizontal_displayed; x++)         // for each character
516         for (x = ma; x < ma + crt.horizontal_displayed; x++)         // for each character
518517         {
519518            UINT8 inv=0;
520519            mem = (x + screen_home) & 0x7ff;
521520            chr = videoram[mem];
522521            col = colorram[mem] | colourm;               // read a byte of colour
522            if ((x & 15) == 0) keyboard_matrix_r(screen->machine, x);   // actually happens for every scanline of every character, but imposes too much unnecessary overhead */
523523
524524            /* process cursor */
525525            if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
526526               ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
527527               ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
528528               (mem == cursor))               // displaying at cursor position?
529                  inv ^= mc6845_cursor[z];         // cursor scan row
529                  inv ^= mc6845_cursor[ra];         // cursor scan row
530530
531531            /* get pattern of pixels for that character scanline */
532            gfx = mbee_pcgram[(chr<<4) | z] ^ inv;
532            gfx = mbee_pcgram[(chr<<4) | ra] ^ inv;
533533            fg = (col & 0x001f) | 64;               // map to foreground palette
534534            bg = (col & 0x07e0) >> 5;               // and background palette
535535
r4421r4422
544544            *p = ( gfx & 0x01 ) ? fg : bg; p++;
545545         }
546546      }
547      sx+=crt.horizontal_displayed;
547      ma+=crt.horizontal_displayed;
548548   }
549549   return 0;
550550}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team