src/mess/drivers/x1.c
| r14314 | r14315 | |
| 233 | 233 | state->m_pal_4096 = auto_alloc_array_clear(machine, UINT8, 0x1000*3); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | | static void x1_draw_pixel(running_machine &machine, bitmap_rgb32 &bitmap,int y,int x,UINT16 pen,UINT8 width,UINT8 height) |
| 236 | static void x1_draw_pixel(running_machine &machine, bitmap_rgb32 &bitmap,int y,int x,UINT16 pen,UINT8 width,UINT8 height) |
| 237 | 237 | { |
| 238 | 238 | if(!machine.primary_screen->visible_area().contains(x, y)) |
| 239 | 239 | return; |
| r14314 | r14315 | |
| 565 | 565 | *************************************/ |
| 566 | 566 | |
| 567 | 567 | |
| 568 | | static UINT16 check_keyboard_press(running_machine &machine) |
| 568 | UINT16 x1_state::check_keyboard_press() |
| 569 | 569 | { |
| 570 | 570 | static const char *const portnames[3] = { "key1","key2","key3" }; |
| 571 | 571 | int i,port_i,scancode; |
| 572 | | UINT8 keymod = input_port_read(machine,"key_modifiers") & 0x1f; |
| 573 | | UINT32 pad = input_port_read(machine,"tenkey"); |
| 574 | | UINT32 f_key = input_port_read(machine, "f_keys"); |
| 572 | UINT8 keymod = input_port_read(machine(),"key_modifiers") & 0x1f; |
| 573 | UINT32 pad = input_port_read(machine(),"tenkey"); |
| 574 | UINT32 f_key = input_port_read(machine(), "f_keys"); |
| 575 | 575 | scancode = 0; |
| 576 | 576 | |
| 577 | 577 | for(port_i=0;port_i<3;port_i++) |
| 578 | 578 | { |
| 579 | 579 | for(i=0;i<32;i++) |
| 580 | 580 | { |
| 581 | | if((input_port_read(machine,portnames[port_i])>>i) & 1) |
| 581 | if((input_port_read(machine(), portnames[port_i])>>i) & 1) |
| 582 | 582 | { |
| 583 | 583 | //key_flag = 1; |
| 584 | 584 | if(keymod & 0x02) // shift not pressed |
| r14314 | r14315 | |
| 629 | 629 | return 0; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | | static UINT8 check_keyboard_shift(running_machine &machine) |
| 632 | UINT8 x1_state::check_keyboard_shift() |
| 633 | 633 | { |
| 634 | 634 | UINT8 val = 0xe0; |
| 635 | 635 | /* |
| r14314 | r14315 | |
| 644 | 644 | ---- ---x CTRL ON |
| 645 | 645 | */ |
| 646 | 646 | |
| 647 | | val |= input_port_read(machine,"key_modifiers") & 0x1f; |
| 647 | val |= input_port_read(machine(), "key_modifiers") & 0x1f; |
| 648 | 648 | |
| 649 | | if(check_keyboard_press(machine) != 0) |
| 649 | if(check_keyboard_press() != 0) |
| 650 | 650 | val &= ~0x40; |
| 651 | 651 | |
| 652 | | if(check_keyboard_press(machine) & 0x100) //function keys |
| 652 | if(check_keyboard_press() & 0x100) //function keys |
| 653 | 653 | val &= ~0x80; |
| 654 | 654 | |
| 655 | 655 | return val; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | | static UINT8 get_game_key(running_machine &machine, int port) |
| 658 | UINT8 x1_state::get_game_key(UINT8 port) |
| 659 | 659 | { |
| 660 | 660 | // key status returned by sub CPU function 0xE3. |
| 661 | 661 | // in order from bit 7 to 0: |
| r14314 | r14315 | |
| 664 | 664 | // port 2: ESC,1,[-],[+],[*],TAB,SPC,RET ([] = numpad) |
| 665 | 665 | // bits are active high |
| 666 | 666 | UINT8 ret = 0; |
| 667 | | UINT32 key1 = input_port_read(machine,"key1"); |
| 668 | | UINT32 key2 = input_port_read(machine,"key2"); |
| 669 | | UINT32 key3 = input_port_read(machine,"key3"); |
| 670 | | UINT32 pad = input_port_read(machine,"tenkey"); |
| 671 | 667 | |
| 672 | | switch(port) |
| 668 | if (port == 0) |
| 673 | 669 | { |
| 674 | | case 0: |
| 675 | | if(key3 & 0x00020000) ret |= 0x80; // Q |
| 676 | | if(key3 & 0x00800000) ret |= 0x40; // W |
| 677 | | if(key3 & 0x00000020) ret |= 0x20; // E |
| 678 | | if(key3 & 0x00000002) ret |= 0x10; // A |
| 679 | | if(key3 & 0x00000010) ret |= 0x08; // D |
| 680 | | if(key3 & 0x04000000) ret |= 0x04; // Z |
| 681 | | if(key3 & 0x01000000) ret |= 0x02; // X |
| 682 | | if(key3 & 0x00000008) ret |= 0x01; // C |
| 683 | | break; |
| 684 | | case 1: |
| 685 | | if(pad & 0x00000080) ret |= 0x80; // Tenkey 7 |
| 686 | | if(pad & 0x00000010) ret |= 0x40; // Tenkey 4 |
| 687 | | if(pad & 0x00000002) ret |= 0x20; // Tenkey 1 |
| 688 | | if(pad & 0x00000100) ret |= 0x10; // Tenkey 8 |
| 689 | | if(pad & 0x00000004) ret |= 0x08; // Tenkey 2 |
| 690 | | if(pad & 0x00000200) ret |= 0x04; // Tenkey 9 |
| 691 | | if(pad & 0x00000040) ret |= 0x02; // Tenkey 6 |
| 692 | | if(pad & 0x00000008) ret |= 0x01; // Tenkey 3 |
| 693 | | break; |
| 694 | | case 2: |
| 695 | | if(key1 & 0x08000000) ret |= 0x80; // ESC |
| 696 | | if(key2 & 0x00020000) ret |= 0x40; // 1 |
| 697 | | if(pad & 0x00000400) ret |= 0x20; // Tenkey - |
| 698 | | if(pad & 0x00000800) ret |= 0x10; // Tenkey + |
| 699 | | if(pad & 0x00001000) ret |= 0x08; // Tenkey * |
| 700 | | if(key1 & 0x00000200) ret |= 0x04; // TAB |
| 701 | | if(key2 & 0x00000001) ret |= 0x02; // SPC |
| 702 | | if(key1 & 0x00002000) ret |= 0x01; // RET |
| 703 | | break; |
| 670 | UINT32 key3 = input_port_read(machine(), "key3"); |
| 671 | if(key3 & 0x00020000) ret |= 0x80; // Q |
| 672 | if(key3 & 0x00800000) ret |= 0x40; // W |
| 673 | if(key3 & 0x00000020) ret |= 0x20; // E |
| 674 | if(key3 & 0x00000002) ret |= 0x10; // A |
| 675 | if(key3 & 0x00000010) ret |= 0x08; // D |
| 676 | if(key3 & 0x04000000) ret |= 0x04; // Z |
| 677 | if(key3 & 0x01000000) ret |= 0x02; // X |
| 678 | if(key3 & 0x00000008) ret |= 0x01; // C |
| 704 | 679 | } |
| 680 | else |
| 681 | if (port == 1) |
| 682 | { |
| 683 | UINT32 pad = input_port_read(machine(), "tenkey"); |
| 684 | if(pad & 0x00000080) ret |= 0x80; // Tenkey 7 |
| 685 | if(pad & 0x00000010) ret |= 0x40; // Tenkey 4 |
| 686 | if(pad & 0x00000002) ret |= 0x20; // Tenkey 1 |
| 687 | if(pad & 0x00000100) ret |= 0x10; // Tenkey 8 |
| 688 | if(pad & 0x00000004) ret |= 0x08; // Tenkey 2 |
| 689 | if(pad & 0x00000200) ret |= 0x04; // Tenkey 9 |
| 690 | if(pad & 0x00000040) ret |= 0x02; // Tenkey 6 |
| 691 | if(pad & 0x00000008) ret |= 0x01; // Tenkey 3 |
| 692 | } |
| 693 | else |
| 694 | if (port == 2) |
| 695 | { |
| 696 | UINT32 key1 = input_port_read(machine(), "key1"); |
| 697 | UINT32 key2 = input_port_read(machine(), "key2"); |
| 698 | UINT32 pad = input_port_read(machine(), "tenkey"); |
| 699 | if(key1 & 0x08000000) ret |= 0x80; // ESC |
| 700 | if(key2 & 0x00020000) ret |= 0x40; // 1 |
| 701 | if(pad & 0x00000400) ret |= 0x20; // Tenkey - |
| 702 | if(pad & 0x00000800) ret |= 0x10; // Tenkey + |
| 703 | if(pad & 0x00001000) ret |= 0x08; // Tenkey * |
| 704 | if(key1 & 0x00000200) ret |= 0x04; // TAB |
| 705 | if(key2 & 0x00000001) ret |= 0x02; // SPC |
| 706 | if(key1 & 0x00002000) ret |= 0x01; // RET |
| 707 | } |
| 705 | 708 | |
| 706 | 709 | return ret; |
| 707 | 710 | } |
| r14314 | r14315 | |
| 716 | 719 | bus_res = m_sub_val[m_key_i]; |
| 717 | 720 | /* FIXME: likely to be different here. */ |
| 718 | 721 | m_key_i++; |
| 719 | | if(m_key_i >= 2) { m_key_i = 0; } |
| 722 | if(m_key_i >= 2) |
| 723 | m_key_i = 0; |
| 720 | 724 | |
| 721 | 725 | return bus_res; |
| 722 | 726 | } |
| r14314 | r14315 | |
| 891 | 895 | { |
| 892 | 896 | case 0xe3: //game key obtaining |
| 893 | 897 | m_sub_cmd_length = 3; |
| 894 | | m_sub_val[0] = get_game_key(machine(),0); |
| 895 | | m_sub_val[1] = get_game_key(machine(),1); |
| 896 | | m_sub_val[2] = get_game_key(machine(),2); |
| 898 | m_sub_val[0] = get_game_key(0); |
| 899 | m_sub_val[1] = get_game_key(1); |
| 900 | m_sub_val[2] = get_game_key(2); |
| 897 | 901 | break; |
| 898 | 902 | case 0xe4: //irq vector setting |
| 899 | 903 | break; |
| 900 | 904 | //case 0xe5: //timer irq clear |
| 901 | 905 | // break; |
| 902 | 906 | case 0xe6: //key data readout |
| 903 | | m_sub_val[0] = check_keyboard_shift(machine()) & 0xff; |
| 904 | | m_sub_val[1] = check_keyboard_press(machine()) & 0xff; |
| 907 | m_sub_val[0] = check_keyboard_shift() & 0xff; |
| 908 | m_sub_val[1] = check_keyboard_press() & 0xff; |
| 905 | 909 | m_sub_cmd_length = 2; |
| 906 | 910 | break; |
| 907 | 911 | // case 0xe7: // TV Control |
| r14314 | r14315 | |
| 990 | 994 | * |
| 991 | 995 | *************************************/ |
| 992 | 996 | |
| 993 | | //static UINT8 fdc_irq_flag; |
| 994 | | //static UINT8 fdc_drq_flag; |
| 995 | | //static UINT8 fdc_side; |
| 996 | | //static UINT8 fdc_drive; |
| 997 | | |
| 998 | 997 | READ8_MEMBER( x1_state::x1_fdc_r ) |
| 999 | 998 | { |
| 1000 | 999 | //UINT8 ret = 0; |
| r14314 | r14315 | |
| 1083 | 1082 | * |
| 1084 | 1083 | *************************************/ |
| 1085 | 1084 | |
| 1086 | | static UINT16 check_pcg_addr(running_machine &machine) |
| 1085 | UINT16 x1_state::check_pcg_addr() |
| 1087 | 1086 | { |
| 1088 | | x1_state *state = machine.driver_data<x1_state>(); |
| 1089 | | if(state->m_avram[0x7ff] & 0x20) return 0x7ff; |
| 1090 | | if(state->m_avram[0x3ff] & 0x20) return 0x3ff; |
| 1091 | | if(state->m_avram[0x5ff] & 0x20) return 0x5ff; |
| 1092 | | if(state->m_avram[0x1ff] & 0x20) return 0x1ff; |
| 1087 | if(m_avram[0x7ff] & 0x20) return 0x7ff; |
| 1088 | if(m_avram[0x3ff] & 0x20) return 0x3ff; |
| 1089 | if(m_avram[0x5ff] & 0x20) return 0x5ff; |
| 1090 | if(m_avram[0x1ff] & 0x20) return 0x1ff; |
| 1093 | 1091 | |
| 1094 | 1092 | return 0x3ff; |
| 1095 | 1093 | } |
| 1096 | 1094 | |
| 1097 | | static UINT16 check_chr_addr(running_machine &machine) |
| 1095 | UINT16 x1_state::check_chr_addr() |
| 1098 | 1096 | { |
| 1099 | | x1_state *state = machine.driver_data<x1_state>(); |
| 1100 | | if(!(state->m_avram[0x7ff] & 0x20)) return 0x7ff; |
| 1101 | | if(!(state->m_avram[0x3ff] & 0x20)) return 0x3ff; |
| 1102 | | if(!(state->m_avram[0x5ff] & 0x20)) return 0x5ff; |
| 1103 | | if(!(state->m_avram[0x1ff] & 0x20)) return 0x1ff; |
| 1097 | if(!(m_avram[0x7ff] & 0x20)) return 0x7ff; |
| 1098 | if(!(m_avram[0x3ff] & 0x20)) return 0x3ff; |
| 1099 | if(!(m_avram[0x5ff] & 0x20)) return 0x5ff; |
| 1100 | if(!(m_avram[0x1ff] & 0x20)) return 0x1ff; |
| 1104 | 1101 | |
| 1105 | 1102 | return 0x3ff; |
| 1106 | 1103 | } |
| 1107 | 1104 | |
| 1108 | | static UINT16 get_pcg_addr(running_machine &machine,UINT16 width,UINT8 y_char_size) |
| 1105 | UINT16 x1_state::get_pcg_addr( UINT16 width, UINT8 y_char_size ) |
| 1109 | 1106 | { |
| 1110 | | x1_state *state = machine.driver_data<x1_state>(); |
| 1111 | | int hbeam = machine.primary_screen->hpos() >> 3; |
| 1112 | | int vbeam = machine.primary_screen->vpos() / y_char_size; |
| 1113 | | UINT16 pcg_offset = ((hbeam + vbeam*width) + mc6845_start_addr) & 0x7ff; |
| 1107 | int hbeam = machine().primary_screen->hpos() >> 3; |
| 1108 | int vbeam = machine().primary_screen->vpos() / y_char_size; |
| 1109 | UINT16 pcg_offset = ((hbeam + vbeam*width) + (((m_crtc_vreg[0x0c]<<8) & 0x3f00) | (m_crtc_vreg[0x0d] & 0xff))) & 0x7ff; |
| 1114 | 1110 | |
| 1115 | 1111 | //printf("%08x %d %d %d %d\n",(hbeam+vbeam*width),hbeam,vbeam,machine.primary_screen->vpos() & 7,width); |
| 1116 | 1112 | |
| r14314 | r14315 | |
| 1129 | 1125 | if(addr == 0 && m_scrn_reg.pcg_mode) // Kanji ROM read, X1Turbo only |
| 1130 | 1126 | { |
| 1131 | 1127 | gfx_data = machine().region("kanji")->base(); |
| 1132 | | pcg_offset = (m_tvram[check_chr_addr(machine())]+(m_kvram[check_chr_addr(machine())]<<8)) & 0xfff; |
| 1128 | pcg_offset = (m_tvram[check_chr_addr()]+(m_kvram[check_chr_addr()]<<8)) & 0xfff; |
| 1133 | 1129 | pcg_offset*=0x20; |
| 1134 | 1130 | pcg_offset+=(offset & 0x0f); |
| 1135 | | pcg_offset+=(m_kvram[check_chr_addr(machine())] & 0x40) >> 2; //left-right check |
| 1131 | pcg_offset+=(m_kvram[check_chr_addr()] & 0x40) >> 2; //left-right check |
| 1136 | 1132 | |
| 1137 | 1133 | res = gfx_data[pcg_offset]; |
| 1138 | 1134 | } |
| r14314 | r14315 | |
| 1144 | 1140 | gfx_data = machine().region((addr == 0) ? "cgrom" : "pcg")->base(); |
| 1145 | 1141 | y_char_size = ((m_crtc_vreg[9]+1) > 8) ? 8 : m_crtc_vreg[9]+1; |
| 1146 | 1142 | if(y_char_size == 0) { y_char_size = 1; } |
| 1147 | | pcg_offset = m_tvram[get_pcg_addr(machine(),m_crtc_vreg[1],y_char_size)]*8; |
| 1143 | pcg_offset = m_tvram[get_pcg_addr(m_crtc_vreg[1], y_char_size)]*8; |
| 1148 | 1144 | pcg_offset+= machine().primary_screen->vpos() & (y_char_size-1); |
| 1149 | 1145 | if(addr) { pcg_offset+= ((addr-1)*0x800); } |
| 1150 | 1146 | res = gfx_data[pcg_offset]; |
| r14314 | r14315 | |
| 1169 | 1165 | { |
| 1170 | 1166 | if(m_scrn_reg.pcg_mode) // Hi-Speed Mode, X1Turbo only |
| 1171 | 1167 | { |
| 1172 | | pcg_offset = m_tvram[check_pcg_addr(machine())]*8; |
| 1168 | pcg_offset = m_tvram[check_pcg_addr()]*8; |
| 1173 | 1169 | pcg_offset+= (offset & 0xe) >> 1; |
| 1174 | 1170 | pcg_offset+=((addr-1)*0x800); |
| 1175 | 1171 | PCG_RAM[pcg_offset] = data; |
| r14314 | r14315 | |
| 1185 | 1181 | /* TODO: Brain Breaker doesn't work with this arrangement in high resolution mode, check out why */ |
| 1186 | 1182 | y_char_size = (m_crtc_vreg[9]+1) > 8 ? (m_crtc_vreg[9]+1)-8 : m_crtc_vreg[9]+1; |
| 1187 | 1183 | if(y_char_size == 0) { y_char_size = 1; } |
| 1188 | | pcg_offset = m_tvram[get_pcg_addr(machine(),m_crtc_vreg[1],y_char_size)]*8; |
| 1184 | pcg_offset = m_tvram[get_pcg_addr(m_crtc_vreg[1], y_char_size)]*8; |
| 1189 | 1185 | pcg_offset+= machine().primary_screen->vpos() & (y_char_size-1); |
| 1190 | 1186 | pcg_offset+= ((addr-1)*0x800); |
| 1191 | 1187 | |
| r14314 | r14315 | |
| 1205 | 1201 | *************************************/ |
| 1206 | 1202 | |
| 1207 | 1203 | /* for bitmap mode */ |
| 1208 | | static void set_current_palette(running_machine &machine) |
| 1204 | void x1_state::set_current_palette() |
| 1209 | 1205 | { |
| 1210 | | x1_state *state = machine.driver_data<x1_state>(); |
| 1211 | 1206 | UINT8 addr,r,g,b; |
| 1212 | 1207 | |
| 1213 | 1208 | for(addr=0;addr<8;addr++) |
| 1214 | 1209 | { |
| 1215 | | r = ((state->m_x_r)>>(addr)) & 1; |
| 1216 | | g = ((state->m_x_g)>>(addr)) & 1; |
| 1217 | | b = ((state->m_x_b)>>(addr)) & 1; |
| 1210 | r = ((m_x_r)>>(addr)) & 1; |
| 1211 | g = ((m_x_g)>>(addr)) & 1; |
| 1212 | b = ((m_x_b)>>(addr)) & 1; |
| 1218 | 1213 | |
| 1219 | | palette_set_color_rgb(machine, addr|8, pal1bit(r), pal1bit(g), pal1bit(b)); |
| 1214 | palette_set_color_rgb(machine(), addr|8, pal1bit(r), pal1bit(g), pal1bit(b)); |
| 1220 | 1215 | } |
| 1221 | 1216 | } |
| 1222 | 1217 | |
| r14314 | r14315 | |
| 1248 | 1243 | else //compatible mode |
| 1249 | 1244 | { |
| 1250 | 1245 | m_x_r = data; |
| 1251 | | set_current_palette(machine()); |
| 1246 | set_current_palette(); |
| 1252 | 1247 | //if(m_old_vpos != machine().primary_screen->vpos()) |
| 1253 | 1248 | //{ |
| 1254 | 1249 | // machine().primary_screen->update_partial(machine().primary_screen->vpos()); |
| r14314 | r14315 | |
| 1267 | 1262 | else |
| 1268 | 1263 | { |
| 1269 | 1264 | m_x_g = data; |
| 1270 | | set_current_palette(machine()); |
| 1265 | set_current_palette(); |
| 1271 | 1266 | //if(m_old_vpos != machine().primary_screen->vpos()) |
| 1272 | 1267 | //{ |
| 1273 | 1268 | machine().primary_screen->update_partial(machine().primary_screen->vpos()); |
| r14314 | r14315 | |
| 1286 | 1281 | else |
| 1287 | 1282 | { |
| 1288 | 1283 | m_x_b = data; |
| 1289 | | set_current_palette(machine()); |
| 1284 | set_current_palette(); |
| 1290 | 1285 | //if(m_old_vpos != machine().primary_screen->vpos()) |
| 1291 | 1286 | //{ |
| 1292 | 1287 | // machine().primary_screen->update_partial(machine().primary_screen->vpos()); |
| r14314 | r14315 | |
| 1620 | 1615 | if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| 1621 | 1616 | // TODO: user could install ym2151 on plain X1 too |
| 1622 | 1617 | //0x700, 0x701 |
| 1623 | | //if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(machine().device("ctc"), offset-0x0704); } |
| 1618 | //if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(m_ctc, offset-0x0704); } |
| 1624 | 1619 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 1625 | 1620 | else if(offset >= 0x1400 && offset <= 0x17ff) { return x1_pcg_r(space, offset-0x1400); } |
| 1626 | 1621 | else if(offset >= 0x1900 && offset <= 0x19ff) { return x1_sub_io_r(space, 0); } |
| r14314 | r14315 | |
| 1629 | 1624 | // else if(offset >= 0x1f80 && offset <= 0x1f8f) { return z80dma_r(machine().device("dma"), 0); } |
| 1630 | 1625 | // else if(offset >= 0x1f90 && offset <= 0x1f91) { return z80sio_c_r(machine().device("sio"), (offset-0x1f90) & 1); } |
| 1631 | 1626 | // else if(offset >= 0x1f92 && offset <= 0x1f93) { return z80sio_d_r(machine().device("sio"), (offset-0x1f92) & 1); } |
| 1632 | | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(machine().device("ctc"), offset-0x1fa0); } |
| 1633 | | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(machine().device("ctc"), offset-0x1fa8); } |
| 1627 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(m_ctc, offset-0x1fa0); } |
| 1628 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(m_ctc, offset-0x1fa8); } |
| 1634 | 1629 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 1635 | 1630 | // else if(offset == 0x1fe0) { return x1turboz_blackclip_r(space,0); } |
| 1636 | 1631 | else if(offset >= 0x2000 && offset <= 0x2fff) { return m_avram[offset & 0x7ff]; } |
| r14314 | r14315 | |
| 1648 | 1643 | if(m_io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 1649 | 1644 | // TODO: user could install ym2151 on plain X1 too |
| 1650 | 1645 | //0x700, 0x701 |
| 1651 | | // else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(machine().device("ctc"), offset-0x0704,data); } |
| 1646 | // else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(m_ctc, offset-0x0704,data); } |
| 1652 | 1647 | // else if(offset >= 0x0c00 && offset <= 0x0cff) { x1_rs232c_w(machine(), 0, data); } |
| 1653 | 1648 | else if(offset >= 0x0e00 && offset <= 0x0e02) { x1_rom_w(space, offset-0xe00,data); } |
| 1654 | 1649 | // else if(offset >= 0x0e80 && offset <= 0x0e82) { x1_kanji_w(machine(), offset-0xe80,data); } |
| r14314 | r14315 | |
| 1668 | 1663 | // else if(offset >= 0x1f80 && offset <= 0x1f8f) { z80dma_w(machine().device("dma"), 0,data); } |
| 1669 | 1664 | // else if(offset >= 0x1f90 && offset <= 0x1f91) { z80sio_c_w(machine().device("sio"), (offset-0x1f90) & 1,data); } |
| 1670 | 1665 | // else if(offset >= 0x1f92 && offset <= 0x1f93) { z80sio_d_w(machine().device("sio"), (offset-0x1f92) & 1,data); } |
| 1671 | | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { z80ctc_w(machine().device("ctc"), offset-0x1fa0,data); } |
| 1672 | | else if(offset >= 0x1fa8 && offset <= 0x1fab) { z80ctc_w(machine().device("ctc"), offset-0x1fa8,data); } |
| 1666 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { z80ctc_w(m_ctc, offset-0x1fa0,data); } |
| 1667 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { z80ctc_w(m_ctc, offset-0x1fa8,data); } |
| 1673 | 1668 | // else if(offset == 0x1fb0) { x1turbo_pal_w(space,0,data); } |
| 1674 | 1669 | // else if(offset >= 0x1fb9 && offset <= 0x1fbf) { x1turbo_txpal_w(space,offset-0x1fb9,data); } |
| 1675 | 1670 | // else if(offset == 0x1fc0) { x1turbo_txdisp_w(space,0,data); } |
| r14314 | r14315 | |
| 1694 | 1689 | if(offset == 0x0700) { return (ym2151_r(machine().device("ym"), offset-0x0700) & 0x7f) | (input_port_read(machine(), "SOUND_SW") & 0x80); } |
| 1695 | 1690 | else if(offset == 0x0701) { return ym2151_r(machine().device("ym"), offset-0x0700); } |
| 1696 | 1691 | //0x704 is FM sound detection port on X1 turboZ |
| 1697 | | else if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(machine().device("ctc"), offset-0x0704); } |
| 1692 | else if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(m_ctc, offset-0x0704); } |
| 1698 | 1693 | else if(offset == 0x0801) { printf("Color image board read\n"); return 0xff; } // * |
| 1699 | 1694 | else if(offset == 0x0803) { printf("Color image board 2 read\n"); return 0xff; } // * |
| 1700 | 1695 | else if(offset >= 0x0a00 && offset <= 0x0a07) { printf("Stereoscopic board read %04x\n",offset); return 0xff; } // * |
| r14314 | r14315 | |
| 1713 | 1708 | else if(offset >= 0x1f80 && offset <= 0x1f8f) { return z80dma_r(machine().device("dma"), 0); } |
| 1714 | 1709 | else if(offset >= 0x1f90 && offset <= 0x1f93) { return z80dart_ba_cd_r(machine().device("sio"), (offset-0x1f90) & 3); } |
| 1715 | 1710 | else if(offset >= 0x1f98 && offset <= 0x1f9f) { printf("Extended SIO/CTC read %04x\n",offset); return 0xff; } |
| 1716 | | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(machine().device("ctc"), offset-0x1fa0); } |
| 1717 | | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(machine().device("ctc"), offset-0x1fa8); } |
| 1711 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(m_ctc, offset-0x1fa0); } |
| 1712 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(m_ctc, offset-0x1fa8); } |
| 1718 | 1713 | else if(offset == 0x1fb0) { return x1turbo_pal_r(space,0); } // Z only! |
| 1719 | 1714 | else if(offset >= 0x1fb8 && offset <= 0x1fbf) { return x1turbo_txpal_r(space,offset-0x1fb8); } //Z only! |
| 1720 | 1715 | else if(offset == 0x1fc0) { return x1turbo_txdisp_r(space,0); } // Z only! |
| r14314 | r14315 | |
| 1739 | 1734 | if(m_io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 1740 | 1735 | else if(offset == 0x0700 || offset == 0x0701) { ym2151_w(machine().device("ym"), offset-0x0700,data); } |
| 1741 | 1736 | //0x704 is FM sound detection port on X1 turboZ |
| 1742 | | else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(machine().device("ctc"), offset-0x0704,data); } |
| 1737 | else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(m_ctc, offset-0x0704,data); } |
| 1743 | 1738 | else if(offset == 0x0800) { printf("Color image board write %02x\n",data); } // * |
| 1744 | 1739 | else if(offset == 0x0802) { printf("Color image board 2 write %02x\n",data); } // * |
| 1745 | 1740 | else if(offset >= 0x0a00 && offset <= 0x0a07) { printf("Stereoscopic board write %04x %02x\n",offset,data); } // * |
| r14314 | r14315 | |
| 1766 | 1761 | else if(offset >= 0x1f80 && offset <= 0x1f8f) { z80dma_w(machine().device("dma"), 0,data); } |
| 1767 | 1762 | else if(offset >= 0x1f90 && offset <= 0x1f93) { z80dart_ba_cd_w(machine().device("sio"), (offset-0x1f90) & 3,data); } |
| 1768 | 1763 | else if(offset >= 0x1f98 && offset <= 0x1f9f) { printf("Extended SIO/CTC write %04x %02x\n",offset,data); } |
| 1769 | | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { z80ctc_w(machine().device("ctc"), offset-0x1fa0,data); } |
| 1770 | | else if(offset >= 0x1fa8 && offset <= 0x1fab) { z80ctc_w(machine().device("ctc"), offset-0x1fa8,data); } |
| 1764 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { z80ctc_w(m_ctc, offset-0x1fa0,data); } |
| 1765 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { z80ctc_w(m_ctc, offset-0x1fa8,data); } |
| 1771 | 1766 | else if(offset == 0x1fb0) { x1turbo_pal_w(space,0,data); } // Z only! |
| 1772 | 1767 | else if(offset >= 0x1fb8 && offset <= 0x1fbf) { x1turbo_txpal_w(space,offset-0x1fb8,data); } //Z only! |
| 1773 | 1768 | else if(offset == 0x1fc0) { x1turbo_txdisp_w(space,0,data); } //Z only! |
| r14314 | r14315 | |
| 2152 | 2147 | PORT_BIT(0x00000008,IP_ACTIVE_LOW,IPT_KEYBOARD) PORT_NAME("CAPS") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE |
| 2153 | 2148 | PORT_BIT(0x00000010,IP_ACTIVE_LOW,IPT_KEYBOARD) PORT_NAME("GRPH") PORT_CODE(KEYCODE_LALT) |
| 2154 | 2149 | |
| 2155 | | #if 0 |
| 2150 | #if 0 |
| 2156 | 2151 | PORT_BIT(0x00020000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 2157 | 2152 | PORT_BIT(0x00040000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') |
| 2158 | 2153 | PORT_BIT(0x00080000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| r14314 | r14315 | |
| 2194 | 2189 | PORT_BIT(0x08000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("PF9") PORT_CODE(KEYCODE_F9) |
| 2195 | 2190 | PORT_BIT(0x10000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("PF10") PORT_CODE(KEYCODE_F10) |
| 2196 | 2191 | |
| 2197 | | #endif |
| 2192 | #endif |
| 2198 | 2193 | INPUT_PORTS_END |
| 2199 | 2194 | |
| 2200 | 2195 | INPUT_PORTS_START( x1turbo ) |
| r14314 | r14315 | |
| 2336 | 2331 | |
| 2337 | 2332 | static const z80_daisy_config x1_daisy[] = |
| 2338 | 2333 | { |
| 2339 | | { "x1kb" }, |
| 2334 | { "x1kb" }, |
| 2340 | 2335 | { "ctc" }, |
| 2341 | 2336 | { NULL } |
| 2342 | 2337 | }; |
| 2343 | 2338 | |
| 2344 | 2339 | static const z80_daisy_config x1turbo_daisy[] = |
| 2345 | 2340 | { |
| 2346 | | { "x1kb" }, |
| 2341 | { "x1kb" }, |
| 2347 | 2342 | { "ctc" }, |
| 2348 | 2343 | { "dma" }, |
| 2349 | 2344 | { "sio" }, |
| r14314 | r14315 | |
| 2585 | 2580 | MCFG_CPU_IO_MAP(x1_io) |
| 2586 | 2581 | MCFG_CPU_CONFIG(x1_daisy) |
| 2587 | 2582 | |
| 2588 | | MCFG_Z80CTC_ADD( "ctc", MAIN_CLOCK/4 , ctc_intf ) |
| 2583 | MCFG_Z80CTC_ADD( "ctc", MAIN_CLOCK/4, ctc_intf ) |
| 2589 | 2584 | |
| 2590 | 2585 | MCFG_DEVICE_ADD("x1kb", X1_KEYBOARD, 0) |
| 2591 | 2586 | |
src/mess/drivers/x1twin.c
| r14314 | r14315 | |
| 17 | 17 | |
| 18 | 18 | #include "includes/pce.h" |
| 19 | 19 | #include "video/vdc.h" |
| 20 | | #include "cpu/h6280/h6280.h" |
| 21 | | #include "sound/c6280.h" |
| 20 | //#include "cpu/h6280/h6280.h" |
| 21 | //#include "sound/c6280.h" |
| 22 | 22 | #include "machine/pcecommn.h" |
| 23 | 23 | |
| 24 | 24 | #include "rendlay.h" |
| r14314 | r14315 | |
| 28 | 28 | public: |
| 29 | 29 | x1twin_state(const machine_config &mconfig, device_type type, const char *tag) |
| 30 | 30 | : x1_state(mconfig, type, tag) |
| 31 | | { } |
| 31 | { } |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | |
| r14314 | r14315 | |
| 36 | 36 | #define VDP_CLOCK XTAL_42_9545MHz |
| 37 | 37 | #define MCU_CLOCK XTAL_6MHz |
| 38 | 38 | |
| 39 | | static SCREEN_UPDATE_RGB32( x1twin ) |
| 39 | static SCREEN_UPDATE_RGB32( x1pce ) |
| 40 | 40 | { |
| 41 | | device_t *left_screen = screen.machine().device("x1_screen"); |
| 42 | | //device_t *right_screen = screen.machine().device("pce_screen"); |
| 43 | | |
| 44 | | if (&screen==left_screen) |
| 45 | | SCREEN_UPDATE16_CALL( x1 ); |
| 46 | | |
| 47 | 41 | return 0; |
| 48 | 42 | } |
| 49 | 43 | |
| r14314 | r14315 | |
| 52 | 46 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(x1_mem_r,x1_mem_w) |
| 53 | 47 | ADDRESS_MAP_END |
| 54 | 48 | |
| 55 | | static ADDRESS_MAP_START( x1_io , AS_IO, 8, x1twin_state ) |
| 49 | static ADDRESS_MAP_START( x1_io, AS_IO, 8, x1twin_state ) |
| 56 | 50 | ADDRESS_MAP_UNMAP_HIGH |
| 57 | 51 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(x1_io_r, x1_io_w) |
| 58 | 52 | ADDRESS_MAP_END |
| 59 | 53 | |
| 60 | 54 | #if 0 |
| 61 | | static ADDRESS_MAP_START( pce_mem , AS_PROGRAM, 8) |
| 55 | static ADDRESS_MAP_START( pce_mem , AS_PROGRAM, 8, x1twin_state ) |
| 62 | 56 | AM_RANGE( 0x000000, 0x09FFFF) AM_ROM |
| 63 | 57 | AM_RANGE( 0x1F0000, 0x1F1FFF) AM_RAM AM_MIRROR(0x6000) AM_BASE( &pce_user_ram ) |
| 64 | 58 | AM_RANGE( 0x1FE000, 0x1FE3FF) AM_READWRITE( vdc_0_r, vdc_0_w ) |
| r14314 | r14315 | |
| 69 | 63 | AM_RANGE( 0x1FF400, 0x1FF7FF) AM_READWRITE( h6280_irq_status_r, h6280_irq_status_w ) |
| 70 | 64 | ADDRESS_MAP_END |
| 71 | 65 | |
| 72 | | static ADDRESS_MAP_START( pce_io , AS_IO, 8) |
| 66 | static ADDRESS_MAP_START( pce_io, AS_IO, 8, x1twin_state ) |
| 73 | 67 | AM_RANGE( 0x00, 0x03) AM_READWRITE( vdc_0_r, vdc_0_w ) |
| 74 | 68 | ADDRESS_MAP_END |
| 75 | 69 | #endif |
| r14314 | r14315 | |
| 321 | 315 | PORT_BIT(0x00000008,IP_ACTIVE_LOW,IPT_KEYBOARD) PORT_NAME("CAPS") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE |
| 322 | 316 | PORT_BIT(0x00000010,IP_ACTIVE_LOW,IPT_KEYBOARD) PORT_NAME("GRPH") PORT_CODE(KEYCODE_LALT) |
| 323 | 317 | |
| 324 | | #if 0 |
| 318 | #if 0 |
| 325 | 319 | PORT_BIT(0x00020000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 326 | 320 | PORT_BIT(0x00040000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') |
| 327 | 321 | PORT_BIT(0x00080000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| r14314 | r14315 | |
| 363 | 357 | PORT_BIT(0x08000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("PF9") PORT_CODE(KEYCODE_F9) |
| 364 | 358 | PORT_BIT(0x10000000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("PF10") PORT_CODE(KEYCODE_F10) |
| 365 | 359 | |
| 366 | | #endif |
| 360 | #endif |
| 367 | 361 | INPUT_PORTS_END |
| 368 | 362 | |
| 369 | 363 | |
| r14314 | r14315 | |
| 471 | 465 | |
| 472 | 466 | static const z80_daisy_config x1_daisy[] = |
| 473 | 467 | { |
| 474 | | { "x1kb" }, |
| 468 | { "x1kb" }, |
| 475 | 469 | { "ctc" }, |
| 476 | 470 | { NULL } |
| 477 | 471 | }; |
| r14314 | r14315 | |
| 555 | 549 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 556 | 550 | MCFG_SCREEN_SIZE(640, 480) |
| 557 | 551 | MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 558 | | MCFG_SCREEN_UPDATE_STATIC(x1twin) |
| 552 | MCFG_SCREEN_UPDATE_STATIC(x1) |
| 559 | 553 | |
| 560 | 554 | MCFG_SCREEN_ADD("pce_screen", RASTER) |
| 561 | 555 | MCFG_SCREEN_REFRESH_RATE(60) |
| 562 | 556 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 563 | 557 | MCFG_SCREEN_RAW_PARAMS(PCE_MAIN_CLOCK/2, VDC_WPF, 70, 70 + 512 + 32, VDC_LPF, 14, 14+242) |
| 564 | | MCFG_SCREEN_UPDATE_STATIC(x1twin) |
| 558 | MCFG_SCREEN_UPDATE_STATIC(x1pce) |
| 565 | 559 | |
| 566 | 560 | MCFG_MC6845_ADD("crtc", H46505, (VDP_CLOCK/48), mc6845_intf) //unknown divider |
| 567 | 561 | MCFG_PALETTE_LENGTH(0x10+0x1000) |
| r14314 | r14315 | |
| 601 | 595 | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(x1_floppy_interface) |
| 602 | 596 | MCFG_SOFTWARE_LIST_ADD("flop_list","x1_flop") |
| 603 | 597 | |
| 604 | | #if 0 |
| 598 | #if 0 |
| 605 | 599 | MCFG_SOUND_ADD("c6280", C6280, PCE_MAIN_CLOCK/6) |
| 606 | 600 | // MCFG_SOUND_CONFIG(c6280_config) |
| 607 | 601 | MCFG_SOUND_ROUTE(0, "pce_l", 0.5) |
| 608 | 602 | MCFG_SOUND_ROUTE(1, "pce_r", 0.5) |
| 609 | | #endif |
| 603 | #endif |
| 610 | 604 | |
| 611 | 605 | MCFG_TIMER_ADD_PERIODIC("keyboard_timer", x1_keyboard_callback, attotime::from_hz(250)) |
| 612 | 606 | MCFG_TIMER_ADD_PERIODIC("cmt_wind_timer", x1_cmt_wind_timer, attotime::from_hz(16)) |