Previous 15994 Revisions Next

r9398 Saturday 16th October, 2010 at 14:11:57 UTC by Robbbert
[MBEE] First step in converting to use mame mc6845 device.
[src/mess/drivers]mbee.c
[src/mess/includes]mbee.h
[src/mess/video]mbee.c

src/mess/video/mbee.c
r9397r9398
7575static UINT8 mc6845_cursor[16];            // cursor shape
7676static void mc6845_cursor_configure(void);
7777static void mc6845_screen_configure(running_machine *machine);
78static running_device *mc6845;
79static UINT8 speed,flash;
80static UINT16 cursor;
7881
7982
8083/***********************************************************
r9397r9398
370373WRITE8_HANDLER ( m6545_index_w )
371374{
372375   crt.idx = data & 0x1f;
376   data &= 0x1f;
377//   mc6845_ind = data;
378   mc6845_address_w( mc6845, 0, data );
373379}
374380
375381WRITE8_HANDLER ( m6545_data_w )
r9397r9398
484490   default:
485491      logerror("6545 write unmapped port $%X <- $%02X\n", crt.idx, data);
486492   }
493//   if (mc6845_ind < 16) mc6845_reg[mc6845_ind] = data & mc6845_mask[mc6845_ind];   /* save data in register */
494//   if ((mc6845_ind == 1) || (mc6845_ind == 6) || (mc6845_ind == 9)) mc6845_screen_configure(space->machine); /* adjust screen size */
495//   if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure();      /* adjust cursor shape - remove when mame fixed */
496   mc6845_register_w( mc6845, 0, data );
487497}
488498
489499
r9397r9398
569579
570580VIDEO_START( mbee )
571581{
582   mc6845 = machine->device("crtc");
572583   videoram = memory_region(machine, "videoram");
573584   gfxram = memory_region(machine, "gfx")+0x1000;
574585   is_premium = 0;
r9397r9398
576587
577588VIDEO_START( mbeeic )
578589{
590   mc6845 = machine->device("crtc");
579591   videoram = memory_region(machine, "videoram");
580592   colorram = memory_region(machine, "colorram");
581593   gfxram = memory_region(machine, "gfx")+0x1000;
r9397r9398
584596
585597VIDEO_START( mbeeppc )
586598{
599   mc6845 = machine->device("crtc");
587600   videoram = memory_region(machine, "videoram");
588601   colorram = memory_region(machine, "colorram");
589602   gfxram = memory_region(machine, "gfx")+0x1000;
r9397r9398
591604   is_premium = 1;
592605}
593606
594/* monochrome bee */
595607VIDEO_UPDATE( mbee )
596608{
597   UINT8 y,ra,chr,gfx;
598   UINT16 mem,sy=0,ma=0,x;
599   UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
600   UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
601   UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo;      // screen home offset (usually zero)
602
603609   framecnt++;
610   cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
611   speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
612   mc6845_update(mc6845, bitmap, cliprect);
613   return 0;
614}
604615
605   for (y = 0; y < crt.vertical_displayed; y++)                  // for each row of chars
606   {
607      for (ra = 0; ra < (crt.scan_lines&15)+1; ra++)               // for each scanline - RA4 is used as an update strobe for the keyboard
608      {
609         UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
610616
611         for (x = ma; x < ma + crt.horizontal_displayed; x++)         // for each character
612         {
613            UINT8 inv=0;
614            mem = (x + screen_home) & 0x7ff;
615            chr = videoram[mem];
617MC6845_ON_UPDATE_ADDR_CHANGED( mbee_update_addr )
618{
619/* not sure what goes in here - parameters passed are device, addr, strobe */
620}
616621
617            mbee_video_kbd_scan(screen->machine, x);
622MC6845_ON_UPDATE_ADDR_CHANGED( mbee256_update_addr )
623{
624/* not used on 256TC */
625}
618626
619            /* process cursor */
620            if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
621               ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
622               ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
623               (mem == cursor))               // displaying at cursor position?
624                  inv ^= mc6845_cursor[ra];         // cursor scan row
625627
626            /* get pattern of pixels for that character scanline */
627            gfx = gfxram[(chr<<4) | ra] ^ inv;
628/* monochrome bee */
629MC6845_UPDATE_ROW( mbee_update_row )
630{
631   UINT8 chr,gfx;
632   UINT16 mem,x;
633   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
628634
629            /* Display a scanline of a character (8 pixels) */
630            *p++ = ( gfx & 0x80 ) ? 1 : 0;
631            *p++ = ( gfx & 0x40 ) ? 1 : 0;
632            *p++ = ( gfx & 0x20 ) ? 1 : 0;
633            *p++ = ( gfx & 0x10 ) ? 1 : 0;
634            *p++ = ( gfx & 0x08 ) ? 1 : 0;
635            *p++ = ( gfx & 0x04 ) ? 1 : 0;
636            *p++ = ( gfx & 0x02 ) ? 1 : 0;
637            *p++ = ( gfx & 0x01 ) ? 1 : 0;
638         }
639      }
640      ma+=crt.horizontal_displayed;
635   for (x = 0; x < x_count; x++)         // for each character
636   {
637      UINT8 inv=0;
638      mem = (ma + x) & 0x7ff;
639      chr = videoram[mem];
640
641      mbee_video_kbd_scan(device->machine, x+ma);
642
643      /* process cursor */
644      if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
645         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
646         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
647         (mem == cursor))               // displaying at cursor position?
648            inv ^= mc6845_cursor[ra];         // cursor scan row
649
650      /* get pattern of pixels for that character scanline */
651      gfx = gfxram[(chr<<4) | ra] ^ inv;
652
653      /* Display a scanline of a character (8 pixels) */
654      *p++ = ( gfx & 0x80 ) ? 1 : 0;
655      *p++ = ( gfx & 0x40 ) ? 1 : 0;
656      *p++ = ( gfx & 0x20 ) ? 1 : 0;
657      *p++ = ( gfx & 0x10 ) ? 1 : 0;
658      *p++ = ( gfx & 0x08 ) ? 1 : 0;
659      *p++ = ( gfx & 0x04 ) ? 1 : 0;
660      *p++ = ( gfx & 0x02 ) ? 1 : 0;
661      *p++ = ( gfx & 0x01 ) ? 1 : 0;
641662   }
642   return 0;
643663}
644664
645665/* prom-based colours */
646VIDEO_UPDATE( mbeeic )
666MC6845_UPDATE_ROW( mbeeic_update_row )
647667{
648   UINT8 y,ra,chr,gfx,fg,bg;
649   UINT16 mem,sy=0,ma=0,x,col;
650   UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
651   UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
652   UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo;      // screen home offset (usually zero)
668   UINT8 chr,gfx,fg,bg;
669   UINT16 mem,x,col;
653670   UINT16 colourm = (mbee_08 & 0x0e) << 7;
671   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
654672
655   framecnt++;
656
657   for (y = 0; y < crt.vertical_displayed; y++)                  // for each row of chars
673   for (x = 0; x < x_count; x++)         // for each character
658674   {
659      for (ra = 0; ra < (crt.scan_lines&15)+1; ra++)               // for each scanline - RA4 is used as an update strobe for the keyboard
660      {
661         UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
675      UINT8 inv=0;
676      mem = (ma + x) & 0x7ff;
677      chr = videoram[mem];
678      col = colorram[mem] | colourm;               // read a byte of colour
662679
663         for (x = ma; x < ma + crt.horizontal_displayed; x++)         // for each character
664         {
665            UINT8 inv=0;
666            mem = (x + screen_home) & 0x7ff;
667            chr = videoram[mem];
668            col = colorram[mem] | colourm;               // read a byte of colour
680      mbee_video_kbd_scan(device->machine, x+ma);
669681
670            mbee_video_kbd_scan(screen->machine, x);
682      /* process cursor */
683      if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
684         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
685         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
686         (mem == cursor))               // displaying at cursor position?
687            inv ^= mc6845_cursor[ra];         // cursor scan row
671688
672            /* process cursor */
673            if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
674               ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
675               ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
676               (mem == cursor))               // displaying at cursor position?
677                  inv ^= mc6845_cursor[ra];         // cursor scan row
689      /* get pattern of pixels for that character scanline */
690      gfx = gfxram[(chr<<4) | ra] ^ inv;
691      fg = (col & 0x001f) | 64;               // map to foreground palette
692      bg = (col & 0x07e0) >> 5;               // and background palette
678693
679            /* get pattern of pixels for that character scanline */
680            gfx = gfxram[(chr<<4) | ra] ^ inv;
681            fg = (col & 0x001f) | 64;               // map to foreground palette
682            bg = (col & 0x07e0) >> 5;               // and background palette
683
684            /* Display a scanline of a character (8 pixels) */
685            *p++ = ( gfx & 0x80 ) ? fg : bg;
686            *p++ = ( gfx & 0x40 ) ? fg : bg;
687            *p++ = ( gfx & 0x20 ) ? fg : bg;
688            *p++ = ( gfx & 0x10 ) ? fg : bg;
689            *p++ = ( gfx & 0x08 ) ? fg : bg;
690            *p++ = ( gfx & 0x04 ) ? fg : bg;
691            *p++ = ( gfx & 0x02 ) ? fg : bg;
692            *p++ = ( gfx & 0x01 ) ? fg : bg;
693         }
694      }
695      ma+=crt.horizontal_displayed;
694      /* Display a scanline of a character (8 pixels) */
695      *p++ = ( gfx & 0x80 ) ? fg : bg;
696      *p++ = ( gfx & 0x40 ) ? fg : bg;
697      *p++ = ( gfx & 0x20 ) ? fg : bg;
698      *p++ = ( gfx & 0x10 ) ? fg : bg;
699      *p++ = ( gfx & 0x08 ) ? fg : bg;
700      *p++ = ( gfx & 0x04 ) ? fg : bg;
701      *p++ = ( gfx & 0x02 ) ? fg : bg;
702      *p++ = ( gfx & 0x01 ) ? fg : bg;
696703   }
697   return 0;
698704}
699705
700706
701707/* new colours & hires2 */
702VIDEO_UPDATE( mbeeppc )
708MC6845_UPDATE_ROW( mbeeppc_update_row )
703709{
704   UINT8 y,ra,gfx,fg,bg;
705   UINT16 mem,sy=0,ma=0,x,col,chr;
706   UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
707   UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
708   UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo;      // screen home offset (usually zero)
710   UINT8 gfx,fg,bg;
711   UINT16 mem,x,col,chr;
712   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
709713
710   framecnt++;
711
712   for (y = 0; y < crt.vertical_displayed; y++)                  // for each row of chars
714   for (x = 0; x < x_count; x++)         // for each character
713715   {
714      for (ra = 0; ra < (crt.scan_lines&15)+1; ra++)               // for each scanline - RA4 is used as an update strobe for the keyboard
716      UINT8 inv=0;
717      mem = (ma + x) & 0x7ff;
718      chr = videoram[mem];
719      col = colorram[mem];                  // read a byte of colour
720
721      if (mbee_1c & 0x80)                  // are extended features enabled?
715722      {
716         UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
723         UINT8 attr = attribram[mem];
717724
718         for (x = ma; x < ma + crt.horizontal_displayed; x++)         // for each character
719         {
720            UINT8 inv=0;
721            mem = (x + screen_home) & 0x7ff;
722            chr = videoram[mem];
723            col = colorram[mem];                  // read a byte of colour
725         if (chr & 0x80)
726            chr += ((attr & 15) << 7);         // bump chr to its particular pcg definition
724727
725            if (mbee_1c & 0x80)                  // are extended features enabled?
726            {
727               UINT8 attr = attribram[mem];
728         if (attr & 0x40)
729            inv ^= 0xff;               // inverse attribute
728730
729               if (chr & 0x80)
730                  chr += ((attr & 15) << 7);         // bump chr to its particular pcg definition
731         if ((attr & 0x80) && (framecnt & 0x10))         // flashing attribute
732            chr = 0x20;
733      }
731734
732               if (attr & 0x40)
733                  inv ^= 0xff;               // inverse attribute
735      mbee_video_kbd_scan(device->machine, x+ma);
734736
735               if ((attr & 0x80) && (framecnt & 0x10))         // flashing attribute
736                  chr = 0x20;
737            }
737      /* process cursor */
738      if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
739         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
740         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
741         (mem == cursor))               // displaying at cursor position?
742            inv ^= mc6845_cursor[ra];         // cursor scan row
738743
739            mbee_video_kbd_scan(screen->machine, x);
744      /* get pattern of pixels for that character scanline */
745      gfx = gfxram[(chr<<4) | ra] ^ inv;
746      fg = col & 15;                     // map to foreground palette
747      bg = (col & 0xf0) >> 4;                  // and background palette
740748
741            /* process cursor */
742            if ((((!flash) && (!speed)) ||               // (5,6)=(0,0) = cursor on always
743               ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
744               ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
745               (mem == cursor))               // displaying at cursor position?
746                  inv ^= mc6845_cursor[ra];         // cursor scan row
747
748            /* get pattern of pixels for that character scanline */
749            gfx = gfxram[(chr<<4) | ra] ^ inv;
750            fg = col & 15;                     // map to foreground palette
751            bg = (col & 0xf0) >> 4;                  // and background palette
752
753            /* Display a scanline of a character (8 pixels) */
754            *p++ = ( gfx & 0x80 ) ? fg : bg;
755            *p++ = ( gfx & 0x40 ) ? fg : bg;
756            *p++ = ( gfx & 0x20 ) ? fg : bg;
757            *p++ = ( gfx & 0x10 ) ? fg : bg;
758            *p++ = ( gfx & 0x08 ) ? fg : bg;
759            *p++ = ( gfx & 0x04 ) ? fg : bg;
760            *p++ = ( gfx & 0x02 ) ? fg : bg;
761            *p++ = ( gfx & 0x01 ) ? fg : bg;
762         }
763      }
764      ma+=crt.horizontal_displayed;
749      /* Display a scanline of a character (8 pixels) */
750      *p++ = ( gfx & 0x80 ) ? fg : bg;
751      *p++ = ( gfx & 0x40 ) ? fg : bg;
752      *p++ = ( gfx & 0x20 ) ? fg : bg;
753      *p++ = ( gfx & 0x10 ) ? fg : bg;
754      *p++ = ( gfx & 0x08 ) ? fg : bg;
755      *p++ = ( gfx & 0x04 ) ? fg : bg;
756      *p++ = ( gfx & 0x02 ) ? fg : bg;
757      *p++ = ( gfx & 0x01 ) ? fg : bg;
765758   }
766   return 0;
767759}
768760
769761
src/mess/includes/mbee.h
r9397r9398
1313#include "machine/z80pio.h"
1414#include "devices/cassette.h"
1515#include "machine/ctronics.h"
16#include "video/mc6845.h"
1617#include "sound/speaker.h"
1718
1819
r9397r9398
9394READ8_HANDLER( mbeeppc_high_r );
9495WRITE8_HANDLER( mbeeppc_high_w );
9596WRITE8_HANDLER( mbeeppc_low_w );
97MC6845_UPDATE_ROW( mbee_update_row );
98MC6845_UPDATE_ROW( mbeeic_update_row );
99MC6845_UPDATE_ROW( mbeeppc_update_row );
100MC6845_ON_UPDATE_ADDR_CHANGED( mbee_update_addr );
101MC6845_ON_UPDATE_ADDR_CHANGED( mbee256_update_addr );
96102
97
98103VIDEO_START( mbee );
99104VIDEO_UPDATE( mbee );
100105VIDEO_START( mbeeic );
src/mess/drivers/mbee.c
r9397r9398
9999#include "devices/flopdrv.h"
100100#include "formats/basicdsk.h"
101101#include "includes/mbee.h"
102#define XTAL_13_5MHz 13500000
102103
103
104104/********** NOTE !!! ***********************************************************
105105    The microbee uses lots of bankswitching and the memory maps are still
106106    being determined. Please don't merge memory maps !!
r9397r9398
592592   NULL
593593};
594594
595static const mc6845_interface mbee_crtc = {
596   "screen",         /* name of screen */
597   8,         /* number of dots per character */
598   NULL,
599   mbee_update_row,      /* handler to display a scanline */
600   NULL,
601   DEVCB_NULL,
602   DEVCB_NULL,
603   DEVCB_NULL,
604   DEVCB_NULL,
605   mbee_update_addr      /* handler to process transparent mode */
606};
607
608static const mc6845_interface mbeeic_crtc = {
609   "screen",         /* name of screen */
610   8,         /* number of dots per character */
611   NULL,
612   mbeeic_update_row,      /* handler to display a scanline */
613   NULL,
614   DEVCB_NULL,
615   DEVCB_NULL,
616   DEVCB_NULL,
617   DEVCB_NULL,
618   mbee_update_addr      /* handler to process transparent mode */
619};
620
621static const mc6845_interface mbeeppc_crtc = {
622   "screen",         /* name of screen */
623   8,         /* number of dots per character */
624   NULL,
625   mbeeppc_update_row,      /* handler to display a scanline */
626   NULL,
627   DEVCB_NULL,
628   DEVCB_NULL,
629   DEVCB_NULL,
630   DEVCB_NULL,
631   mbee_update_addr      /* handler to process transparent mode */
632};
633
634static const mc6845_interface mbee256_crtc = {
635   "screen",         /* name of screen */
636   8,         /* number of dots per character */
637   NULL,
638   mbeeppc_update_row,      /* handler to display a scanline */
639   NULL,
640   DEVCB_NULL,
641   DEVCB_NULL,
642   DEVCB_NULL,
643   DEVCB_NULL,
644   mbee256_update_addr      /* handler to process transparent mode */
645};
646
595647static MACHINE_CONFIG_START( mbee, mbee_state )
596648   /* basic machine hardware */
597649   MDRV_CPU_ADD("maincpu", Z80, XTAL_12MHz / 6)         /* 2 MHz */
r9397r9398
626678   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
627679
628680   /* devices */
681   MDRV_MC6845_ADD("crtc", SY6545_1, XTAL_12MHz / 8, mbee_crtc)
629682   MDRV_QUICKLOAD_ADD("quickload", mbee, "mwb,com", 2)
630683   MDRV_Z80BIN_QUICKLOAD_ADD("quickload2", mbee, 2)
631684   MDRV_CENTRONICS_ADD("centronics", standard_centronics)
r9397r9398
635688
636689static MACHINE_CONFIG_START( mbeeic, mbee_state )
637690   /* basic machine hardware */
638   MDRV_CPU_ADD("maincpu", Z80, 3375000)         /* 3.37500 MHz */
691   MDRV_CPU_ADD("maincpu", Z80, XTAL_13_5MHz / 4)         /* 3.37500 MHz */
639692   MDRV_CPU_PROGRAM_MAP(mbeeic_mem)
640693   MDRV_CPU_IO_MAP(mbeeic_io)
641694   MDRV_CPU_CONFIG(mbee_daisy_chain)
r9397r9398
657710   MDRV_PALETTE_INIT(mbeeic)
658711
659712   MDRV_VIDEO_START(mbeeic)
660   MDRV_VIDEO_UPDATE(mbeeic)
713   MDRV_VIDEO_UPDATE(mbee)
661714
662715   /* sound hardware */
663716   MDRV_SPEAKER_STANDARD_MONO("mono")
r9397r9398
667720   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
668721
669722   /* devices */
723   MDRV_MC6845_ADD("crtc", SY6545_1, XTAL_13_5MHz / 8, mbeeic_crtc)
670724   MDRV_QUICKLOAD_ADD("quickload", mbee, "mwb,com", 2)
671725   MDRV_Z80BIN_QUICKLOAD_ADD("quickload2", mbee, 2)
672726   MDRV_CENTRONICS_ADD("centronics", standard_centronics)
r9397r9398
694748   MDRV_CPU_PROGRAM_MAP(mbeeppc_mem)
695749   MDRV_CPU_IO_MAP(mbeeppc_io)
696750   MDRV_VIDEO_START(mbeeppc)
697   MDRV_VIDEO_UPDATE(mbeeppc)
698751   MDRV_GFXDECODE(mbeeppc)
699752   MDRV_PALETTE_LENGTH(16)
700753   MDRV_PALETTE_INIT(mbeeppc)
754   MDRV_DEVICE_REMOVE("crtc")
755   MDRV_MC6845_ADD("crtc", SY6545_1, XTAL_13_5MHz / 8, mbeeppc_crtc)
701756MACHINE_CONFIG_END
702757
703758static MACHINE_CONFIG_DERIVED( mbee56, mbeeic )
r9397r9398
729784   MDRV_CPU_IO_MAP(mbee256_io)
730785   MDRV_MACHINE_RESET( mbee256 )
731786   MDRV_MC146818_ADD( "rtc", MC146818_STANDARD )
787   MDRV_DEVICE_REMOVE("crtc")
788   MDRV_MC6845_ADD("crtc", SY6545_1, XTAL_13_5MHz / 8, mbee256_crtc)
732789MACHINE_CONFIG_END
733790
734791/* Unused roms:

Previous 15994 Revisions Next


© 1998-2018 The MESS Team