src/mess/drivers/atarist.c
| r856 | r857 | |
| 23 | 23 | |
| 24 | 24 | - proper UK TOS roms |
| 25 | 25 | - save state support |
| 26 | | - serial communications for the HD63701 cpu |
| 27 | | - US keyboard layout for the special keys |
| 26 | - rewrite HD6301 cpu core for serial I/O |
| 27 | - UK keyboard layout for the special keys |
| 28 | 28 | - accurate screen timing |
| 29 | 29 | - memory shadow for boot memory check |
| 30 | | - STe DMA sound and LMC1992/Microwire mixer |
| 30 | - floppy DMA transfer timer |
| 31 | - STe DMA sound and LMC1992 Microwire mixer |
| 31 | 32 | - Mega STe 8/16 MHz switch |
| 32 | 33 | - Mega STe MC68881 FPU |
| 33 | 34 | - Mega STe SCC8530 interface |
| r856 | r857 | |
| 51 | 52 | |
| 52 | 53 | #define ATARIST_FLOPPY_BYTES_PER_SECTOR 512 |
| 53 | 54 | |
| 54 | | struct FDC |
| 55 | static struct FDC |
| 55 | 56 | { |
| 56 | 57 | UINT32 dmabase; |
| 57 | 58 | UINT16 status, mode; |
| r856 | r857 | |
| 236 | 237 | |
| 237 | 238 | /* IKBD */ |
| 238 | 239 | |
| 239 | | static UINT8 acia_ikbd_rx, acia_ikbd_tx; |
| 240 | | static UINT8 ikbd_keylatch; |
| 241 | | static UINT8 ikbd_mouse_x0, ikbd_mouse_y0; |
| 242 | | static UINT8 ikbd_mouse_x_phase, ikbd_mouse_y_phase, ikbd_mouse_phase_counter; |
| 240 | static struct IKBD |
| 241 | { |
| 242 | UINT8 keylatch; |
| 243 | UINT8 mouse_x, mouse_y; |
| 244 | UINT8 mouse_px, mouse_py, mouse_pc; |
| 245 | UINT8 rx, tx; |
| 246 | } ikbd; |
| 243 | 247 | |
| 244 | 248 | static const int IKBD_MOUSE_XYA[3][4] = { { 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 } }; |
| 245 | 249 | static const int IKBD_MOUSE_XYB[3][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0, 0 } }; |
| r856 | r857 | |
| 253 | 257 | |
| 254 | 258 | static READ8_HANDLER( ikbd_port1_r ) |
| 255 | 259 | { |
| 256 | | return ikbd_keylatch; |
| 260 | /* |
| 261 | |
| 262 | bit description |
| 263 | |
| 264 | 0 Keyboard column input |
| 265 | 1 Keyboard column input |
| 266 | 2 Keyboard column input |
| 267 | 3 Keyboard column input |
| 268 | 4 Keyboard column input |
| 269 | 5 Keyboard column input |
| 270 | 6 Keyboard column input |
| 271 | 7 Keyboard column input |
| 272 | |
| 273 | */ |
| 274 | |
| 275 | return ikbd.keylatch; |
| 257 | 276 | } |
| 258 | 277 | |
| 259 | 278 | static READ8_HANDLER( ikbd_port2_r ) |
| r856 | r857 | |
| 270 | 289 | |
| 271 | 290 | */ |
| 272 | 291 | |
| 273 | | return (acia_ikbd_tx << 3) | (readinputportbytag("JOY1") & 0x06); |
| 292 | return (ikbd.tx << 3) | (readinputportbytag_safe("IKBD_JOY1", 0xff) & 0x06); |
| 274 | 293 | } |
| 275 | 294 | |
| 276 | 295 | static WRITE8_HANDLER( ikbd_port2_w ) |
| r856 | r857 | |
| 287 | 306 | |
| 288 | 307 | */ |
| 289 | 308 | |
| 290 | | acia_ikbd_rx = (data & 0x10) >> 4; |
| 309 | ikbd.rx = (data & 0x10) >> 4; |
| 291 | 310 | } |
| 292 | 311 | |
| 293 | 312 | static WRITE8_HANDLER( ikbd_port3_w ) |
| r856 | r857 | |
| 309 | 328 | |
| 310 | 329 | set_led_status(1, data & 0x01); |
| 311 | 330 | |
| 312 | | if (~data & 0x02) ikbd_keylatch = readinputportbytag("P31"); |
| 313 | | if (~data & 0x04) ikbd_keylatch = readinputportbytag("P32"); |
| 314 | | if (~data & 0x08) ikbd_keylatch = readinputportbytag("P33"); |
| 315 | | if (~data & 0x10) ikbd_keylatch = readinputportbytag("P34"); |
| 316 | | if (~data & 0x20) ikbd_keylatch = readinputportbytag("P35"); |
| 317 | | if (~data & 0x40) ikbd_keylatch = readinputportbytag("P36"); |
| 318 | | if (~data & 0x80) ikbd_keylatch = readinputportbytag("P37"); |
| 331 | if (~data & 0x02) ikbd.keylatch = readinputportbytag("P31"); |
| 332 | if (~data & 0x04) ikbd.keylatch = readinputportbytag("P32"); |
| 333 | if (~data & 0x08) ikbd.keylatch = readinputportbytag("P33"); |
| 334 | if (~data & 0x10) ikbd.keylatch = readinputportbytag("P34"); |
| 335 | if (~data & 0x20) ikbd.keylatch = readinputportbytag("P35"); |
| 336 | if (~data & 0x40) ikbd.keylatch = readinputportbytag("P36"); |
| 337 | if (~data & 0x80) ikbd.keylatch = readinputportbytag("P37"); |
| 319 | 338 | } |
| 320 | 339 | |
| 321 | 340 | static READ8_HANDLER( ikbd_port4_r ) |
| 322 | 341 | { |
| 342 | /* |
| 343 | |
| 344 | bit description |
| 345 | |
| 346 | 0 JOY 0-1 or mouse XB |
| 347 | 1 JOY 0-2 or mouse XA |
| 348 | 2 JOY 0-3 or mouse YA |
| 349 | 3 JOY 0-4 or mouse YB |
| 350 | 4 JOY 1-1 |
| 351 | 5 JOY 1-2 |
| 352 | 6 JOY 1-3 |
| 353 | 7 JOY 1-4 |
| 354 | |
| 355 | */ |
| 356 | |
| 323 | 357 | if (readinputportbytag("config") & 0x01) |
| 324 | 358 | { |
| 325 | 359 | /* |
| r856 | r857 | |
| 331 | 365 | |
| 332 | 366 | */ |
| 333 | 367 | |
| 334 | | UINT8 data = readinputportbytag("JOY0") & 0xf0; |
| 335 | | UINT8 x = readinputportbytag("MOUSEX"); |
| 336 | | UINT8 y = readinputportbytag("MOUSEY"); |
| 368 | UINT8 data = readinputportbytag_safe("IKBD_JOY0", 0xff) & 0xf0; |
| 369 | UINT8 x = readinputportbytag_safe("IKBD_MOUSEX", 0x00); |
| 370 | UINT8 y = readinputportbytag_safe("IKBD_MOUSEY", 0x00); |
| 337 | 371 | |
| 338 | | if (x == ikbd_mouse_x0) |
| 372 | if (x == ikbd.mouse_x) |
| 339 | 373 | { |
| 340 | | ikbd_mouse_x_phase = IKBD_MOUSE_PHASE_STATIC; |
| 374 | ikbd.mouse_px = IKBD_MOUSE_PHASE_STATIC; |
| 341 | 375 | } |
| 342 | | else if (x > ikbd_mouse_x0) |
| 376 | else if (x > ikbd.mouse_x) |
| 343 | 377 | { |
| 344 | | ikbd_mouse_x_phase = IKBD_MOUSE_PHASE_POSITIVE; |
| 378 | ikbd.mouse_px = IKBD_MOUSE_PHASE_POSITIVE; |
| 345 | 379 | } |
| 346 | | else if (x < ikbd_mouse_x0) |
| 380 | else if (x < ikbd.mouse_x) |
| 347 | 381 | { |
| 348 | | ikbd_mouse_x_phase = IKBD_MOUSE_PHASE_NEGATIVE; |
| 382 | ikbd.mouse_px = IKBD_MOUSE_PHASE_NEGATIVE; |
| 349 | 383 | } |
| 350 | 384 | |
| 351 | | if (y == ikbd_mouse_y0) |
| 385 | if (y == ikbd.mouse_y) |
| 352 | 386 | { |
| 353 | | ikbd_mouse_y_phase = IKBD_MOUSE_PHASE_STATIC; |
| 387 | ikbd.mouse_py = IKBD_MOUSE_PHASE_STATIC; |
| 354 | 388 | } |
| 355 | | else if (y > ikbd_mouse_y0) |
| 389 | else if (y > ikbd.mouse_y) |
| 356 | 390 | { |
| 357 | | ikbd_mouse_y_phase = IKBD_MOUSE_PHASE_POSITIVE; |
| 391 | ikbd.mouse_py = IKBD_MOUSE_PHASE_POSITIVE; |
| 358 | 392 | } |
| 359 | | else if (y < ikbd_mouse_y0) |
| 393 | else if (y < ikbd.mouse_y) |
| 360 | 394 | { |
| 361 | | ikbd_mouse_y_phase = IKBD_MOUSE_PHASE_NEGATIVE; |
| 395 | ikbd.mouse_py = IKBD_MOUSE_PHASE_NEGATIVE; |
| 362 | 396 | } |
| 363 | 397 | |
| 364 | | data |= IKBD_MOUSE_XYB[ikbd_mouse_x_phase][ikbd_mouse_phase_counter]; // XB |
| 365 | | data |= IKBD_MOUSE_XYA[ikbd_mouse_x_phase][ikbd_mouse_phase_counter] << 1; // XA |
| 366 | | data |= IKBD_MOUSE_XYA[ikbd_mouse_y_phase][ikbd_mouse_phase_counter] << 2; // YA |
| 367 | | data |= IKBD_MOUSE_XYB[ikbd_mouse_y_phase][ikbd_mouse_phase_counter] << 3; // YB |
| 398 | data |= IKBD_MOUSE_XYB[ikbd.mouse_px][ikbd.mouse_pc]; // XB |
| 399 | data |= IKBD_MOUSE_XYA[ikbd.mouse_px][ikbd.mouse_pc] << 1; // XA |
| 400 | data |= IKBD_MOUSE_XYA[ikbd.mouse_py][ikbd.mouse_pc] << 2; // YA |
| 401 | data |= IKBD_MOUSE_XYB[ikbd.mouse_py][ikbd.mouse_pc] << 3; // YB |
| 368 | 402 | |
| 369 | | ikbd_mouse_phase_counter++; |
| 403 | ikbd.mouse_pc++; |
| 370 | 404 | |
| 371 | | if (ikbd_mouse_phase_counter == 4) |
| 405 | if (ikbd.mouse_pc == 4) |
| 372 | 406 | { |
| 373 | | ikbd_mouse_phase_counter = 0; |
| 407 | ikbd.mouse_pc = 0; |
| 374 | 408 | } |
| 375 | 409 | |
| 376 | | ikbd_mouse_x0 = x; |
| 377 | | ikbd_mouse_y0 = y; |
| 410 | ikbd.mouse_x = x; |
| 411 | ikbd.mouse_y = y; |
| 378 | 412 | |
| 379 | 413 | return data; |
| 380 | 414 | } |
| 381 | 415 | else |
| 382 | 416 | { |
| 383 | | return readinputportbytag("JOY0"); |
| 417 | return readinputportbytag_safe("IKBD_JOY0", 0xff); |
| 384 | 418 | } |
| 385 | 419 | } |
| 386 | 420 | |
| r856 | r857 | |
| 390 | 424 | |
| 391 | 425 | bit description |
| 392 | 426 | |
| 393 | | 0 JOY 0-1 or mouse XB or keyboard row input |
| 394 | | 1 JOY 0-2 or mouse XA or keyboard row input |
| 395 | | 2 JOY 0-3 or mouse YA or keyboard row input |
| 396 | | 3 JOY 0-4 or mouse YB or keyboard row input |
| 397 | | 4 JOY 1-1 or keyboard row input |
| 398 | | 5 JOY 1-2 or keyboard row input |
| 399 | | 6 JOY 1-3 or keyboard row input |
| 400 | | 7 JOY 1-4 or keyboard row input |
| 427 | 0 Keyboard row select |
| 428 | 1 Keyboard row select |
| 429 | 2 Keyboard row select |
| 430 | 3 Keyboard row select |
| 431 | 4 Keyboard row select |
| 432 | 5 Keyboard row select |
| 433 | 6 Keyboard row select |
| 434 | 7 Keyboard row select |
| 401 | 435 | |
| 402 | 436 | */ |
| 403 | 437 | |
| 404 | | if (~data & 0x01) ikbd_keylatch = readinputportbytag("P40"); |
| 405 | | if (~data & 0x02) ikbd_keylatch = readinputportbytag("P41"); |
| 406 | | if (~data & 0x04) ikbd_keylatch = readinputportbytag("P42"); |
| 407 | | if (~data & 0x08) ikbd_keylatch = readinputportbytag("P43"); |
| 408 | | if (~data & 0x10) ikbd_keylatch = readinputportbytag("P44"); |
| 409 | | if (~data & 0x20) ikbd_keylatch = readinputportbytag("P45"); |
| 410 | | if (~data & 0x40) ikbd_keylatch = readinputportbytag("P46"); |
| 411 | | if (~data & 0x80) ikbd_keylatch = readinputportbytag("P47"); |
| 438 | if (~data & 0x01) ikbd.keylatch = readinputportbytag("P40"); |
| 439 | if (~data & 0x02) ikbd.keylatch = readinputportbytag("P41"); |
| 440 | if (~data & 0x04) ikbd.keylatch = readinputportbytag("P42"); |
| 441 | if (~data & 0x08) ikbd.keylatch = readinputportbytag("P43"); |
| 442 | if (~data & 0x10) ikbd.keylatch = readinputportbytag("P44"); |
| 443 | if (~data & 0x20) ikbd.keylatch = readinputportbytag("P45"); |
| 444 | if (~data & 0x40) ikbd.keylatch = readinputportbytag("P46"); |
| 445 | if (~data & 0x80) ikbd.keylatch = readinputportbytag("P47"); |
| 412 | 446 | } |
| 413 | 447 | |
| 414 | 448 | /* Memory Maps */ |
| r856 | r857 | |
| 691 | 725 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad +") PORT_CODE(KEYCODE_PLUS_PAD) |
| 692 | 726 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 3") PORT_CODE(KEYCODE_3_PAD) |
| 693 | 727 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad Enter") PORT_CODE(KEYCODE_ENTER_PAD) |
| 728 | INPUT_PORTS_END |
| 694 | 729 | |
| 695 | | PORT_START_TAG("JOY0") |
| 730 | INPUT_PORTS_START( atarist ) |
| 731 | PORT_START_TAG("config") |
| 732 | PORT_CONFNAME( 0x01, 0x00, "Input Port 0 Device") |
| 733 | PORT_CONFSETTING( 0x00, "Mouse" ) |
| 734 | PORT_CONFSETTING( 0x01, DEF_STR( Joystick ) ) |
| 735 | PORT_CONFNAME( 0x80, 0x80, "Monitor") |
| 736 | PORT_CONFSETTING( 0x00, "Monochrome" ) |
| 737 | PORT_CONFSETTING( 0x80, "Color" ) |
| 738 | |
| 739 | PORT_INCLUDE( ikbd ) |
| 740 | |
| 741 | PORT_START_TAG("IKBD_JOY0") |
| 696 | 742 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_8WAY // XB |
| 697 | 743 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_8WAY // XA |
| 698 | 744 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_8WAY // YA |
| r856 | r857 | |
| 702 | 748 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_8WAY |
| 703 | 749 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_8WAY |
| 704 | 750 | |
| 705 | | PORT_START_TAG("JOY1") |
| 751 | PORT_START_TAG("IKBD_JOY1") |
| 706 | 752 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) |
| 707 | 753 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 708 | 754 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) |
| 709 | 755 | |
| 710 | | PORT_START_TAG("MOUSEX") |
| 756 | PORT_START_TAG("IKBD_MOUSEX") |
| 711 | 757 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_MINMAX(0, 255) PORT_PLAYER(1) |
| 712 | 758 | |
| 713 | | PORT_START_TAG("MOUSEY") |
| 759 | PORT_START_TAG("IKBD_MOUSEY") |
| 714 | 760 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_MINMAX(0, 255) PORT_PLAYER(1) |
| 715 | 761 | INPUT_PORTS_END |
| 716 | 762 | |
| 717 | | INPUT_PORTS_START( atarist ) |
| 763 | INPUT_PORTS_START( atariste ) |
| 718 | 764 | PORT_START_TAG("config") |
| 719 | 765 | PORT_CONFNAME( 0x01, 0x00, "Input Port 0 Device") |
| 720 | 766 | PORT_CONFSETTING( 0x00, "Mouse" ) |
| r856 | r857 | |
| 724 | 770 | PORT_CONFSETTING( 0x80, "Color" ) |
| 725 | 771 | |
| 726 | 772 | PORT_INCLUDE( ikbd ) |
| 727 | | INPUT_PORTS_END |
| 728 | 773 | |
| 729 | | INPUT_PORTS_START( atariste ) |
| 730 | | PORT_INCLUDE( atarist ) |
| 731 | | |
| 732 | 774 | PORT_START_TAG("JOY0E") |
| 733 | 775 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 734 | 776 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3) |
| r856 | r857 | |
| 824 | 866 | { |
| 825 | 867 | 500000, |
| 826 | 868 | 500000, |
| 827 | | &acia_ikbd_rx, |
| 828 | | &acia_ikbd_tx, |
| 869 | &ikbd.rx, |
| 870 | &ikbd.tx, |
| 829 | 871 | acia_interrupt |
| 830 | 872 | }; |
| 831 | 873 | |
| r856 | r857 | |
| 1007 | 1049 | MACHINE_DRIVER_END |
| 1008 | 1050 | |
| 1009 | 1051 | static MACHINE_DRIVER_START( atariste ) |
| 1010 | | MDRV_IMPORT_FROM(atarist) |
| 1011 | | |
| 1012 | | MDRV_CPU_MODIFY("main") |
| 1052 | // basic machine hardware |
| 1053 | MDRV_CPU_ADD_TAG("main", M68000, Y2/4) |
| 1013 | 1054 | MDRV_CPU_PROGRAM_MAP(ste_map, 0) |
| 1014 | 1055 | |
| 1056 | MDRV_CPU_ADD(HD63701, 1000000) // HD6301, really clocked at 4MHz but CPU core doesn't divide it properly |
| 1057 | MDRV_CPU_PROGRAM_MAP(ikbd_map, 0) |
| 1058 | MDRV_CPU_IO_MAP(ikbd_io_map, 0) |
| 1059 | |
| 1060 | MDRV_MACHINE_START(atariste) |
| 1061 | |
| 1062 | // video hardware |
| 1063 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) |
| 1064 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 1015 | 1065 | MDRV_PALETTE_LENGTH(512) |
| 1016 | | // stereo sound |
| 1066 | MDRV_VIDEO_START( atarist ) |
| 1067 | MDRV_VIDEO_UPDATE( atarist ) |
| 1017 | 1068 | |
| 1018 | | MDRV_MACHINE_START(atariste) |
| 1069 | MDRV_SCREEN_ADD("main", 0) |
| 1070 | MDRV_SCREEN_RAW_PARAMS(Y2/4, ATARIST_HTOT_PAL, ATARIST_HBEND_PAL, ATARIST_HBSTART_PAL, ATARIST_VTOT_PAL, ATARIST_VBEND_PAL, ATARIST_VBSTART_PAL) |
| 1071 | |
| 1072 | // sound hardware |
| 1073 | MDRV_SPEAKER_STANDARD_STEREO("left", "right") |
| 1074 | |
| 1075 | MDRV_SOUND_ADD(YM2149, Y2/16) |
| 1076 | MDRV_SOUND_CONFIG(ym2149_interface) |
| 1077 | MDRV_SOUND_ROUTE(0, "left", 0.50) |
| 1078 | MDRV_SOUND_ROUTE(0, "right", 0.50) |
| 1079 | /* |
| 1080 | MDRV_SOUND_ADD(CUSTOM, 0) // DAC |
| 1081 | MDRV_SOUND_ROUTE(0, "right", 0.50) |
| 1082 | MDRV_SOUND_ROUTE(1, "left", 0.50) |
| 1083 | */ |
| 1019 | 1084 | MACHINE_DRIVER_END |
| 1020 | 1085 | |
| 1021 | 1086 | static MACHINE_DRIVER_START( megaste ) |