Previous 15994 Revisions Next

r10470 Wednesday 16th February, 2011 at 23:46:19 UTC by Angelo Salese
[SMC-777]: work-around for an i/o port read, fixed palette colors, rewritten tilemap gfxs by using custom code and added tile blinking. Fixes graphics in Dragon's Alphabet and Bird Crush
[src/mess/drivers]smc777.c

src/mess/drivers/smc777.c
r10469r10470
22
33    SMC-777 (c) 1983 Sony
44
5    preliminary driver by Angelo Salese
5    driver by Angelo Salese
66
77    TODO:
88    - no documentation, the entire driver is just a bunch of educated
r10469r10470
1010   - ROM/RAM bankswitch, it apparently happens after one instruction prefetching.
1111     We currently use an hackish implementation until the MAME/MESS framework can
1212     support that ...
13   - keyboard input is very very sluggish;
14   - colors in Dragon's Alphabet, Bird Crash;
13   - keyboard input is very sluggish;
1514   - clean up i/o ports, remove Z80_B usage and write custom code in place of it;
15   - cursor stuck in Bird Crash;
16   - add mc6845 features;
17   - many other missing features;
1618
1719**************************************************************************************/
1820
r10469r10470
6971   UINT8 *gram = screen->machine->region("fbuf")->base();
7072   int x_width;
7173
72   bitmap_fill(bitmap, cliprect, screen->machine->pens[state->backdrop_pen+0x10]);
74   bitmap_fill(bitmap, cliprect, screen->machine->pens[state->backdrop_pen]);
7375
7476   x_width = (state->display_reg & 0x80) ? 2 : 4;
7577
r10469r10470
8789            /* todo: clean this up! */
8890            if(x_width == 2)
8991            {
90               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*2+0+CRTC_MIN_X) = screen->machine->pens[color+0x10];
92               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*2+0+CRTC_MIN_X) = screen->machine->pens[color];
9193            }
9294            else
9395            {
94               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+0+CRTC_MIN_X) = screen->machine->pens[color+0x10];
95               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+1+CRTC_MIN_X) = screen->machine->pens[color+0x10];
96               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+0+CRTC_MIN_X) = screen->machine->pens[color];
97               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+1+CRTC_MIN_X) = screen->machine->pens[color];
9698            }
9799
98100            color = (gram[count] & 0x0f) >> 0;
99101            if(x_width == 2)
100102            {
101               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*2+1+CRTC_MIN_X) = screen->machine->pens[color+0x10];
103               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*2+1+CRTC_MIN_X) = screen->machine->pens[color];
102104            }
103105            else
104106            {
105               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+2+CRTC_MIN_X) = screen->machine->pens[color+0x10];
106               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+3+CRTC_MIN_X) = screen->machine->pens[color+0x10];
107               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+2+CRTC_MIN_X) = screen->machine->pens[color];
108               *BITMAP_ADDR16(bitmap, y+yi+CRTC_MIN_Y, x*4+3+CRTC_MIN_X) = screen->machine->pens[color];
107109            }
108110
109111            count++;
r10469r10470
121123   {
122124      for(x=0;x<x_width;x++)
123125      {
126         /*
127         -x-- ---- blink
128         --xx x--- bg color (00 transparent, 01 white, 10 black, 11 complementary to fg color
129         ---- -xxx fg color
130         */
124131         int tile = vram[count];
125132         int color = attr[count] & 7;
126133         int bk_color = (attr[count] & 0x18) >> 3;
127         int yb,xb,bk_pen;
134         int blink = attr[count] & 0x40;
135         int yi,xi;
136         int bk_pen;
137         //int bk_struct[4] = { -1, 0x10, 0x11, (color & 7) ^ 8 };
128138
129         bk_pen = 0x00;
130         switch(bk_color)
139         switch(bk_color & 3)
131140         {
132            case 1: bk_pen = 0x07; break; //white
133            case 2: bk_pen = 0x00; break; //black
134            case 3: bk_pen = (color ^ 7)+0x08; break; //complementary
141            case 0: bk_pen = -1; break; //transparent
142            case 1: bk_pen = 0x10; break; //white
143            case 2: bk_pen = 0x11; break; //black
144            case 3: bk_pen = (color ^ 0xf); break; //complementary
135145         }
136146
137         if(bk_color)
138            for(yb=0;yb<8;yb++)
139               for(xb=0;xb<8;xb++)
140                  *BITMAP_ADDR16(bitmap, y*8+CRTC_MIN_Y+yb, x*8+CRTC_MIN_X+xb) = screen->machine->pens[bk_pen+0x10];
147         if(blink && screen->machine->primary_screen->frame_number() & 0x10) //blinking, used by Dragon's Alphabet
148            color = bk_pen;
141149
142         /*TODO: make this custom code*/
143         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],tile,color,0,0,x*8+CRTC_MIN_X,y*8+CRTC_MIN_Y,0);
150         for(yi=0;yi<8;yi++)
151         {
152            for(xi=0;xi<8;xi++)
153            {
154               UINT8 *gfx_data = screen->machine->region("pcg")->base();
155               int pen;
144156
157               pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? color : bk_pen;
158
159               if(pen != -1)
160                  *BITMAP_ADDR16(bitmap, y*8+CRTC_MIN_Y+yi, x*8+CRTC_MIN_X+xi) = screen->machine->pens[pen];
161            }
162         }
163
145164         // draw cursor
146165         if(state->cursor_addr == count)
147166         {
r10469r10470
162181               {
163182                  for(xc=0;xc<8;xc++)
164183                  {
165                     *BITMAP_ADDR16(bitmap, y*8+CRTC_MIN_Y-yc+7, x*8+CRTC_MIN_X+xc) = screen->machine->pens[0x17];
184                     *BITMAP_ADDR16(bitmap, y*8+CRTC_MIN_Y-yc+7, x*8+CRTC_MIN_X+xc) = screen->machine->pens[0x7];
166185                  }
167186               }
168187            }
r10469r10470
355374{
356375   smc777_state *drvstate = device->machine->driver_data<smc777_state>();
357376   drvstate->fdc_irq_flag = state;
358//  cputag_set_input_line(device->machine, "maincpu", 0, (state) ? ASSERT_LINE : CLEAR_LINE);
359377}
360378
361379static WRITE_LINE_DEVICE_HANDLER( smc777_fdc_drq_w )
r10469r10470
391409{
392410   smc777_state *state = space->machine->driver_data<smc777_state>();
393411
412   printf("System FF %02x\n",state->system_data & 0x0f);
413
414   switch(state->system_data & 0x0f)
415   {
416      case 0x00:
417         return (state->raminh & 0x01) << 4; //unknown bit, Dragon's Alphabet and Bird Crush relies on this
418   }
419
394420   return state->system_data;
395421}
396422
397//static TIMER_CALLBACK( raminh_change )
398423
399424
400425static WRITE8_HANDLER( system_output_w )
r10469r10470
467492
468493   switch(gradient_index)
469494   {
470      case 0: state->pal.r = data; palette_set_color_rgb(space->machine, pal_index+0x10, state->pal.r, state->pal.g, state->pal.b); break;
471      case 1: state->pal.g = data; palette_set_color_rgb(space->machine, pal_index+0x10, state->pal.r, state->pal.g, state->pal.b); break;
472      case 2: state->pal.b = data; palette_set_color_rgb(space->machine, pal_index+0x10, state->pal.r, state->pal.g, state->pal.b); break;
495      case 0: state->pal.r = data; palette_set_color_rgb(space->machine, pal_index, state->pal.r, state->pal.g, state->pal.b); break;
496      case 1: state->pal.g = data; palette_set_color_rgb(space->machine, pal_index, state->pal.r, state->pal.g, state->pal.b); break;
497      case 2: state->pal.b = data; palette_set_color_rgb(space->machine, pal_index, state->pal.r, state->pal.g, state->pal.b); break;
473498   }
474499}
475500
r10469r10470
590615//  AM_RANGE(0x48, 0x50) AM_NOP //HDD (Winchester)
591616   AM_RANGE(0x51, 0x51) AM_READWRITE(smc777_keyboard_direct_r,smc777_keyboard_direct_w)
592617   AM_RANGE(0x52, 0x52) AM_WRITE(smc777_ramdac_w)
618   AM_RANGE(0x53, 0x53) AM_DEVWRITE("sn1", sn76496_w) //SMC-777 specific
593619//  AM_RANGE(0x54, 0x59) AM_NOP //VTR Controller
594   AM_RANGE(0x53, 0x53) AM_DEVWRITE("sn1", sn76496_w) //not in the datasheet ... almost certainly SMC-777 specific
595620//  AM_RANGE(0x5a, 0x5b) AM_WRITENOP //RAM banking
596621//  AM_RANGE(0x70, 0x70) AM_NOP //Auto Start ROM
597622//  AM_RANGE(0x74, 0x74) AM_NOP //IEEE-488 ROM
r10469r10470
704729   PORT_BIT(0x20000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("]") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']')
705730   PORT_BIT(0x40000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^')
706731   PORT_BIT(0x80000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("_")
707
708   PORT_START("IN0")
709   PORT_DIPNAME( 0x01, 0x01, "SYSTEM" )
710   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
711   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
712   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
713   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
714   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
715   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
716   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
717   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) //space
718   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
719   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
720   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
721   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
722   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
723   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
724   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
725   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
726   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
727
728   PORT_START("IN1")
729   PORT_DIPNAME( 0x01, 0x01, "SYSTEM" )
730   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
731   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
732   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
733   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
734   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
735   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
736   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
737   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
738   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
739   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
740   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
741   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
742   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
743   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
744   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
745   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
746   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
747   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
748   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
749   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
750   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
751   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
752   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
753
754   PORT_START("DSW")
755   PORT_DIPNAME( 0x01, 0x01, "SYSTEM" )
756   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
757   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
758   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
759   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
760   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
761   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
762   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
763   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
764   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
765   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
766   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
767   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
768   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
769   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
770   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
771   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
772   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
773   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
774   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
775   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
776   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
777   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
778   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
779732INPUT_PORTS_END
780733
781734static TIMER_DEVICE_CALLBACK( keyboard_callback )
r10469r10470
865818
866819static PALETTE_INIT( smc777 )
867820{
868   int i;
869
870   for (i = 0x000; i < 0x010; i++)
871   {
872      UINT8 r,g,b;
873
874      if((i & 0x01) == 0x01)
875      {
876         r = ((i >> 3) & 1) ? 0xff : 0x00;
877         g = ((i >> 2) & 1) ? 0xff : 0x00;
878         b = ((i >> 1) & 1) ? 0xff : 0x00;
879      }
880      else { r = g = b = 0x00; }
881
882      palette_set_color_rgb(machine, i, r,g,b);
883   }
821   palette_set_color_rgb(machine, 0x10, 0xff,0xff,0xff);
822   palette_set_color_rgb(machine, 0x11, 0x00,0x00,0x00);
884823}
885824
886825static const wd17xx_interface smc777_mb8876_interface =
r10469r10470
937876    MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
938877    MCFG_SCREEN_SIZE(0x400, 400)
939878    MCFG_SCREEN_VISIBLE_AREA(0, 660-1, 0, 220-1) //normal 640 x 200 + 20 pixels for border color
940    MCFG_PALETTE_LENGTH(0x20)
879    MCFG_PALETTE_LENGTH(0x10+2) //16 palette entries + 2 special white and black
941880    MCFG_PALETTE_INIT(smc777)
942881   MCFG_GFXDECODE(smc777)
943882
r10469r10470
964903ROM_START( smc777 )
965904    ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
966905
906   /* shadow ROM */
967907    ROM_REGION( 0x10000, "bios", ROMREGION_ERASEFF )
968908   ROM_SYSTEM_BIOS(0, "1st", "1st rev.")
969909   ROMX_LOAD( "smcrom.dat", 0x0000, 0x4000, CRC(b2520d31) SHA1(3c24b742c38bbaac85c0409652ba36e20f4687a1), ROM_BIOS(1))

Previous 15994 Revisions Next


© 1998-2018 The MESS Team