src/mess/drivers/smc777.c
| r10469 | r10470 | |
| 2 | 2 | |
| 3 | 3 | SMC-777 (c) 1983 Sony |
| 4 | 4 | |
| 5 | | preliminary driver by Angelo Salese |
| 5 | driver by Angelo Salese |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | 8 | - no documentation, the entire driver is just a bunch of educated |
| r10469 | r10470 | |
| 10 | 10 | - ROM/RAM bankswitch, it apparently happens after one instruction prefetching. |
| 11 | 11 | We currently use an hackish implementation until the MAME/MESS framework can |
| 12 | 12 | support that ... |
| 13 | | - keyboard input is very very sluggish; |
| 14 | | - colors in Dragon's Alphabet, Bird Crash; |
| 13 | - keyboard input is very sluggish; |
| 15 | 14 | - 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; |
| 16 | 18 | |
| 17 | 19 | **************************************************************************************/ |
| 18 | 20 | |
| r10469 | r10470 | |
| 69 | 71 | UINT8 *gram = screen->machine->region("fbuf")->base(); |
| 70 | 72 | int x_width; |
| 71 | 73 | |
| 72 | | bitmap_fill(bitmap, cliprect, screen->machine->pens[state->backdrop_pen+0x10]); |
| 74 | bitmap_fill(bitmap, cliprect, screen->machine->pens[state->backdrop_pen]); |
| 73 | 75 | |
| 74 | 76 | x_width = (state->display_reg & 0x80) ? 2 : 4; |
| 75 | 77 | |
| r10469 | r10470 | |
| 87 | 89 | /* todo: clean this up! */ |
| 88 | 90 | if(x_width == 2) |
| 89 | 91 | { |
| 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]; |
| 91 | 93 | } |
| 92 | 94 | else |
| 93 | 95 | { |
| 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]; |
| 96 | 98 | } |
| 97 | 99 | |
| 98 | 100 | color = (gram[count] & 0x0f) >> 0; |
| 99 | 101 | if(x_width == 2) |
| 100 | 102 | { |
| 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]; |
| 102 | 104 | } |
| 103 | 105 | else |
| 104 | 106 | { |
| 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]; |
| 107 | 109 | } |
| 108 | 110 | |
| 109 | 111 | count++; |
| r10469 | r10470 | |
| 121 | 123 | { |
| 122 | 124 | for(x=0;x<x_width;x++) |
| 123 | 125 | { |
| 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 | */ |
| 124 | 131 | int tile = vram[count]; |
| 125 | 132 | int color = attr[count] & 7; |
| 126 | 133 | 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 }; |
| 128 | 138 | |
| 129 | | bk_pen = 0x00; |
| 130 | | switch(bk_color) |
| 139 | switch(bk_color & 3) |
| 131 | 140 | { |
| 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 |
| 135 | 145 | } |
| 136 | 146 | |
| 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; |
| 141 | 149 | |
| 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; |
| 144 | 156 | |
| 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 | |
| 145 | 164 | // draw cursor |
| 146 | 165 | if(state->cursor_addr == count) |
| 147 | 166 | { |
| r10469 | r10470 | |
| 162 | 181 | { |
| 163 | 182 | for(xc=0;xc<8;xc++) |
| 164 | 183 | { |
| 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]; |
| 166 | 185 | } |
| 167 | 186 | } |
| 168 | 187 | } |
| r10469 | r10470 | |
| 355 | 374 | { |
| 356 | 375 | smc777_state *drvstate = device->machine->driver_data<smc777_state>(); |
| 357 | 376 | drvstate->fdc_irq_flag = state; |
| 358 | | // cputag_set_input_line(device->machine, "maincpu", 0, (state) ? ASSERT_LINE : CLEAR_LINE); |
| 359 | 377 | } |
| 360 | 378 | |
| 361 | 379 | static WRITE_LINE_DEVICE_HANDLER( smc777_fdc_drq_w ) |
| r10469 | r10470 | |
| 391 | 409 | { |
| 392 | 410 | smc777_state *state = space->machine->driver_data<smc777_state>(); |
| 393 | 411 | |
| 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 | |
| 394 | 420 | return state->system_data; |
| 395 | 421 | } |
| 396 | 422 | |
| 397 | | //static TIMER_CALLBACK( raminh_change ) |
| 398 | 423 | |
| 399 | 424 | |
| 400 | 425 | static WRITE8_HANDLER( system_output_w ) |
| r10469 | r10470 | |
| 467 | 492 | |
| 468 | 493 | switch(gradient_index) |
| 469 | 494 | { |
| 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; |
| 473 | 498 | } |
| 474 | 499 | } |
| 475 | 500 | |
| r10469 | r10470 | |
| 590 | 615 | // AM_RANGE(0x48, 0x50) AM_NOP //HDD (Winchester) |
| 591 | 616 | AM_RANGE(0x51, 0x51) AM_READWRITE(smc777_keyboard_direct_r,smc777_keyboard_direct_w) |
| 592 | 617 | AM_RANGE(0x52, 0x52) AM_WRITE(smc777_ramdac_w) |
| 618 | AM_RANGE(0x53, 0x53) AM_DEVWRITE("sn1", sn76496_w) //SMC-777 specific |
| 593 | 619 | // 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 |
| 595 | 620 | // AM_RANGE(0x5a, 0x5b) AM_WRITENOP //RAM banking |
| 596 | 621 | // AM_RANGE(0x70, 0x70) AM_NOP //Auto Start ROM |
| 597 | 622 | // AM_RANGE(0x74, 0x74) AM_NOP //IEEE-488 ROM |
| r10469 | r10470 | |
| 704 | 729 | PORT_BIT(0x20000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("]") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']') |
| 705 | 730 | PORT_BIT(0x40000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^') |
| 706 | 731 | 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 ) ) |
| 779 | 732 | INPUT_PORTS_END |
| 780 | 733 | |
| 781 | 734 | static TIMER_DEVICE_CALLBACK( keyboard_callback ) |
| r10469 | r10470 | |
| 865 | 818 | |
| 866 | 819 | static PALETTE_INIT( smc777 ) |
| 867 | 820 | { |
| 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); |
| 884 | 823 | } |
| 885 | 824 | |
| 886 | 825 | static const wd17xx_interface smc777_mb8876_interface = |
| r10469 | r10470 | |
| 937 | 876 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 938 | 877 | MCFG_SCREEN_SIZE(0x400, 400) |
| 939 | 878 | 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 |
| 941 | 880 | MCFG_PALETTE_INIT(smc777) |
| 942 | 881 | MCFG_GFXDECODE(smc777) |
| 943 | 882 | |
| r10469 | r10470 | |
| 964 | 903 | ROM_START( smc777 ) |
| 965 | 904 | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |
| 966 | 905 | |
| 906 | /* shadow ROM */ |
| 967 | 907 | ROM_REGION( 0x10000, "bios", ROMREGION_ERASEFF ) |
| 968 | 908 | ROM_SYSTEM_BIOS(0, "1st", "1st rev.") |
| 969 | 909 | ROMX_LOAD( "smcrom.dat", 0x0000, 0x4000, CRC(b2520d31) SHA1(3c24b742c38bbaac85c0409652ba36e20f4687a1), ROM_BIOS(1)) |