Previous 15994 Revisions Next

r2299 Sunday 6th April, 2008 at 12:26:18 UTC by Robbbert
[MBEE] Added auto-resize and fixed cursor modes.
[src/mess/drivers]mbee.c
[src/mess/video]mbee.c

src/mess/video/mbee.c
r2298r2299
3939} CRTC6545;
4040
4141static CRTC6545 crt;
42static int off_x = 0;
43static int off_y = 0;
4442static int framecnt = 0;
4543static int m6545_color_bank = 0;
4644static int m6545_video_bank = 0;
4745static int mbee_pcg_color_latch = 0;
4846
4947int mbee_frame_counter;
50
51
5248UINT8 *pcgram;
5349
50static UINT8 mc6845_cursor[16];            // cursor shape
51static void mc6845_cursor_configure(void);
52static void mc6845_screen_configure(running_machine *machine);
5453
5554WRITE8_HANDLER ( mbee_pcg_color_latch_w )
5655{
r2298r2299
158157   return data;
159158}
160159
161static void m6545_offset_xy(void)
162{
163   if( crt.horizontal_sync_pos )
164      off_x = crt.horizontal_total - crt.horizontal_sync_pos - 23;
165   else
166      off_x = -24;
167
168   off_y = (crt.vertical_total - crt.vertical_sync_pos) *
169      (crt.scan_lines + 1) + crt.vertical_adjust;
170
171   if( off_y < 0 )
172      off_y = 0;
173
174   if( off_y > 128 )
175      off_y = 128;
176}
177
178160 READ8_HANDLER ( mbee_color_bank_r )
179161{
180162   return m6545_color_bank;
r2298r2299
312294      if( crt.horizontal_total == data )
313295         break;
314296      crt.horizontal_total = data;
315      m6545_offset_xy();
316297      break;
317298   case 1:
318299      crt.horizontal_displayed = data;
300      mc6845_screen_configure(machine);
319301      break;
320302   case 2:
321303      if( crt.horizontal_sync_pos == data )
322304         break;
323305      crt.horizontal_sync_pos = data;
324      m6545_offset_xy();
325306      break;
326307   case 3:
327308      crt.horizontal_length = data;
r2298r2299
330311      if( crt.vertical_total == data )
331312         break;
332313      crt.vertical_total = data;
333      m6545_offset_xy();
334314      break;
335315   case 5:
336316      if( crt.vertical_adjust == data )
337317         break;
338318      crt.vertical_adjust = data;
339      m6545_offset_xy();
340319      break;
341320   case 6:
342321      crt.vertical_displayed = data;
322      mc6845_screen_configure(machine);
343323      break;
344324   case 7:
345325      if( crt.vertical_sync_pos == data )
346326         break;
347327      crt.vertical_sync_pos = data;
348      m6545_offset_xy();
349328      break;
350329   case 8:
351330      crt.crt_mode = data;
r2298r2299
365344      if( crt.scan_lines == data )
366345         break;
367346      crt.scan_lines = data;
368      m6545_offset_xy();
347      mc6845_screen_configure(machine);
348      mc6845_cursor_configure();
369349      break;
370350   case 10:
371351      crt.cursor_top = data;
352      mc6845_cursor_configure();
372353      break;
373354   case 11:
374355      crt.cursor_bottom = data;
356      mc6845_cursor_configure();
375357      break;
376358   case 12:
377359      data &= 0x3f;
r2298r2299
418400   }
419401}
420402
403/* The 6845 can produce a variety of cursor shapes - all are emulated here */
404static void mc6845_cursor_configure(void)
405{
406   UINT8 i,curs_type=0,r9,r10,r11;
407
408   /* curs_type holds the general cursor shape to be created
409      0 = no cursor
410      1 = partial cursor (only shows on a block of scan lines)
411      2 = full cursor
412      3 = two-part cursor (has a part at the top and bottom with the middle blank) */
413
414   for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++) mc6845_cursor[i] = 0;      // prepare cursor by erasing old one
415
416   r9  = crt.scan_lines;               // number of scan lines - 1
417   r10 = crt.cursor_top & 0x1f;            // cursor start line = last 5 bits
418   r11 = crt.cursor_bottom+1;            // cursor end line incremented to suit for-loops below
419
420   /* decide the curs_type by examining the registers */
421   if (r10 < r11) curs_type=1;            // start less than end, show start to end
422   else
423   if (r10 == r11) curs_type=2;            // if equal, show full cursor
424   else curs_type=3;               // if start greater than end, it's a two-part cursor
425
426   if ((r11 - 1) > r9) curs_type=2;         // if end greater than scan-lines, show full cursor
427   if (r10 > r9) curs_type=0;            // if start greater than scan-lines, then no cursor
428   if (r11 > 16) r11=16;               // truncate 5-bit register to fit our 4-bit hardware
429
430   /* create the new cursor */
431   if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(mc6845_cursor);i++) mc6845_cursor[i]=0xff; // turn on full cursor
432
433   if (curs_type == 1) for (i = r10;i < r11;i++) mc6845_cursor[i]=0xff; // for each line that should show, turn on that scan line
434     
435   if (curs_type == 3) for (i = r11; i < r10;i++) mc6845_cursor[i]=0; // now take a bite out of the middle
436}
437
438/* Resize the screen within the limits of the hardware. Expand the image to fill the screen area */
439static void mc6845_screen_configure(running_machine *machine)
440{
441   rectangle visarea;
442
443   UINT16 width = crt.horizontal_displayed*8-1;                     // width in pixels
444   UINT16 height = crt.vertical_displayed*(crt.scan_lines+1)-1;               // height in pixels
445   UINT16 bytes = crt.horizontal_displayed*crt.vertical_displayed-1;            // video ram needed -1
446
447   /* Resize the screen */
448   visarea.min_x = 0;
449   visarea.max_x = width-1;
450   visarea.min_y = 0;
451   visarea.max_y = height-1;
452   if ((width < 610) && (height < 460) && (bytes < 0x800))   /* bounds checking to prevent an assert or violation */
453      video_screen_set_visarea(machine->primary_screen, 0, width, 0, height);
454}
455
421456VIDEO_START( mbee )
422457{
423458   videoram = auto_malloc(0x800);
r2298r2299
433468
434469VIDEO_UPDATE( mbee )
435470{
436   int offs, cursor, screen_;
471   UINT16 i, bytes = crt.horizontal_displayed*crt.vertical_displayed;
472   UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
473   UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
474   UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo;      // screen home offset (usually zero)
437475
438   for( offs = 0x000; offs < 0x380; offs += 0x10 )
439      keyboard_matrix_r(offs);
476   for( i = 0; i < 0x380; i += 0x10 ) keyboard_matrix_r(i);
440477
441478   framecnt++;
442479
443   cursor = (crt.cursor_address_hi << 8) | crt.cursor_address_lo;
444   screen_ = (crt.screen_address_hi << 8) | crt.screen_address_lo;
480   /* Get the graphics of the character under the cursor, xor with the visible cursor scan lines,
481      and store as character number 256. If inverse mode, drop bit 7 of character before xoring */
482   for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++)
483      pcgram[0x1000+i] = pcgram[(videoram[cursor]<<4) + i] ^ mc6845_cursor[i];
445484
446   for (offs = 0; offs < crt.horizontal_displayed * crt.vertical_displayed; offs++)
485   decodechar(screen->machine->gfx[0],256, pcgram);         // and into machine graphics
486
487   for( i = 0; i < bytes; i++ )
447488   {
448      int mem = ((offs + screen_) & 0x7ff);
449      int sy = off_y - 9 + (offs / crt.horizontal_displayed) * (crt.scan_lines + 1);
450      int sx = (off_x + 3 + (offs % crt.horizontal_displayed)) << 3;
451      int code = videoram[mem];
452      drawgfx( bitmap, screen->machine->gfx[0],code,0,0,0,sx,sy,
453         NULL,TRANSPARENCY_NONE,0);
489      int mem = ((i + screen_home) & 0x7ff);
490      int sy = (i / crt.horizontal_displayed) * (crt.scan_lines + 1);
491      int sx = (i % crt.horizontal_displayed) << 3;
492      int chr = videoram[mem];
454493
455      if( mem == cursor && (crt.cursor_top & 0x60) != 0x20 )
456      {
457         if( (crt.cursor_top & 0x60) == 0x60 || (framecnt & 16) == 0 )
458         {
459            int x, y;
460                      for( y = (crt.cursor_top & 31); y <= (crt.cursor_bottom & 31); y++ )
461            {
462               if( y > crt.scan_lines )
463                  break;
464               for( x = 0; x < 8; x++ )
465                  *BITMAP_ADDR16(bitmap, sy+y, sx+x) = 1;
466            }
467         }
468      }
494      /* if cursor is on and we are at cursor position, show it */
495      /* NOTE: flash rates obtained from real hardware */
496
497      if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
498         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
499         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
500         (mem == cursor))               // displaying at cursor position?
501            chr = 256;               // 256 = cursor character
502
503      drawgfx( bitmap, screen->machine->gfx[0],chr,0,0,0,sx,sy,
504         cliprect,TRANSPARENCY_NONE,0);   // put character on the screen
469505   }
470506     
471507   return 0;
r2298r2299
473509
474510VIDEO_UPDATE( mbeeic )
475511{
476   int offs, cursor, screen_;
512   UINT16 i, bytes = crt.horizontal_displayed*crt.vertical_displayed;
513   UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
514   UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
515   UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo;      // screen home offset (usually zero)
477516   UINT16 colourm = (mbee_pcg_color_latch & 0x0e) << 7;
478517
479   for( offs = 0x000; offs < 0x380; offs += 0x10 )
480      keyboard_matrix_r(offs);
518   for( i = 0; i < 0x380; i += 0x10 ) keyboard_matrix_r(i);
481519
482520   framecnt++;
483521
484   cursor = (crt.cursor_address_hi << 8) | crt.cursor_address_lo;
485   screen_ = (crt.screen_address_hi << 8) | crt.screen_address_lo;
522   /* Get the graphics of the character under the cursor, xor with the visible cursor scan lines,
523      and store as character number 256. If inverse mode, drop bit 7 of character before xoring */
524   for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++)
525      pcgram[0x1000+i] = pcgram[(videoram[cursor]<<4) + i] ^ mc6845_cursor[i];
486526
487   for (offs = 0; offs < crt.horizontal_displayed * crt.vertical_displayed; offs++)
527   decodechar(screen->machine->gfx[0],256, pcgram);         // and into machine graphics
528
529   for( i = 0; i < bytes; i++ )
488530   {
489      int mem = ((offs + screen_) & 0x7ff);
490      int sy = off_y + (offs / crt.horizontal_displayed) * (crt.scan_lines + 1);
491      int sx = (off_x + (offs % crt.horizontal_displayed)) << 3;
492      int code = videoram[mem];
493      int color = colorram[mem] | colourm;
494      drawgfx( bitmap, screen->machine->gfx[0],code,color,0,0,sx,sy,
495         NULL, TRANSPARENCY_NONE, 0);
531      int mem = ((i + screen_home) & 0x7ff);
532      int sy = (i / crt.horizontal_displayed) * (crt.scan_lines + 1);
533      int sx = (i % crt.horizontal_displayed) << 3;
534      int chr = videoram[mem];
535      int col = colorram[mem] | colourm;                  // read a byte of colour
496536
497      if( mem == cursor && (crt.cursor_top & 0x60) != 0x20 )
498      {
499         if( (crt.cursor_top & 0x60) == 0x60 || (framecnt & 16) == 0 )
500         {
501            int x, y;
502                      for( y = (crt.cursor_top & 31); y <= (crt.cursor_bottom & 31); y++ )
503            {
504               if( y > crt.scan_lines )
505                  break;
506               for( x = 0; x < 8; x++ )
507                  *BITMAP_ADDR16(bitmap, sy+y, sx+x) = ((color<<1)+1); /* convert to palette entry number */
508            }
509         }
510      }
537      /* if cursor is on and we are at cursor position, show it */
538      /* NOTE: flash rates obtained from real hardware */
539
540      if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
541         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
542         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
543         (mem == cursor))               // displaying at cursor position?
544            chr = 256;               // 256 = cursor character
545
546      drawgfx( bitmap, screen->machine->gfx[0],chr,col,0,0,sx,sy,
547         cliprect,TRANSPARENCY_NONE,0);   // put character on the screen
548
511549   }
550
512551   return 0;
513552}
src/mess/drivers/mbee.c
r2298r2299
207207//   PORT_CONFNAME( 0x08, 0x08, "Cassette Speaker")
208208//   PORT_CONFSETTING(    0x08, DEF_STR(On))
209209//   PORT_CONFSETTING(    0x00, DEF_STR(Off))
210//   PORT_CONFNAME( 0x10, 0x10, "Auto-Resize?")
211//   PORT_CONFSETTING(    0x00, DEF_STR(No))
212//   PORT_CONFSETTING(    0x10, DEF_STR(Yes))
213210INPUT_PORTS_END
214211
215212static const gfx_layout mbee_charlayout =
216213{
217214    8,16,                   /* 8 x 16 characters */
218    256,                    /* 256 characters */
215    257,                    /* 256 characters + cursor */
219216    1,                      /* 1 bits per pixel */
220217    { 0 },                  /* no bitplanes; 1 bit per pixel */
221218    /* x offsets */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team