src/mess/machine/mtx.c
| r0 | r1583 | |
| 1 | /*************************************************************************
|
| 2 | |
| 3 | machine/mtx.c
|
| 4 | |
| 5 | Memotech MTX 500, MTX 512 and RS 128
|
| 6 | |
| 7 | **************************************************************************/
|
| 8 | |
| 9 | |
| 10 | /* Core includes */
|
| 11 | #include "driver.h"
|
| 12 | #include "includes/mtx.h"
|
| 13 | |
| 14 | /* Components */
|
| 15 | #include "cpu/z80/z80.h"
|
| 16 | #include "machine/z80ctc.h"
|
| 17 | #include "machine/z80dart.h"
|
| 18 | #include "video/tms9928a.h"
|
| 19 | |
| 20 | /* Devices */
|
| 21 | #include "devices/printer.h"
|
| 22 | #include "devices/snapquik.h"
|
| 23 | |
| 24 | |
| 25 | #define MTX_PRT_BUSY 1
|
| 26 | #define MTX_PRT_NOERROR 2
|
| 27 | #define MTX_PRT_EMPTY 4
|
| 28 | #define MTX_PRT_SELECTED 8
|
| 29 | |
| 30 | |
| 31 | |
| 32 | /*************************************
|
| 33 | *
|
| 34 | * Global variables
|
| 35 | *
|
| 36 | *************************************/
|
| 37 | |
| 38 | static UINT8 key_sense;
|
| 39 | |
| 40 | static UINT8 mtx_relcpmh;
|
| 41 | static UINT8 mtx_rampage;
|
| 42 | static UINT8 mtx_rompage;
|
| 43 | |
| 44 | static UINT8 *mtx_null_mem = NULL;
|
| 45 | static UINT8 *mtx_zero_mem = NULL;
|
| 46 | |
| 47 | static char mtx_prt_strobe = 0;
|
| 48 | static char mtx_prt_data = 0;
|
| 49 | |
| 50 | static UINT8 *mtx_tape_buf = NULL;
|
| 51 | static int mtx_tape_index = 0;
|
| 52 | static char *mtx_tape_filename = NULL;
|
| 53 | |
| 54 | |
| 55 | |
| 56 | /*************************************
|
| 57 | *
|
| 58 | * TMS9929A video chip
|
| 59 | *
|
| 60 | *************************************/
|
| 61 | |
| 62 | static void mtx_tms9929a_interrupt(int data)
|
| 63 | {
|
| 64 | // logerror ("tms9929a_interrupt: %d\n", data);
|
| 65 | z80ctc_0_trg0_w(0, data ? 0 : 1);
|
| 66 | }
|
| 67 | |
| 68 | static const TMS9928a_interface tms9928a_interface =
|
| 69 | {
|
| 70 | TMS9929A,
|
| 71 | 0x4000,
|
| 72 | 0, 0,
|
| 73 | mtx_tms9929a_interrupt
|
| 74 | };
|
| 75 | |
| 76 | INTERRUPT_GEN( mtx_interrupt )
|
| 77 | {
|
| 78 | TMS9928A_interrupt();
|
| 79 | }
|
| 80 | |
| 81 | |
| 82 | |
| 83 | /*************************************
|
| 84 | *
|
| 85 | * Snapshots
|
| 86 | *
|
| 87 | *************************************/
|
| 88 | |
| 89 | SNAPSHOT_LOAD( mtx )
|
| 90 | {
|
| 91 | UINT8 header[4];
|
| 92 | |
| 93 | /* get the header */
|
| 94 | image_fread(image, &header, sizeof(header));
|
| 95 | |
| 96 | return INIT_FAIL;
|
| 97 | }
|
| 98 | |
| 99 | |
| 100 | |
| 101 | /*************************************
|
| 102 | *
|
| 103 | * Cassette
|
| 104 | *
|
| 105 | *************************************/
|
| 106 | |
| 107 | READ8_HANDLER( mtx_cst_r )
|
| 108 | {
|
| 109 | return 0xff;
|
| 110 | }
|
| 111 | |
| 112 | WRITE8_HANDLER( mtx_cst_w )
|
| 113 | {
|
| 114 | }
|
| 115 | |
| 116 | |
| 117 | |
| 118 | /*************************************
|
| 119 | *
|
| 120 | * Printer
|
| 121 | *
|
| 122 | *************************************/
|
| 123 | |
| 124 | static mess_image *mtx_printer_image(void)
|
| 125 | {
|
| 126 | return image_from_devtype_and_index(IO_PRINTER, 0);
|
| 127 | }
|
| 128 | |
| 129 | READ8_HANDLER( mtx_strobe_r )
|
| 130 | {
|
| 131 | if (mtx_prt_strobe == 0)
|
| 132 | printer_output (mtx_printer_image (), mtx_prt_data);
|
| 133 | |
| 134 | mtx_prt_strobe = 1;
|
| 135 | |
| 136 | return 0;
|
| 137 | }
|
| 138 | |
| 139 | |
| 140 | READ8_HANDLER( mtx_prt_r )
|
| 141 | {
|
| 142 | mtx_prt_strobe = 0;
|
| 143 | |
| 144 | return MTX_PRT_NOERROR | (printer_status (mtx_printer_image (), 0)
|
| 145 | ? MTX_PRT_SELECTED : 0);
|
| 146 | }
|
| 147 | |
| 148 | WRITE8_HANDLER( mtx_prt_w )
|
| 149 | {
|
| 150 | mtx_prt_data = data;
|
| 151 | }
|
| 152 | |
| 153 | |
| 154 | |
| 155 | /*************************************
|
| 156 | *
|
| 157 | * Keyboard
|
| 158 | *
|
| 159 | *************************************/
|
| 160 | |
| 161 | WRITE8_HANDLER( mtx_sense_w )
|
| 162 | {
|
| 163 | key_sense = data;
|
| 164 | }
|
| 165 | |
| 166 | READ8_HANDLER( mtx_key_lo_r )
|
| 167 | {
|
| 168 | UINT8 data = 0xff;
|
| 169 | |
| 170 | if (!(key_sense & 0x01)) data &= readinputportbytag("keyboard_low_0");
|
| 171 | if (!(key_sense & 0x02)) data &= readinputportbytag("keyboard_low_1");
|
| 172 | if (!(key_sense & 0x04)) data &= readinputportbytag("keyboard_low_2");
|
| 173 | if (!(key_sense & 0x08)) data &= readinputportbytag("keyboard_low_3");
|
| 174 | if (!(key_sense & 0x10)) data &= readinputportbytag("keyboard_low_4");
|
| 175 | if (!(key_sense & 0x20)) data &= readinputportbytag("keyboard_low_5");
|
| 176 | if (!(key_sense & 0x40)) data &= readinputportbytag("keyboard_low_6");
|
| 177 | if (!(key_sense & 0x80)) data &= readinputportbytag("keyboard_low_7");
|
| 178 | |
| 179 | return data;
|
| 180 | }
|
| 181 | |
| 182 | READ8_HANDLER( mtx_key_hi_r )
|
| 183 | {
|
| 184 | UINT8 data = readinputportbytag("country_code");
|
| 185 | |
| 186 | if (!(key_sense & 0x01)) data &= readinputportbytag("keyboard_high_0");
|
| 187 | if (!(key_sense & 0x02)) data &= readinputportbytag("keyboard_high_1");
|
| 188 | if (!(key_sense & 0x04)) data &= readinputportbytag("keyboard_high_2");
|
| 189 | if (!(key_sense & 0x08)) data &= readinputportbytag("keyboard_high_3");
|
| 190 | if (!(key_sense & 0x10)) data &= readinputportbytag("keyboard_high_4");
|
| 191 | if (!(key_sense & 0x20)) data &= readinputportbytag("keyboard_high_5");
|
| 192 | if (!(key_sense & 0x40)) data &= readinputportbytag("keyboard_high_6");
|
| 193 | if (!(key_sense & 0x80)) data &= readinputportbytag("keyboard_high_7");
|
| 194 | |
| 195 | return data;
|
| 196 | }
|
| 197 | |
| 198 | |
| 199 | |
| 200 | /*************************************
|
| 201 | *
|
| 202 | * Z80 CTC
|
| 203 | *
|
| 204 | *************************************/
|
| 205 | |
| 206 | static void mtx_ctc_interrupt(int state)
|
| 207 | {
|
| 208 | // logerror("mtx_ctc_interrupt: %02x\n", state);
|
| 209 | cpunum_set_input_line(0, 0, state);
|
| 210 | }
|
| 211 | |
| 212 | READ8_HANDLER( mtx_ctc_r )
|
| 213 | {
|
| 214 | return z80ctc_0_r(offset);
|
| 215 | }
|
| 216 | |
| 217 | WRITE8_HANDLER( mtx_ctc_w )
|
| 218 | {
|
| 219 | // logerror("mtx_ctc_w: %02x\n", data);
|
| 220 | if (offset < 3)
|
| 221 | z80ctc_0_w(offset,data);
|
| 222 | }
|
| 223 | |
| 224 | static z80ctc_interface mtx_ctc_intf =
|
| 225 | {
|
| 226 | MTX_SYSTEM_CLOCK,
|
| 227 | 0,
|
| 228 | mtx_ctc_interrupt,
|
| 229 | 0,
|
| 230 | 0,
|
| 231 | 0
|
| 232 | };
|
| 233 | |
| 234 | |
| 235 | |
| 236 | /*************************************
|
| 237 | *
|
| 238 | * Z80 Dart
|
| 239 | *
|
| 240 | *************************************/
|
| 241 | |
| 242 | READ8_HANDLER( mtx_dart_data_r )
|
| 243 | {
|
| 244 | return z80dart_d_r(0, offset);
|
| 245 | }
|
| 246 | |
| 247 | READ8_HANDLER( mtx_dart_control_r )
|
| 248 | {
|
| 249 | return z80dart_c_r(0, offset);
|
| 250 | }
|
| 251 | |
| 252 | WRITE8_HANDLER( mtx_dart_data_w )
|
| 253 | {
|
| 254 | z80dart_d_w(0, offset, data);
|
| 255 | }
|
| 256 | |
| 257 | WRITE8_HANDLER( mtx_dart_control_w )
|
| 258 | {
|
| 259 | z80dart_c_w(0, offset, data);
|
| 260 | }
|
| 261 | |
| 262 | static const z80dart_interface mtx_dart_intf =
|
| 263 | {
|
| 264 | MTX_SYSTEM_CLOCK,
|
| 265 | NULL,
|
| 266 | NULL,
|
| 267 | NULL,
|
| 268 | NULL,
|
| 269 | NULL,
|
| 270 | NULL
|
| 271 | };
|
| 272 | |
| 273 | |
| 274 | |
| 275 | /*************************************
|
| 276 | *
|
| 277 | * Bank switching
|
| 278 | *
|
| 279 | *************************************/
|
| 280 | |
| 281 | static void mtx_set_bank_offsets (unsigned int bank1, unsigned int bank2,
|
| 282 | unsigned int bank3, unsigned int bank4,
|
| 283 | unsigned int bank5, unsigned int bank6,
|
| 284 | unsigned int bank7, unsigned int bank8)
|
| 285 | {
|
| 286 | UINT8 *romimage;
|
| 287 | |
| 288 | // logerror ("CPM %d RAM %x ROM %x\n", mtx_relcpmh,
|
| 289 | // mtx_rampage, mtx_rompage);
|
| 290 | // logerror ("map: [0000] %04x [2000] %04x [4000] %04x [6000] %04x\n",
|
| 291 | // bank1, bank2, bank3, bank4);
|
| 292 | // logerror (" [8000] %04x [a000] %04x [c000] %04x [e000] %04x\n",
|
| 293 | // bank5, bank6, bank7, bank8);
|
| 294 | |
| 295 | romimage = memory_region(REGION_CPU1);
|
| 296 | |
| 297 | if (mtx_relcpmh)
|
| 298 | {
|
| 299 | memory_set_bankptr (1, mess_ram + bank1);
|
| 300 | // bank 9 is handled by the mtx_trap_write function
|
| 301 | memory_set_bankptr (2, mess_ram + bank2);
|
| 302 | memory_set_bankptr (10, mess_ram + bank2);
|
| 303 | }
|
| 304 | else
|
| 305 | {
|
| 306 | memory_set_bankptr (1, romimage + bank1);
|
| 307 | // bank is 9 handled by the mtx_trap_write function
|
| 308 | memory_set_bankptr (2, romimage + bank2);
|
| 309 | memory_set_bankptr (10, mtx_null_mem);
|
| 310 | }
|
| 311 | |
| 312 | if (bank3 < mess_ram_size)
|
| 313 | {
|
| 314 | memory_set_bankptr (3, mess_ram + bank3);
|
| 315 | memory_set_bankptr (11, mess_ram + bank3);
|
| 316 | }
|
| 317 | else
|
| 318 | {
|
| 319 | memory_set_bankptr (3, mtx_null_mem);
|
| 320 | memory_set_bankptr (11, mtx_zero_mem);
|
| 321 | }
|
| 322 | |
| 323 | if (bank4 < mess_ram_size)
|
| 324 | {
|
| 325 | memory_set_bankptr (4, mess_ram + bank4);
|
| 326 | memory_set_bankptr (12, mess_ram + bank4);
|
| 327 | }
|
| 328 | else
|
| 329 | {
|
| 330 | memory_set_bankptr (4, mtx_null_mem);
|
| 331 | memory_set_bankptr (12, mtx_zero_mem);
|
| 332 | }
|
| 333 | |
| 334 | if (bank5 < mess_ram_size)
|
| 335 | {
|
| 336 | memory_set_bankptr (5, mess_ram + bank5);
|
| 337 | memory_set_bankptr (13, mess_ram + bank5);
|
| 338 | }
|
| 339 | else
|
| 340 | {
|
| 341 | memory_set_bankptr (5, mtx_null_mem);
|
| 342 | memory_set_bankptr (13, mtx_zero_mem);
|
| 343 | }
|
| 344 | |
| 345 | if (bank6 < mess_ram_size)
|
| 346 | {
|
| 347 | memory_set_bankptr (6, mess_ram + bank6);
|
| 348 | memory_set_bankptr (14, mess_ram + bank6);
|
| 349 | }
|
| 350 | else
|
| 351 | {
|
| 352 | memory_set_bankptr (6, mtx_null_mem);
|
| 353 | memory_set_bankptr (14, mtx_zero_mem);
|
| 354 | }
|
| 355 | |
| 356 | memory_set_bankptr (7, mess_ram + bank7);
|
| 357 | memory_set_bankptr (15, mess_ram + bank7);
|
| 358 | |
| 359 | memory_set_bankptr (8, mess_ram + bank8);
|
| 360 | memory_set_bankptr (16, mess_ram + bank8);
|
| 361 | }
|
| 362 | |
| 363 | WRITE8_HANDLER( mtx_bankswitch_w )
|
| 364 | {
|
| 365 | unsigned int bank1, bank2, bank3, bank4;
|
| 366 | unsigned int bank5, bank6, bank7, bank8;
|
| 367 | |
| 368 | mtx_relcpmh = (data & 0x80) >> 7;
|
| 369 | mtx_rampage = (data & 0x0f);
|
| 370 | mtx_rompage = (data & 0x70) >> 4;
|
| 371 | |
| 372 | if (mtx_relcpmh)
|
| 373 | {
|
| 374 | bank1 = 0xe000 + mtx_rampage * 0xc000;
|
| 375 | bank2 = 0xc000 + mtx_rampage * 0xc000;
|
| 376 | bank3 = 0xa000 + mtx_rampage * 0xc000;
|
| 377 | bank4 = 0x8000 + mtx_rampage * 0xc000;
|
| 378 | bank5 = 0x6000 + mtx_rampage * 0xc000;
|
| 379 | bank6 = 0x4000 + mtx_rampage * 0xc000;
|
| 380 | }
|
| 381 | else
|
| 382 | {
|
| 383 | bank1 = 0x0;
|
| 384 | bank2 = 0x2000 + mtx_rompage * 0x2000;
|
| 385 | bank3 = 0xa000 + mtx_rampage * 0x8000;
|
| 386 | bank4 = 0x8000 + mtx_rampage * 0x8000;
|
| 387 | bank5 = 0x6000 + mtx_rampage * 0x8000;
|
| 388 | bank6 = 0x4000 + mtx_rampage * 0x8000;
|
| 389 | }
|
| 390 | |
| 391 | bank7 = 0x2000;
|
| 392 | bank8 = 0x0;
|
| 393 | |
| 394 | mtx_set_bank_offsets (bank1, bank2, bank3, bank4,
|
| 395 | bank5, bank6, bank7, bank8);
|
| 396 | }
|
| 397 | |
| 398 | static void mtx_virt_to_phys (const char * what, int vaddress,
|
| 399 | int * ramspace, int * paddress)
|
| 400 | {
|
| 401 | int offset = vaddress & 0x1fff;
|
| 402 | int vbase = vaddress & ~0x1fff;
|
| 403 | int pbase = 0x20000;
|
| 404 | |
| 405 | *ramspace = mtx_relcpmh || vaddress >= 0x4000;
|
| 406 | |
| 407 | if (0xc000 <= vaddress && vaddress < 0x10000)
|
| 408 | pbase = 0xe000 - vbase;
|
| 409 | else if (mtx_relcpmh)
|
| 410 | pbase = 0xe000 - vbase + mtx_rampage * 0xc000;
|
| 411 | else if (0 <= vaddress && vaddress < 0x2000)
|
| 412 | pbase = 0;
|
| 413 | else if (0x2000 <= vaddress && vaddress < 0x4000)
|
| 414 | pbase = 0x2000 + mtx_rompage * 0x2000;
|
| 415 | else if (0x4000 <= vaddress && vaddress < 0xc000)
|
| 416 | pbase = (0xe000 - vbase) + mtx_rampage * 0x8000;
|
| 417 | |
| 418 | *paddress = pbase + offset;
|
| 419 | |
| 420 | // logerror ("%s (%d,%d,%d,%04x) -> (%d,%06x)\n", what,
|
| 421 | // mtx_relcpmh, mtx_rompage, mtx_rampage, vaddress,
|
| 422 | // *ramspace, *paddress);
|
| 423 | }
|
| 424 | |
| 425 | |
| 426 | |
| 427 | /*************************************
|
| 428 | *
|
| 429 | * Tape hack
|
| 430 | *
|
| 431 | *************************************/
|
| 432 | |
| 433 | static UINT8 mtx_peek(int vaddress)
|
| 434 | {
|
| 435 | UINT8 * romimage;
|
| 436 | int ramspace;
|
| 437 | int paddress;
|
| 438 | |
| 439 | romimage = memory_region(REGION_CPU1);
|
| 440 | mtx_virt_to_phys("peek", vaddress, &ramspace, &paddress);
|
| 441 | |
| 442 | if (paddress > mess_ram_size) {
|
| 443 | logerror("peek into non-existing memory\n");
|
| 444 | return 0;
|
| 445 | }
|
| 446 | |
| 447 | if (ramspace)
|
| 448 | return mess_ram[paddress];
|
| 449 | else
|
| 450 | return romimage[paddress];
|
| 451 | }
|
| 452 | |
| 453 | static void mtx_poke(int vaddress, UINT8 data)
|
| 454 | {
|
| 455 | int ramspace;
|
| 456 | int paddress;
|
| 457 | |
| 458 | mtx_virt_to_phys ("poke", vaddress, &ramspace, &paddress);
|
| 459 | if (!ramspace)
|
| 460 | logerror ("poke into the ROM address space\n");
|
| 461 | else if (paddress >= mess_ram_size)
|
| 462 | logerror ("poke into non-existing RAM\n");
|
| 463 | else
|
| 464 | mess_ram[paddress] = data;
|
| 465 | }
|
| 466 | |
| 467 | /*
|
| 468 | * A filename is at most 14 characters long, always ending with a space.
|
| 469 | * The save file can be at most 65536 long.
|
| 470 | * Note: the empty string is saved as a single space.
|
| 471 | */
|
| 472 | static void mtx_save_hack(int start, int length)
|
| 473 | {
|
| 474 | mame_file * tape_file;
|
| 475 | file_error filerr;
|
| 476 | int bytes_saved;
|
| 477 | int i;
|
| 478 | |
| 479 | assert(length <= 32768);
|
| 480 | |
| 481 | // logerror("mtx_save_hack: start=%#x length=%#x (%d) index=%#x (%d)\n",
|
| 482 | // start, length, length, mtx_save_index, mtx_save_index);
|
| 483 | |
| 484 | if ((start > 0xc000) && (length == 20)) /* Save the header segment */
|
| 485 | {
|
| 486 | for (i = 0; i < 18; i++)
|
| 487 | mtx_tape_buf[i] = mtx_peek(start + i);
|
| 488 | length = 18;
|
| 489 | |
| 490 | memcpy(mtx_tape_filename, mtx_tape_buf + 1, 15);
|
| 491 | for (i = 14; i > 0 && mtx_tape_filename[i] == 0x20; i--)
|
| 492 | ;
|
| 493 | mtx_tape_filename[i + 1] = '\0';
|
| 494 | mtx_tape_index = 0;
|
| 495 | |
| 496 | filerr = mame_fopen(SEARCHPATH_IMAGE, mtx_tape_filename,
|
| 497 | OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, &tape_file);
|
| 498 | }
|
| 499 | else /* Save system variable, body, or variable store segment */
|
| 500 | {
|
| 501 | for (i = 0; i < length; i++)
|
| 502 | mtx_tape_buf[i] = mtx_peek(start + i);
|
| 503 | |
| 504 | filerr = mame_fopen(SEARCHPATH_IMAGE, mtx_tape_filename,
|
| 505 | OPEN_FLAG_WRITE, &tape_file);
|
| 506 | }
|
| 507 | |
| 508 | if (filerr == FILERR_NONE)
|
| 509 | {
|
| 510 | mame_fseek(tape_file, mtx_tape_index, SEEK_SET);
|
| 511 | bytes_saved = mame_fwrite(tape_file, mtx_tape_buf, length);
|
| 512 | logerror("saved %d bytes from %d:%04x into '%s' at %d\n", bytes_saved,
|
| 513 | mtx_rampage, start, mtx_tape_filename, mtx_tape_index);
|
| 514 | if (length > bytes_saved)
|
| 515 | logerror("wrote too few bytes from '%s'\n", mtx_tape_filename);
|
| 516 | |
| 517 | mame_fclose(tape_file);
|
| 518 | mtx_tape_index += length;
|
| 519 | }
|
| 520 | else
|
| 521 | logerror("cannot open '%s' for saving\n", mtx_tape_filename);
|
| 522 | }
|
| 523 | |
| 524 | /*
|
| 525 | * A filename is at most 14 characters long, ending with a space.
|
| 526 | * At most 65536 bytes are loaded from the file.
|
| 527 | * Note: the empty string is loaded as a single space (ugly),
|
| 528 | * not the 'next' file.
|
| 529 | */
|
| 530 | static void mtx_load_hack(int start, int length)
|
| 531 | {
|
| 532 | mame_file * tape_file;
|
| 533 | file_error filerr;
|
| 534 | int bytes_loaded;
|
| 535 | int i;
|
| 536 | |
| 537 | assert(length <= 32768);
|
| 538 | |
| 539 | // logerror("mtx_load_hack: start=%#x length=%#x (%d)\n", start, length, length);
|
| 540 | |
| 541 | if ((start > 0xc000) && (length == 18))
|
| 542 | {
|
| 543 | for (i = 0; i < 15; i++)
|
| 544 | mtx_tape_filename[i] = mtx_peek(start - 0xf + i);
|
| 545 | |
| 546 | for (i = 14; i > 0 && mtx_tape_filename[i] == 0x20; i--)
|
| 547 | ;
|
| 548 | |
| 549 | mtx_tape_filename[i+1] = '\0';
|
| 550 | mtx_tape_index = 0;
|
| 551 | }
|
| 552 | |
| 553 | filerr = mame_fopen(SEARCHPATH_IMAGE, mtx_tape_filename, OPEN_FLAG_READ,
|
| 554 | &tape_file);
|
| 555 | if (filerr == FILERR_NONE)
|
| 556 | {
|
| 557 | mame_fseek(tape_file, mtx_tape_index, SEEK_SET);
|
| 558 | bytes_loaded = mame_fread(tape_file, mtx_tape_buf, length);
|
| 559 | logerror("loaded %d bytes from '%s' at %d into %d:%04x\n", bytes_loaded,
|
| 560 | mtx_tape_filename, mtx_tape_index, mtx_rampage, start);
|
| 561 | if (length > bytes_loaded)
|
| 562 | logerror("read too few bytes from '%s'\n", mtx_tape_filename);
|
| 563 | |
| 564 | for (i = 0; i < length; i++)
|
| 565 | mtx_poke(start + i, mtx_tape_buf[i]);
|
| 566 | |
| 567 | mame_fclose(tape_file);
|
| 568 | mtx_tape_index += length;
|
| 569 | }
|
| 570 | else
|
| 571 | logerror("cannot open '%s' for loading\n", mtx_tape_filename);
|
| 572 | }
|
| 573 | |
| 574 | static void mtx_verify_hack(int start, int length)
|
| 575 | {
|
| 576 | // logerror("mtx_verify_hack: start=0x%x, length=0x%x (%d) not implemented\n", start, length, length);
|
| 577 | }
|
| 578 | |
| 579 | WRITE8_HANDLER( mtx_trap_write )
|
| 580 | {
|
| 581 | int pc;
|
| 582 | int start;
|
| 583 | int length;
|
| 584 | |
| 585 | if (mtx_relcpmh)
|
| 586 | {
|
| 587 | mtx_poke(offset, data);
|
| 588 | return;
|
| 589 | }
|
| 590 | |
| 591 | pc = activecpu_get_reg(Z80_PC);
|
| 592 | if((offset == 0x0aae) && (pc == 0x0ab1))
|
| 593 | {
|
| 594 | start = activecpu_get_reg(Z80_HL);
|
| 595 | length = activecpu_get_reg(Z80_DE);
|
| 596 | |
| 597 | // logerror("PC %04x\nStart %04x, Length %04x, 0xFD67 %02x, 0xFD68 %02x index 0x%04x\n", pc, start, length, mess_ram[0xfd67], mess_ram[0xfd68], mtx_tape_size);
|
| 598 | |
| 599 | if(mtx_peek(0xfd68) == 0)
|
| 600 | mtx_save_hack(start, length);
|
| 601 | else if(mtx_peek(0xfd67) == 0)
|
| 602 | mtx_load_hack(start, length);
|
| 603 | else
|
| 604 | mtx_verify_hack(start, length);
|
| 605 | }
|
| 606 | }
|
| 607 | |
| 608 | |
| 609 | |
| 610 | /*************************************
|
| 611 | *
|
| 612 | * Machine initialization
|
| 613 | *
|
| 614 | *************************************/
|
| 615 | |
| 616 | MACHINE_START( mtx512 )
|
| 617 | {
|
| 618 | UINT8 * romimage;
|
| 619 | |
| 620 | TMS9928A_configure(&tms9928a_interface);
|
| 621 | |
| 622 | mtx_null_mem = (UINT8 *) auto_malloc (16384);
|
| 623 | mtx_zero_mem = (UINT8 *) auto_malloc (16384);
|
| 624 | memset (mtx_zero_mem, 0, 16384);
|
| 625 | |
| 626 | mtx_tape_buf = auto_malloc (32768);
|
| 627 | mtx_tape_index = 0;
|
| 628 | mtx_tape_filename = auto_malloc (16);
|
| 629 | mtx_tape_filename[0] = 0;
|
| 630 | |
| 631 | z80ctc_init(0, &mtx_ctc_intf);
|
| 632 | |
| 633 | // Patch the Rom (Sneaky........ Who needs to trap opcodes?)
|
| 634 | romimage = memory_region(REGION_CPU1);
|
| 635 | romimage[0x0aae] = 0x32; // ld ($0aae),a
|
| 636 | romimage[0x0aaf] = 0xae;
|
| 637 | romimage[0x0ab0] = 0x0a;
|
| 638 | romimage[0x0ab1] = 0xc9; // ret
|
| 639 | |
| 640 | // Set up the starting memory configuration
|
| 641 | mtx_relcpmh = 0;
|
| 642 | mtx_rampage = 0;
|
| 643 | mtx_rompage = 0;
|
| 644 | mtx_set_bank_offsets (0, 0x2000, 0xa0000, 0x8000,
|
| 645 | 0x6000, 0x4000, 0x2000, 0);
|
| 646 | }
|
| 647 | |
| 648 | DRIVER_INIT( rs128 )
|
| 649 | {
|
| 650 | z80dart_init(0, &mtx_dart_intf);
|
| 651 | |
| 652 | /* install handlers for dart interface */
|
| 653 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_IO, 0x0c, 0x0d, 0, 0, mtx_dart_data_r, mtx_dart_data_w);
|
| 654 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_IO, 0x0e, 0x0f, 0, 0, mtx_dart_control_r, mtx_dart_control_w);
|
| 655 | }
|
| 656 | |
| 657 | MACHINE_RESET( rs128 )
|
| 658 | {
|
| 659 | z80dart_reset(0);
|
| 660 | }
|
src/mess/drivers/mtx.c
| r1582 | r1583 | |
| 1 | | /* |
| 2 | | ** mtx.c : driver for Memotech MTX512 |
| 3 | | ** |
| 4 | | ** The memory address space of the MTX512 is divided into 8 banks, |
| 5 | | ** with a size of 8KB each. These banks are mapped differently based |
| 6 | | ** upon the memory model, selected ROM and RAM page, and the amount |
| 7 | | ** of available RAM memory. There are two memory models: a ROM-based |
| 8 | | ** model and a CPM model. The memory model, ROM, and RAM page are |
| 9 | | ** selected at IO port 0 (i.e., with out (0),a) |
| 10 | | ** |
| 11 | | ** In the ROM-based model, bank 1 en bank 2 map to ROM images. Bank 1 |
| 12 | | ** maps to the OSROM image; bank2 maps to either the BASICROM image |
| 13 | | ** or the ASSEMROM image, depending on the selected ROM page. The |
| 14 | | ** available RAM is allocated to the banks from top to bottom. Bank 8 |
| 15 | | ** and bank 7, always start at offset 0x0 and 0x2000, respectively. |
| 16 | | ** Bank 6, 5, 4, and 3 are mapped depending on the selected RAM page |
| 17 | | ** and the available memory. |
| 18 | | ** |
| 19 | | ** In the CPM model, all banks map to RAM memory. The available RAM |
| 20 | | ** is (again) allocated from top to bottom. Bank 8 and bank 7, always |
| 21 | | ** start at offset 0x0 and 0x2000, respectively. Bank 6, 5, 4, 3, 2, |
| 22 | | ** and 1 are mapped depending on the read-only memory register and |
| 23 | | ** the avaiable memory. |
| 24 | | */ |
| 1 | /************************************************************************* |
| 25 | 2 | |
| 26 | | #include "driver.h" |
| 27 | | #include "cpu/z80/z80.h" |
| 28 | | #include "cpu/z80/z80daisy.h" |
| 29 | | #include "machine/z80ctc.h" |
| 30 | | #include "machine/z80pio.h" |
| 31 | | #include "machine/z80sio.h" |
| 32 | | #include "video/tms9928a.h" |
| 33 | | #include "sound/sn76496.h" |
| 34 | | #include "devices/cartslot.h" |
| 35 | | #include "devices/printer.h" |
| 3 | driver/mtx.c |
| 36 | 4 | |
| 5 | Memotech MTX 500, MTX 512 and RS 128 |
| 37 | 6 | |
| 38 | | #define MTX_SYSTEM_CLOCK 4000000 |
| 39 | 7 | |
| 40 | | #define MTX_PRT_BUSY 1 |
| 41 | | #define MTX_PRT_NOERROR 2 |
| 42 | | #define MTX_PRT_EMPTY 4 |
| 43 | | #define MTX_PRT_SELECTED 8 |
| 8 | The memory address space of the MTX512 is divided into 8 banks, |
| 9 | with a size of 8KB each. These banks are mapped differently based |
| 10 | upon the memory model, selected ROM and RAM page, and the amount |
| 11 | of available RAM memory. There are two memory models: a ROM-based |
| 12 | model and a CPM model. The memory model, ROM, and RAM page are |
| 13 | selected at IO port 0 (i.e., with out (0),a) |
| 44 | 14 | |
| 15 | 0x0000 - 0x1fff OSROM |
| 16 | 0x2000 - 0x3fff Paged: Assembler ROM, Basic ROM or RAM |
| 17 | 0x4000 - 0xbfff Paged: RAM |
| 18 | 0xc000 - 0xffff RAM |
| 45 | 19 | |
| 46 | | static unsigned char key_sense; |
| 20 | In the CPM model, all banks map to RAM memory. The available RAM |
| 21 | is (again) allocated from top to bottom. Bank 8 and bank 7, always |
| 22 | start at offset 0x0 and 0x2000, respectively. Bank 6, 5, 4, 3, 2, |
| 23 | and 1 are mapped depending on the read-only memory register and |
| 24 | the available memory. |
| 47 | 25 | |
| 48 | | static unsigned char mtx_relcpmh; |
| 49 | | static unsigned char mtx_rampage; |
| 50 | | static unsigned char mtx_rompage; |
| 51 | 26 | |
| 52 | | static unsigned char * mtx_null_mem = NULL; |
| 53 | | static unsigned char * mtx_zero_mem = NULL; |
| 27 | TODO: - Get rid of the tape hacks |
| 28 | - Finish RS232 support |
| 29 | - Floppy disk emulation |
| 30 | - Hard disk emulation |
| 31 | - "Silicon" disk emulation |
| 32 | - Multi Effect Video Wall emulation (maybe) |
| 54 | 33 | |
| 55 | | static char mtx_prt_strobe = 0; |
| 56 | | static char mtx_prt_data = 0; |
| 34 | **************************************************************************/ |
| 57 | 35 | |
| 58 | | static unsigned char * mtx_tape_buf = NULL; |
| 59 | | static int mtx_tape_index = 0; |
| 60 | | static char * mtx_tape_filename = NULL; |
| 61 | 36 | |
| 37 | /* Core includes */ |
| 38 | #include "driver.h" |
| 39 | #include "includes/mtx.h" |
| 62 | 40 | |
| 63 | | static WRITE8_HANDLER ( mtx_cst_w ) |
| 64 | | { |
| 65 | | } |
| 41 | /* Components */ |
| 42 | #include "cpu/z80/z80.h" |
| 43 | #include "cpu/z80/z80daisy.h" |
| 44 | #include "machine/z80ctc.h" |
| 45 | #include "video/tms9928a.h" |
| 46 | #include "sound/sn76496.h" |
| 66 | 47 | |
| 67 | | static READ8_HANDLER ( mtx_psg_r ) |
| 68 | | { |
| 69 | | return 0xff; |
| 70 | | } |
| 48 | /* Devices */ |
| 49 | #include "devices/printer.h" |
| 50 | #include "devices/snapquik.h" |
| 71 | 51 | |
| 72 | | static WRITE8_HANDLER ( mtx_psg_w ) |
| 73 | | { |
| 74 | | SN76496_0_w(offset,data); |
| 75 | | } |
| 76 | 52 | |
| 77 | | static mess_image * mtx_printer_image (void) |
| 78 | | { |
| 79 | | return image_from_devtype_and_index (IO_PRINTER, 0); |
| 80 | | } |
| 81 | 53 | |
| 82 | | static READ8_HANDLER ( mtx_strobe_r ) |
| 83 | | { |
| 84 | | if (mtx_prt_strobe == 0) |
| 85 | | printer_output (mtx_printer_image (), mtx_prt_data); |
| 54 | /************************************* |
| 55 | * |
| 56 | * Memory maps |
| 57 | * |
| 58 | *************************************/ |
| 86 | 59 | |
| 87 | | mtx_prt_strobe = 1; |
| 60 | static ADDRESS_MAP_START( mtx_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 61 | AM_RANGE(0x0000, 0x1fff) AM_READWRITE(MRA8_BANK1, mtx_trap_write) |
| 62 | AM_RANGE(0x2000, 0x3fff) AM_READWRITE(MRA8_BANK2, MWA8_BANK10) |
| 63 | AM_RANGE(0x4000, 0x5fff) AM_READWRITE(MRA8_BANK3, MWA8_BANK11) |
| 64 | AM_RANGE(0x6000, 0x7fff) AM_READWRITE(MRA8_BANK4, MWA8_BANK12) |
| 65 | AM_RANGE(0x8000, 0x9fff) AM_READWRITE(MRA8_BANK5, MWA8_BANK13) |
| 66 | AM_RANGE(0xa000, 0xbfff) AM_READWRITE(MRA8_BANK6, MWA8_BANK14) |
| 67 | AM_RANGE(0xc000, 0xdfff) AM_READWRITE(MRA8_BANK7, MWA8_BANK15) |
| 68 | AM_RANGE(0xe000, 0xffff) AM_READWRITE(MRA8_BANK8, MWA8_BANK16) |
| 69 | ADDRESS_MAP_END |
| 88 | 70 | |
| 89 | | return 0; |
| 90 | | } |
| 91 | 71 | |
| 92 | | static READ8_HANDLER ( mtx_prt_r ) |
| 93 | | { |
| 94 | | mtx_prt_strobe = 0; |
| 72 | static ADDRESS_MAP_START( mtx_io, ADDRESS_SPACE_IO, 8 ) |
| 73 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 74 | AM_RANGE(0x00, 0x00) AM_READWRITE(mtx_strobe_r, mtx_bankswitch_w) |
| 75 | AM_RANGE(0x01, 0x01) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w) |
| 76 | AM_RANGE(0x02, 0x02) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 77 | AM_RANGE(0x03, 0x03) AM_READWRITE(mtx_cst_r, mtx_cst_w) |
| 78 | AM_RANGE(0x04, 0x04) AM_READWRITE(mtx_prt_r, mtx_prt_w) |
| 79 | AM_RANGE(0x05, 0x05) AM_READWRITE(mtx_key_lo_r, mtx_sense_w) |
| 80 | AM_RANGE(0x06, 0x06) AM_READWRITE(mtx_key_hi_r, SN76496_0_w) |
| 81 | AM_RANGE(0x08, 0x0b) AM_READWRITE(mtx_ctc_r, mtx_ctc_w) |
| 82 | ADDRESS_MAP_END |
| 95 | 83 | |
| 96 | | return MTX_PRT_NOERROR | (printer_status (mtx_printer_image (), 0) |
| 97 | | ? MTX_PRT_SELECTED : 0); |
| 98 | | } |
| 99 | 84 | |
| 100 | | static WRITE8_HANDLER ( mtx_prt_w ) |
| 101 | | { |
| 102 | | mtx_prt_data = data; |
| 103 | | } |
| 104 | 85 | |
| 105 | | static READ8_HANDLER ( mtx_vdp_r ) |
| 106 | | { |
| 107 | | if (offset & 0x01) |
| 108 | | return TMS9928A_register_r(0); |
| 109 | | else |
| 110 | | return TMS9928A_vram_r(0); |
| 111 | | } |
| 86 | /************************************* |
| 87 | * |
| 88 | * Input ports |
| 89 | * |
| 90 | *************************************/ |
| 112 | 91 | |
| 113 | | static WRITE8_HANDLER ( mtx_vdp_w ) |
| 114 | | { |
| 115 | | if (offset & 0x01) |
| 116 | | TMS9928A_register_w(0, data); |
| 117 | | else |
| 118 | | TMS9928A_vram_w(0, data); |
| 119 | | } |
| 92 | static INPUT_PORTS_START( mtx512 ) |
| 93 | PORT_START_TAG("keyboard_low_0") |
| 94 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 95 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 96 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 97 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 98 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 99 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') |
| 100 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('\\') PORT_CHAR('|') |
| 101 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Keypad 7 Page") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(PGDN)) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) |
| 120 | 102 | |
| 121 | | static WRITE8_HANDLER ( mtx_sense_w ) |
| 122 | | { |
| 123 | | key_sense = data; |
| 124 | | } |
| 103 | PORT_START_TAG("keyboard_low_1") |
| 104 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 105 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 106 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 107 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 108 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 109 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 110 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^') PORT_CHAR('~') |
| 111 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Keypad 8 EOL") PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(END)) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) |
| 125 | 112 | |
| 126 | | static READ8_HANDLER ( mtx_key_lo_r ) |
| 127 | | { |
| 128 | | unsigned char rtn = 0; |
| 113 | PORT_START_TAG("keyboard_low_2") |
| 114 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 115 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') |
| 116 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') |
| 117 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') |
| 118 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') |
| 119 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') |
| 120 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('[') PORT_CHAR('{') |
| 121 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) |
| 129 | 122 | |
| 130 | | if (key_sense==0xfe) |
| 131 | | rtn = readinputport(0); |
| 123 | PORT_START_TAG("keyboard_low_3") |
| 124 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') |
| 125 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') |
| 126 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') |
| 127 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') |
| 128 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') |
| 129 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') PORT_CHAR('`') |
| 130 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Linefeed") PORT_CODE(KEYCODE_PRTSCR) |
| 131 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) |
| 132 | 132 | |
| 133 | | if (key_sense==0xfd) |
| 134 | | rtn = readinputport(1); |
| 133 | PORT_START_TAG("keyboard_low_4") |
| 134 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("AlphaLock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 135 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') |
| 136 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') |
| 137 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') |
| 138 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') |
| 139 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') |
| 140 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR(']') PORT_CHAR('}') |
| 141 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) |
| 135 | 142 | |
| 136 | | if (key_sense==0xfb) |
| 137 | | rtn = readinputport(2); |
| 143 | PORT_START_TAG("keyboard_low_5") |
| 144 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') |
| 145 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') |
| 146 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') |
| 147 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') |
| 148 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') |
| 149 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') |
| 150 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 151 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(HOME)) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) |
| 138 | 152 | |
| 139 | | if (key_sense==0xf7) |
| 140 | | rtn = readinputport(3); |
| 153 | PORT_START_TAG("keyboard_low_6") |
| 154 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 155 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') |
| 156 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') |
| 157 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') |
| 158 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 159 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 160 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 161 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) |
| 141 | 162 | |
| 142 | | if (key_sense==0xef) |
| 143 | | rtn = readinputport(4); |
| 163 | PORT_START_TAG("keyboard_low_7") |
| 164 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') |
| 165 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') |
| 166 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') |
| 167 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') |
| 168 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 169 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('_') |
| 170 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) |
| 171 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Keypad Enter CLS") PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) |
| 144 | 172 | |
| 145 | | if (key_sense==0xdf) |
| 146 | | rtn = readinputport(5); |
| 173 | PORT_START_TAG("keyboard_high_0") |
| 174 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(CANCEL)) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) |
| 175 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 176 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 147 | 177 | |
| 148 | | if (key_sense==0xbf) |
| 149 | | rtn = readinputport(6); |
| 178 | PORT_START_TAG("keyboard_high_1") |
| 179 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 180 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 181 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 150 | 182 | |
| 151 | | if (key_sense==0x7f) |
| 152 | | rtn = readinputport(7); |
| 183 | PORT_START_TAG("keyboard_high_2") |
| 184 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR('\t') PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) |
| 185 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 186 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 153 | 187 | |
| 154 | | return(rtn); |
| 155 | | } |
| 188 | PORT_START_TAG("keyboard_high_3") |
| 189 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) |
| 190 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 191 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 156 | 192 | |
| 157 | | static READ8_HANDLER ( mtx_key_hi_r ) |
| 158 | | { |
| 159 | | unsigned char rtn = 0; |
| 193 | PORT_START_TAG("keyboard_high_4") |
| 194 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED) |
| 195 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 196 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 160 | 197 | |
| 161 | | unsigned char tmp; |
| 162 | | tmp = ((readinputport(10) & 0x03) << 2) | 0xf0; |
| 163 | | rtn = tmp; |
| 198 | PORT_START_TAG("keyboard_high_5") |
| 199 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED) |
| 200 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 201 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 164 | 202 | |
| 165 | | if (key_sense==0xfe) |
| 166 | | rtn = (readinputport(8) & 0x03) | tmp; |
| 203 | PORT_START_TAG("keyboard_high_6") |
| 204 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED) |
| 205 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 206 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 167 | 207 | |
| 168 | | if (key_sense==0xfd) |
| 169 | | rtn = ((readinputport(8) >> 2) & 0x03) | tmp; |
| 208 | PORT_START_TAG("keyboard_high_7") |
| 209 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 210 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 211 | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 170 | 212 | |
| 171 | | if (key_sense==0xfb) |
| 172 | | rtn = ((readinputport(8) >> 4) & 0x03) | tmp; |
| 213 | PORT_START_TAG("country_code") |
| 214 | PORT_DIPNAME(0x04, 0x00, "Country Code Switch 1") |
| 215 | PORT_DIPSETTING(0x04, DEF_STR(Off) ) |
| 216 | PORT_DIPSETTING(0x00, DEF_STR(On) ) |
| 217 | PORT_DIPNAME(0x08, 0x00, "Country Code Switch 0") |
| 218 | PORT_DIPSETTING(0x08, DEF_STR(Off) ) |
| 219 | PORT_DIPSETTING(0x00, DEF_STR(On) ) |
| 220 | PORT_BIT(0xf3, IP_ACTIVE_LOW, IPT_UNUSED) |
| 221 | INPUT_PORTS_END |
| 173 | 222 | |
| 174 | | if (key_sense==0xf7) |
| 175 | | rtn = ((readinputport(8) >> 6) & 0x03) | tmp; |
| 176 | 223 | |
| 177 | | if (key_sense==0xef) |
| 178 | | rtn = (readinputport(9) & 0x03) | tmp; |
| 179 | 224 | |
| 180 | | if (key_sense==0xdf) |
| 181 | | rtn = ((readinputport(9) >> 2) & 0x03) | tmp; |
| 225 | /************************************* |
| 226 | * |
| 227 | * Z80 daisy chain |
| 228 | * |
| 229 | *************************************/ |
| 182 | 230 | |
| 183 | | if (key_sense==0xbf) |
| 184 | | rtn = ((readinputport(9) >> 4) & 0x03) | tmp; |
| 185 | | |
| 186 | | if (key_sense==0x7f) |
| 187 | | rtn = ((readinputport(9) >> 6) & 0x03) | tmp; |
| 188 | | |
| 189 | | return(rtn); |
| 190 | | } |
| 191 | | |
| 192 | | static void mtx_ctc_interrupt(int state) |
| 231 | static const struct z80_irq_daisy_chain mtx_daisy_chain[] = |
| 193 | 232 | { |
| 194 | | //logerror("interrupting ctc %02x\r\n ",state); |
| 195 | | cpunum_set_input_line(0, 0, state); |
| 196 | | } |
| 197 | | |
| 198 | | static READ8_HANDLER ( mtx_ctc_r ) |
| 199 | | { |
| 200 | | return z80ctc_0_r(offset); |
| 201 | | } |
| 202 | | |
| 203 | | static WRITE8_HANDLER ( mtx_ctc_w ) |
| 204 | | { |
| 205 | | //logerror("CTC W: %02x\r\n",data); |
| 206 | | if (offset < 3) |
| 207 | | z80ctc_0_w(offset,data); |
| 208 | | } |
| 209 | | |
| 210 | | static z80ctc_interface mtx_ctc_intf = |
| 211 | | { |
| 212 | | MTX_SYSTEM_CLOCK, |
| 213 | | 0, |
| 214 | | mtx_ctc_interrupt, |
| 215 | | 0, |
| 216 | | 0, |
| 217 | | 0 |
| 233 | {z80ctc_reset, z80ctc_irq_state, z80ctc_irq_ack, z80ctc_irq_reti, 0}, |
| 234 | {0, 0, 0, 0, -1} |
| 218 | 235 | }; |
| 219 | 236 | |
| 220 | | static void mtx_tms9929A_interrupt (int data) |
| 221 | | { |
| 222 | | // logerror ("tms9929A_interrupt: %d\n", data); |
| 223 | | z80ctc_0_trg0_w (0, data ? 0 : 1); |
| 224 | | } |
| 225 | 237 | |
| 226 | | static void mtx_set_bank_offsets (unsigned int bank1, unsigned int bank2, |
| 227 | | unsigned int bank3, unsigned int bank4, |
| 228 | | unsigned int bank5, unsigned int bank6, |
| 229 | | unsigned int bank7, unsigned int bank8) |
| 230 | | { |
| 231 | | unsigned char * romimage; |
| 232 | 238 | |
| 233 | | // logerror ("CPM %d RAM %x ROM %x\n", mtx_relcpmh, |
| 234 | | // mtx_rampage, mtx_rompage); |
| 235 | | // logerror ("map: [0000] %04x [2000] %04x [4000] %04x [6000] %04x\n", |
| 236 | | // bank1, bank2, bank3, bank4); |
| 237 | | // logerror (" [8000] %04x [a000] %04x [c000] %04x [e000] %04x\n", |
| 238 | | // bank5, bank6, bank7, bank8); |
| 239 | /************************************* |
| 240 | * |
| 241 | * Machine drivers |
| 242 | * |
| 243 | *************************************/ |
| 239 | 244 | |
| 240 | | romimage = memory_region (REGION_CPU1); |
| 245 | static MACHINE_DRIVER_START( mtx512 ) |
| 246 | /* basic machine hardware */ |
| 247 | MDRV_CPU_ADD(Z80, MTX_SYSTEM_CLOCK) |
| 248 | MDRV_CPU_PROGRAM_MAP(mtx_mem, 0) |
| 249 | MDRV_CPU_IO_MAP(mtx_io, 0) |
| 250 | MDRV_CPU_VBLANK_INT(mtx_interrupt, 1) |
| 251 | MDRV_CPU_CONFIG(mtx_daisy_chain) |
| 252 | MDRV_SCREEN_REFRESH_RATE(50) |
| 253 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION) |
| 241 | 254 | |
| 242 | | if (mtx_relcpmh) |
| 243 | | { |
| 244 | | memory_set_bankptr (1, mess_ram + bank1); |
| 245 | | // bank 9 is handled by the mtx_trap_write function |
| 246 | | memory_set_bankptr (2, mess_ram + bank2); |
| 247 | | memory_set_bankptr (10, mess_ram + bank2); |
| 248 | | } |
| 249 | | else |
| 250 | | { |
| 251 | | memory_set_bankptr (1, romimage + bank1); |
| 252 | | // bank is 9 handled by the mtx_trap_write function |
| 253 | | memory_set_bankptr (2, romimage + bank2); |
| 254 | | memory_set_bankptr (10, mtx_null_mem); |
| 255 | | } |
| 255 | MDRV_MACHINE_START( mtx512 ) |
| 256 | 256 | |
| 257 | | if (bank3 < mess_ram_size) |
| 258 | | { |
| 259 | | memory_set_bankptr (3, mess_ram + bank3); |
| 260 | | memory_set_bankptr (11, mess_ram + bank3); |
| 261 | | } |
| 262 | | else |
| 263 | | { |
| 264 | | memory_set_bankptr (3, mtx_null_mem); |
| 265 | | memory_set_bankptr (11, mtx_zero_mem); |
| 266 | | } |
| 257 | /* video hardware */ |
| 258 | MDRV_IMPORT_FROM(tms9928a) |
| 267 | 259 | |
| 268 | | if (bank4 < mess_ram_size) |
| 269 | | { |
| 270 | | memory_set_bankptr (4, mess_ram + bank4); |
| 271 | | memory_set_bankptr (12, mess_ram + bank4); |
| 272 | | } |
| 273 | | else |
| 274 | | { |
| 275 | | memory_set_bankptr (4, mtx_null_mem); |
| 276 | | memory_set_bankptr (12, mtx_zero_mem); |
| 277 | | } |
| 260 | /* sound hardware */ |
| 261 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 262 | MDRV_SOUND_ADD(SN76489A, MTX_SYSTEM_CLOCK) |
| 263 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 264 | MACHINE_DRIVER_END |
| 278 | 265 | |
| 279 | | if (bank5 < mess_ram_size) |
| 280 | | { |
| 281 | | memory_set_bankptr (5, mess_ram + bank5); |
| 282 | | memory_set_bankptr (13, mess_ram + bank5); |
| 283 | | } |
| 284 | | else |
| 285 | | { |
| 286 | | memory_set_bankptr (5, mtx_null_mem); |
| 287 | | memory_set_bankptr (13, mtx_zero_mem); |
| 288 | | } |
| 289 | 266 | |
| 290 | | if (bank6 < mess_ram_size) |
| 291 | | { |
| 292 | | memory_set_bankptr (6, mess_ram + bank6); |
| 293 | | memory_set_bankptr (14, mess_ram + bank6); |
| 294 | | } |
| 295 | | else |
| 296 | | { |
| 297 | | memory_set_bankptr (6, mtx_null_mem); |
| 298 | | memory_set_bankptr (14, mtx_zero_mem); |
| 299 | | } |
| 267 | static MACHINE_DRIVER_START( rs128 ) |
| 268 | MDRV_IMPORT_FROM(mtx512) |
| 269 | MDRV_MACHINE_RESET(rs128) |
| 270 | MACHINE_DRIVER_END |
| 300 | 271 | |
| 301 | | memory_set_bankptr (7, mess_ram + bank7); |
| 302 | | memory_set_bankptr (15, mess_ram + bank7); |
| 303 | 272 | |
| 304 | | memory_set_bankptr (8, mess_ram + bank8); |
| 305 | | memory_set_bankptr (16, mess_ram + bank8); |
| 306 | | } |
| 307 | 273 | |
| 308 | | static WRITE8_HANDLER ( mtx_bankswitch_w ) |
| 309 | | { |
| 310 | | unsigned int bank1, bank2, bank3, bank4; |
| 311 | | unsigned int bank5, bank6, bank7, bank8; |
| 274 | /************************************* |
| 275 | * |
| 276 | * ROM definitions |
| 277 | * |
| 278 | *************************************/ |
| 312 | 279 | |
| 313 | | mtx_relcpmh = (data & 0x80) >> 7; |
| 314 | | mtx_rampage = (data & 0x0f); |
| 315 | | mtx_rompage = (data & 0x70) >> 4; |
| 280 | ROM_START( mtx512 ) |
| 281 | ROM_REGION(0x12000, REGION_CPU1, 0) |
| 282 | ROM_LOAD("osrom", 0x0000, 0x2000, CRC(9ca858cc) SHA1(3804503a58f0bcdea96bb6488833782ebd03976d)) |
| 283 | ROM_LOAD("basicrom", 0x2000, 0x2000, CRC(87b4e59c) SHA1(c49782a82a7f068c1195cd967882ba9edd546eaf)) |
| 284 | ROM_LOAD("assemrom", 0x4000, 0x2000, CRC(9d7538c3) SHA1(d1882c4ea61a68b1715bd634ded5603e18a99c5f)) |
| 285 | ROM_END |
| 316 | 286 | |
| 317 | | if (mtx_relcpmh) |
| 318 | | { |
| 319 | | bank1 = 0xe000 + mtx_rampage * 0xc000; |
| 320 | | bank2 = 0xc000 + mtx_rampage * 0xc000; |
| 321 | | bank3 = 0xa000 + mtx_rampage * 0xc000; |
| 322 | | bank4 = 0x8000 + mtx_rampage * 0xc000; |
| 323 | | bank5 = 0x6000 + mtx_rampage * 0xc000; |
| 324 | | bank6 = 0x4000 + mtx_rampage * 0xc000; |
| 325 | | } |
| 326 | | else |
| 327 | | { |
| 328 | | bank1 = 0x0; |
| 329 | | bank2 = 0x2000 + mtx_rompage * 0x2000; |
| 330 | | bank3 = 0xa000 + mtx_rampage * 0x8000; |
| 331 | | bank4 = 0x8000 + mtx_rampage * 0x8000; |
| 332 | | bank5 = 0x6000 + mtx_rampage * 0x8000; |
| 333 | | bank6 = 0x4000 + mtx_rampage * 0x8000; |
| 334 | | } |
| 335 | 287 | |
| 336 | | bank7 = 0x2000; |
| 337 | | bank8 = 0x0; |
| 288 | #define rom_mtx500 rom_mtx512 |
| 289 | #define rom_rs128 rom_mtx512 |
| 338 | 290 | |
| 339 | | mtx_set_bank_offsets (bank1, bank2, bank3, bank4, |
| 340 | | bank5, bank6, bank7, bank8); |
| 341 | | } |
| 342 | 291 | |
| 343 | | static void mtx_virt_to_phys (const char * what, int vaddress, |
| 344 | | int * ramspace, int * paddress) |
| 345 | | { |
| 346 | | int offset = vaddress & 0x1fff; |
| 347 | | int vbase = vaddress & ~0x1fff; |
| 348 | | int pbase = 0x20000; |
| 349 | 292 | |
| 350 | | *ramspace = mtx_relcpmh || vaddress >= 0x4000; |
| 293 | /************************************* |
| 294 | * |
| 295 | * System configs |
| 296 | * |
| 297 | *************************************/ |
| 351 | 298 | |
| 352 | | if (0xc000 <= vaddress && vaddress < 0x10000) |
| 353 | | pbase = 0xe000 - vbase; |
| 354 | | else if (mtx_relcpmh) |
| 355 | | pbase = 0xe000 - vbase + mtx_rampage * 0xc000; |
| 356 | | else if (0 <= vaddress && vaddress < 0x2000) |
| 357 | | pbase = 0; |
| 358 | | else if (0x2000 <= vaddress && vaddress < 0x4000) |
| 359 | | pbase = 0x2000 + mtx_rompage * 0x2000; |
| 360 | | else if (0x4000 <= vaddress && vaddress < 0xc000) |
| 361 | | pbase = (0xe000 - vbase) + mtx_rampage * 0x8000; |
| 362 | | |
| 363 | | *paddress = pbase + offset; |
| 364 | | |
| 365 | | // logerror ("%s (%d,%d,%d,%04x) -> (%d,%06x)\n", what, |
| 366 | | // mtx_relcpmh, mtx_rompage, mtx_rampage, vaddress, |
| 367 | | // *ramspace, *paddress); |
| 368 | | } |
| 369 | | |
| 370 | | static unsigned char mtx_peek (int vaddress) |
| 371 | | { |
| 372 | | unsigned char * romimage; |
| 373 | | int ramspace; |
| 374 | | int paddress; |
| 375 | | |
| 376 | | romimage = memory_region (REGION_CPU1); |
| 377 | | mtx_virt_to_phys ("peek", vaddress, &ramspace, &paddress); |
| 378 | | |
| 379 | | if (paddress > mess_ram_size) { |
| 380 | | logerror ("peek into non-existing memory\n"); |
| 381 | | return 0; |
| 382 | | } |
| 383 | | |
| 384 | | if (ramspace) |
| 385 | | return mess_ram[paddress]; |
| 386 | | else |
| 387 | | return romimage[paddress]; |
| 388 | | } |
| 389 | | |
| 390 | | static void mtx_poke (int vaddress, unsigned char data) |
| 391 | | { |
| 392 | | int ramspace; |
| 393 | | int paddress; |
| 394 | | |
| 395 | | mtx_virt_to_phys ("poke", vaddress, &ramspace, &paddress); |
| 396 | | if (!ramspace) |
| 397 | | logerror ("poke into the ROM address space\n"); |
| 398 | | else if (paddress >= mess_ram_size) |
| 399 | | logerror ("poke into non-existing RAM\n"); |
| 400 | | else |
| 401 | | mess_ram[paddress] = data; |
| 402 | | } |
| 403 | | |
| 404 | | /* |
| 405 | | * A filename is at most 14 characters long, always ending with a space. |
| 406 | | * The save file can be at most 65536 long. |
| 407 | | * Note: the empty string is saved as a single space. |
| 408 | | */ |
| 409 | | static void mtx_save_hack(int start, int length) |
| 410 | | { |
| 411 | | mame_file * tape_file; |
| 412 | | file_error filerr; |
| 413 | | int bytes_saved; |
| 414 | | int i; |
| 415 | | |
| 416 | | assert(length <= 32768); |
| 417 | | |
| 418 | | // logerror("mtx_save_hack: start=%#x length=%#x (%d) index=%#x (%d)\n", |
| 419 | | // start, length, length, mtx_save_index, mtx_save_index); |
| 420 | | |
| 421 | | if ((start > 0xc000) && (length == 20)) /* Save the header segment */ |
| 422 | | { |
| 423 | | for (i = 0; i < 18; i++) |
| 424 | | mtx_tape_buf[i] = mtx_peek(start + i); |
| 425 | | length = 18; |
| 426 | | |
| 427 | | memcpy(mtx_tape_filename, mtx_tape_buf + 1, 15); |
| 428 | | for (i = 14; i > 0 && mtx_tape_filename[i] == 0x20; i--) |
| 429 | | ; |
| 430 | | mtx_tape_filename[i + 1] = '\0'; |
| 431 | | mtx_tape_index = 0; |
| 432 | | |
| 433 | | filerr = mame_fopen(SEARCHPATH_IMAGE, mtx_tape_filename, |
| 434 | | OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, &tape_file); |
| 435 | | } |
| 436 | | else /* Save system variable, body, or variable store segment */ |
| 437 | | { |
| 438 | | for (i = 0; i < length; i++) |
| 439 | | mtx_tape_buf[i] = mtx_peek(start + i); |
| 440 | | |
| 441 | | filerr = mame_fopen(SEARCHPATH_IMAGE, mtx_tape_filename, |
| 442 | | OPEN_FLAG_WRITE, &tape_file); |
| 443 | | } |
| 444 | | |
| 445 | | if (filerr == FILERR_NONE) |
| 446 | | { |
| 447 | | mame_fseek(tape_file, mtx_tape_index, SEEK_SET); |
| 448 | | bytes_saved = mame_fwrite(tape_file, mtx_tape_buf, length); |
| 449 | | logerror("saved %d bytes from %d:%04x into '%s' at %d\n", bytes_saved, |
| 450 | | mtx_rampage, start, mtx_tape_filename, mtx_tape_index); |
| 451 | | if (length > bytes_saved) |
| 452 | | logerror("wrote too few bytes from '%s'\n", mtx_tape_filename); |
| 453 | | |
| 454 | | mame_fclose(tape_file); |
| 455 | | mtx_tape_index += length; |
| 456 | | } |
| 457 | | else |
| 458 | | logerror("cannot open '%s' for saving\n", mtx_tape_filename); |
| 459 | | } |
| 460 | | |
| 461 | | /* |
| 462 | | * A filename is at most 14 characters long, ending with a space. |
| 463 | | * At most 65536 bytes are loaded from the file. |
| 464 | | * Note: the empty string is loaded as a single space (ugly), |
| 465 | | * not the 'next' file. |
| 466 | | */ |
| 467 | | static void mtx_load_hack(int start, int length) |
| 468 | | { |
| 469 | | mame_file * tape_file; |
| 470 | | file_error filerr; |
| 471 | | int bytes_loaded; |
| 472 | | int i; |
| 473 | | |
| 474 | | assert(length <= 32768); |
| 475 | | |
| 476 | | // logerror("mtx_load_hack: start=%#x length=%#x (%d)\n", start, length, length); |
| 477 | | |
| 478 | | if ((start > 0xc000) && (length == 18)) |
| 479 | | { |
| 480 | | for (i = 0; i < 15; i++) |
| 481 | | mtx_tape_filename[i] = mtx_peek(start - 0xf + i); |
| 482 | | |
| 483 | | for (i = 14; i > 0 && mtx_tape_filename[i] == 0x20; i--) |
| 484 | | ; |
| 485 | | |
| 486 | | mtx_tape_filename[i+1] = '\0'; |
| 487 | | mtx_tape_index = 0; |
| 488 | | } |
| 489 | | |
| 490 | | filerr = mame_fopen(SEARCHPATH_IMAGE, mtx_tape_filename, OPEN_FLAG_READ, |
| 491 | | &tape_file); |
| 492 | | if (filerr == FILERR_NONE) |
| 493 | | { |
| 494 | | mame_fseek(tape_file, mtx_tape_index, SEEK_SET); |
| 495 | | bytes_loaded = mame_fread(tape_file, mtx_tape_buf, length); |
| 496 | | logerror("loaded %d bytes from '%s' at %d into %d:%04x\n", bytes_loaded, |
| 497 | | mtx_tape_filename, mtx_tape_index, mtx_rampage, start); |
| 498 | | if (length > bytes_loaded) |
| 499 | | logerror("read too few bytes from '%s'\n", mtx_tape_filename); |
| 500 | | |
| 501 | | for (i = 0; i < length; i++) |
| 502 | | mtx_poke(start + i, mtx_tape_buf[i]); |
| 503 | | |
| 504 | | mame_fclose(tape_file); |
| 505 | | mtx_tape_index += length; |
| 506 | | } |
| 507 | | else |
| 508 | | logerror("cannot open '%s' for loading\n", mtx_tape_filename); |
| 509 | | } |
| 510 | | |
| 511 | | static void mtx_verify_hack(int start, int length) |
| 512 | | { |
| 513 | | // logerror("mtx_verify_hack: start=0x%x length=0x%x (%d) not implemented\n", start, length, length); |
| 514 | | } |
| 515 | | |
| 516 | | static WRITE8_HANDLER ( mtx_trap_write ) |
| 517 | | { |
| 518 | | int pc; |
| 519 | | int start; |
| 520 | | int length; |
| 521 | | |
| 522 | | if (mtx_relcpmh) |
| 523 | | { |
| 524 | | mtx_poke (offset, data); |
| 525 | | return; |
| 526 | | } |
| 527 | | |
| 528 | | pc = activecpu_get_reg(Z80_PC); |
| 529 | | if((offset == 0x0aae) && (pc == 0x0ab1)) |
| 530 | | { |
| 531 | | start = activecpu_get_reg(Z80_HL); |
| 532 | | length = activecpu_get_reg(Z80_DE); |
| 533 | | |
| 534 | | // logerror("PC %04x\nStart %04x, Length %04x, 0xFD67 %02x, 0xFD68 %02x index 0x%04x\n", pc, start, length, mess_ram[0xfd67], mess_ram[0xfd68], mtx_tape_size); |
| 535 | | |
| 536 | | if(mtx_peek(0xfd68) == 0) |
| 537 | | mtx_save_hack(start, length); |
| 538 | | else if(mtx_peek(0xfd67) == 0) |
| 539 | | mtx_load_hack(start, length); |
| 540 | | else |
| 541 | | mtx_verify_hack(start, length); |
| 542 | | } |
| 543 | | } |
| 544 | | |
| 545 | 299 | static void mtx_printer_getinfo(const device_class *devclass, UINT32 state, union devinfo *info) |
| 546 | 300 | { |
| 547 | 301 | switch(state) |
| r1582 | r1583 | |
| 553 | 307 | } |
| 554 | 308 | } |
| 555 | 309 | |
| 556 | | static const TMS9928a_interface tms9928a_interface = |
| 557 | | { |
| 558 | | TMS9929A, |
| 559 | | 0x4000, |
| 560 | | 0, 0, |
| 561 | | mtx_tms9929A_interrupt |
| 562 | | }; |
| 563 | 310 | |
| 564 | | static MACHINE_START( mtx512 ) |
| 311 | static void mtx_snapshot_getinfo(const device_class *devclass, UINT32 state, union devinfo *info) |
| 565 | 312 | { |
| 566 | | unsigned char * romimage; |
| 313 | switch(state) |
| 314 | { |
| 315 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 316 | case DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "mtb"); break; |
| 567 | 317 | |
| 568 | | TMS9928A_configure(&tms9928a_interface); |
| 318 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 319 | case DEVINFO_PTR_SNAPSHOT_LOAD: info->f = (genf *) snapshot_load_mtx; break; |
| 569 | 320 | |
| 570 | | mtx_null_mem = (unsigned char *) auto_malloc (16384); |
| 571 | | mtx_zero_mem = (unsigned char *) auto_malloc (16384); |
| 572 | | memset (mtx_zero_mem, 0, 16384); |
| 321 | /* --- the following bits of info are returned as doubles --- */ |
| 322 | case DEVINFO_FLOAT_SNAPSHOT_DELAY: info->d = 0.5; break; |
| 573 | 323 | |
| 574 | | mtx_tape_buf = auto_malloc (32768); |
| 575 | | mtx_tape_index = 0; |
| 576 | | mtx_tape_filename = auto_malloc (16); |
| 577 | | mtx_tape_filename[0] = 0; |
| 578 | | |
| 579 | | z80ctc_init(0, &mtx_ctc_intf); |
| 580 | | |
| 581 | | // Patch the Rom (Sneaky........ Who needs to trap opcodes?) |
| 582 | | romimage = memory_region(REGION_CPU1); |
| 583 | | romimage[0x0aae] = 0x32; // ld ($0aae),a |
| 584 | | romimage[0x0aaf] = 0xae; |
| 585 | | romimage[0x0ab0] = 0x0a; |
| 586 | | romimage[0x0ab1] = 0xc9; // ret |
| 587 | | |
| 588 | | // Set up the starting memory configuration |
| 589 | | mtx_relcpmh = 0; |
| 590 | | mtx_rampage = 0; |
| 591 | | mtx_rompage = 0; |
| 592 | | mtx_set_bank_offsets (0, 0x2000, 0xa0000, 0x8000, |
| 593 | | 0x6000, 0x4000, 0x2000, 0); |
| 324 | default: snapshot_device_getinfo(devclass, state, info); break; |
| 325 | } |
| 594 | 326 | } |
| 595 | 327 | |
| 596 | | static INTERRUPT_GEN( mtx_interrupt ) |
| 597 | | { |
| 598 | | TMS9928A_interrupt(); |
| 599 | | } |
| 600 | 328 | |
| 601 | | static ADDRESS_MAP_START( mtx_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 602 | | AM_RANGE( 0x0000, 0x1fff) AM_READWRITE( MRA8_BANK1, mtx_trap_write ) |
| 603 | | AM_RANGE( 0x2000, 0x3fff) AM_READWRITE( MRA8_BANK2, MWA8_BANK10 ) |
| 604 | | AM_RANGE( 0x4000, 0x5fff) AM_READWRITE( MRA8_BANK3, MWA8_BANK11 ) |
| 605 | | AM_RANGE( 0x6000, 0x7fff) AM_READWRITE( MRA8_BANK4, MWA8_BANK12 ) |
| 606 | | AM_RANGE( 0x8000, 0x9fff) AM_READWRITE( MRA8_BANK5, MWA8_BANK13 ) |
| 607 | | AM_RANGE( 0xa000, 0xbfff) AM_READWRITE( MRA8_BANK6, MWA8_BANK14 ) |
| 608 | | AM_RANGE( 0xc000, 0xdfff) AM_READWRITE( MRA8_BANK7, MWA8_BANK15 ) |
| 609 | | AM_RANGE( 0xe000, 0xffff) AM_READWRITE( MRA8_BANK8, MWA8_BANK16 ) |
| 610 | | ADDRESS_MAP_END |
| 611 | | |
| 612 | | static ADDRESS_MAP_START( mtx_io, ADDRESS_SPACE_IO, 8) |
| 613 | | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 614 | | AM_RANGE( 0x00, 0x00) AM_READWRITE( mtx_strobe_r, mtx_bankswitch_w ) |
| 615 | | AM_RANGE( 0x01, 0x02) AM_READWRITE( mtx_vdp_r, mtx_vdp_w ) |
| 616 | | AM_RANGE( 0x03, 0x03) AM_READWRITE( mtx_psg_r, mtx_cst_w ) |
| 617 | | AM_RANGE( 0x04, 0x04) AM_READWRITE( mtx_prt_r, mtx_prt_w ) |
| 618 | | AM_RANGE( 0x05, 0x05) AM_READWRITE( mtx_key_lo_r, mtx_sense_w ) |
| 619 | | AM_RANGE( 0x06, 0x06) AM_READWRITE( mtx_key_hi_r, mtx_psg_w ) |
| 620 | | AM_RANGE( 0x08, 0x0b) AM_READWRITE( mtx_ctc_r, mtx_ctc_w ) |
| 621 | | ADDRESS_MAP_END |
| 622 | | |
| 623 | | static INPUT_PORTS_START( mtx512 ) |
| 624 | | PORT_START /* 0 */ |
| 625 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1 !") PORT_CODE(KEYCODE_1) |
| 626 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3 #") PORT_CODE(KEYCODE_3) |
| 627 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5 %") PORT_CODE(KEYCODE_5) |
| 628 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7 '") PORT_CODE(KEYCODE_7) |
| 629 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9 )") PORT_CODE(KEYCODE_9) |
| 630 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("- =") PORT_CODE(KEYCODE_MINUS) |
| 631 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\\ |") PORT_CODE(KEYCODE_BACKSLASH) |
| 632 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD7 PAGE )") PORT_CODE(KEYCODE_7_PAD) |
| 633 | | |
| 634 | | PORT_START /* 1 */ |
| 635 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ESCAPE") PORT_CODE(KEYCODE_ESC) |
| 636 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2 \"") PORT_CODE(KEYCODE_2) |
| 637 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4 $") PORT_CODE(KEYCODE_4) |
| 638 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6 &") PORT_CODE(KEYCODE_6) |
| 639 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8 (") PORT_CODE(KEYCODE_8) |
| 640 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0 0") PORT_CODE(KEYCODE_0) |
| 641 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("^ ~") PORT_CODE(KEYCODE_EQUALS) |
| 642 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD8 EOL") PORT_CODE(KEYCODE_8_PAD) |
| 643 | | |
| 644 | | PORT_START /* 2 */ |
| 645 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) |
| 646 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("w W") PORT_CODE(KEYCODE_W) |
| 647 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("r R") PORT_CODE(KEYCODE_R) |
| 648 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("y Y") PORT_CODE(KEYCODE_Y) |
| 649 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("i I") PORT_CODE(KEYCODE_I) |
| 650 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("p P") PORT_CODE(KEYCODE_P) |
| 651 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[ {") PORT_CODE(KEYCODE_CLOSEBRACE) |
| 652 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD5 CURSORUP") PORT_CODE(KEYCODE_5_PAD) |
| 653 | | |
| 654 | | PORT_START /* 3 */ |
| 655 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("q Q") PORT_CODE(KEYCODE_Q) |
| 656 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("e E") PORT_CODE(KEYCODE_E) |
| 657 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("t T") PORT_CODE(KEYCODE_T) |
| 658 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("u U") PORT_CODE(KEYCODE_U) |
| 659 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("o O") PORT_CODE(KEYCODE_O) |
| 660 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("@ `") PORT_CODE(KEYCODE_OPENBRACE) |
| 661 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LINEFEED") PORT_CODE(KEYCODE_DOWN) |
| 662 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD1 CURSORLEFT") PORT_CODE(KEYCODE_1_PAD) |
| 663 | | |
| 664 | | PORT_START /* 4 */ |
| 665 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ALPHALOCK") PORT_CODE(KEYCODE_CAPSLOCK) |
| 666 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("s S") PORT_CODE(KEYCODE_S) |
| 667 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("f F") PORT_CODE(KEYCODE_F) |
| 668 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("h H") PORT_CODE(KEYCODE_H) |
| 669 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("k K") PORT_CODE(KEYCODE_K) |
| 670 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("; +") PORT_CODE(KEYCODE_COLON) |
| 671 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("] }") PORT_CODE(KEYCODE_BACKSLASH2) |
| 672 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD3 CURSORRIGHT") PORT_CODE(KEYCODE_3_PAD) |
| 673 | | |
| 674 | | PORT_START /* 5 */ |
| 675 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("a A") PORT_CODE(KEYCODE_A) |
| 676 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("d D") PORT_CODE(KEYCODE_D) |
| 677 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("g G") PORT_CODE(KEYCODE_G) |
| 678 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("j J") PORT_CODE(KEYCODE_J) |
| 679 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("l L") PORT_CODE(KEYCODE_L) |
| 680 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(": *") PORT_CODE(KEYCODE_QUOTE) |
| 681 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) |
| 682 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD2 HOME") PORT_CODE(KEYCODE_2_PAD) |
| 683 | | |
| 684 | | PORT_START /* 6 */ |
| 685 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEFTSHIFT") PORT_CODE(KEYCODE_LSHIFT) |
| 686 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("x X") PORT_CODE(KEYCODE_X) |
| 687 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("v V") PORT_CODE(KEYCODE_V) |
| 688 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("n N") PORT_CODE(KEYCODE_N) |
| 689 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(", <") PORT_CODE(KEYCODE_COMMA) |
| 690 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) |
| 691 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RIGHTSHIFT") PORT_CODE(KEYCODE_RSHIFT) |
| 692 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD(.) CURSORDOWN") PORT_CODE(KEYCODE_DEL_PAD) |
| 693 | | |
| 694 | | PORT_START /* 7 */ |
| 695 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("z Z") PORT_CODE(KEYCODE_Z) |
| 696 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("c C") PORT_CODE(KEYCODE_C) |
| 697 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("b B") PORT_CODE(KEYCODE_B) |
| 698 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("m M") PORT_CODE(KEYCODE_M) |
| 699 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("(.) >") PORT_CODE(KEYCODE_STOP) |
| 700 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("_ _") PORT_CODE(KEYCODE_MINUS_PAD) |
| 701 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD0 INS") PORT_CODE(KEYCODE_0_PAD) |
| 702 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPADENTER CLS") PORT_CODE(KEYCODE_ENTER_PAD) |
| 703 | | |
| 704 | | /* Hi Bits */ |
| 705 | | |
| 706 | | PORT_START /* 8 */ |
| 707 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD9 BRK") PORT_CODE(KEYCODE_9_PAD) |
| 708 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) |
| 709 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("BS") PORT_CODE(KEYCODE_BACKSPACE) |
| 710 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) |
| 711 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD4 TAB") PORT_CODE(KEYCODE_4_PAD) |
| 712 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) |
| 713 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMERICPAD6 DEL") PORT_CODE(KEYCODE_6_PAD) |
| 714 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) |
| 715 | | |
| 716 | | PORT_START /* 9 */ |
| 717 | | PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("(none)") |
| 718 | | PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) |
| 719 | | PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("(none)") |
| 720 | | PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) |
| 721 | | PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("(none)") |
| 722 | | PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) |
| 723 | | PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) |
| 724 | | PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) |
| 725 | | |
| 726 | | PORT_START /* 10 */ |
| 727 | | PORT_DIPNAME(0x02, 0x00, "Country Code Switch 1") |
| 728 | | PORT_DIPSETTING(0x02, DEF_STR(Off) ) |
| 729 | | PORT_DIPSETTING(0x00, DEF_STR(On) ) |
| 730 | | PORT_DIPNAME(0x01, 0x00, "Country Code Switch 0") |
| 731 | | PORT_DIPSETTING(0x01, DEF_STR(Off) ) |
| 732 | | PORT_DIPSETTING(0x00, DEF_STR(On) ) |
| 733 | | PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED) |
| 734 | | |
| 735 | | INPUT_PORTS_END |
| 736 | | |
| 737 | | |
| 738 | | static const struct z80_irq_daisy_chain mtx_daisy_chain[] = |
| 739 | | { |
| 740 | | {z80ctc_reset, z80ctc_irq_state, z80ctc_irq_ack, z80ctc_irq_reti, 0}, |
| 741 | | {0,0,0,0,-1} |
| 742 | | }; |
| 743 | | |
| 744 | | static MACHINE_DRIVER_START( mtx512 ) |
| 745 | | /* basic machine hardware */ |
| 746 | | MDRV_CPU_ADD(Z80, MTX_SYSTEM_CLOCK) |
| 747 | | MDRV_CPU_PROGRAM_MAP(mtx_mem, 0) |
| 748 | | MDRV_CPU_IO_MAP(mtx_io, 0) |
| 749 | | MDRV_CPU_VBLANK_INT(mtx_interrupt, 1) |
| 750 | | MDRV_CPU_CONFIG(mtx_daisy_chain) |
| 751 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 752 | | MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION) |
| 753 | | MDRV_INTERLEAVE(1) |
| 754 | | |
| 755 | | MDRV_MACHINE_START( mtx512 ) |
| 756 | | |
| 757 | | /* video hardware */ |
| 758 | | MDRV_IMPORT_FROM(tms9928a) |
| 759 | | |
| 760 | | /* sound hardware */ |
| 761 | | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 762 | | MDRV_SOUND_ADD(SN76489A, MTX_SYSTEM_CLOCK) |
| 763 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 764 | | MACHINE_DRIVER_END |
| 765 | | |
| 766 | | ROM_START (mtx512) |
| 767 | | ROM_REGION (0x12000, REGION_CPU1, 0) |
| 768 | | ROM_LOAD ("osrom", 0x0, 0x2000, CRC(9ca858cc) SHA1(3804503a58f0bcdea96bb6488833782ebd03976d)) |
| 769 | | ROM_LOAD ("basicrom", 0x2000, 0x2000, CRC(87b4e59c) SHA1(c49782a82a7f068c1195cd967882ba9edd546eaf)) |
| 770 | | ROM_LOAD ("assemrom", 0x4000, 0x2000, CRC(9d7538c3) SHA1(d1882c4ea61a68b1715bd634ded5603e18a99c5f)) |
| 771 | | ROM_END |
| 772 | | |
| 773 | | SYSTEM_CONFIG_START(mtx512) |
| 774 | | CONFIG_RAM(32 * 1024) |
| 775 | | CONFIG_RAM_DEFAULT(64 * 1024) |
| 776 | | CONFIG_RAM(96 * 1024) |
| 777 | | CONFIG_RAM(128 * 1024) |
| 329 | SYSTEM_CONFIG_START( mtx_common ) |
| 330 | CONFIG_DEVICE(mtx_snapshot_getinfo) |
| 331 | CONFIG_DEVICE(mtx_printer_getinfo) |
| 778 | 332 | CONFIG_RAM(160 * 1024) |
| 779 | 333 | CONFIG_RAM(192 * 1024) |
| 780 | 334 | CONFIG_RAM(224 * 1024) |
| r1582 | r1583 | |
| 787 | 341 | CONFIG_RAM(448 * 1024) |
| 788 | 342 | CONFIG_RAM(480 * 1024) |
| 789 | 343 | CONFIG_RAM(512 * 1024) |
| 790 | | CONFIG_DEVICE(mtx_printer_getinfo) |
| 791 | 344 | SYSTEM_CONFIG_END |
| 792 | 345 | |
| 793 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG, COMPANY FULLNAME */ |
| 794 | | COMP( 1983, mtx512, 0, 0, mtx512, mtx512, 0, mtx512, "Memotech Ltd.", "MTX 512" , 0) |
| 346 | |
| 347 | SYSTEM_CONFIG_START( mtx512 ) |
| 348 | CONFIG_IMPORT_FROM(mtx_common) |
| 349 | CONFIG_RAM_DEFAULT(64 * 1024) |
| 350 | CONFIG_RAM(96 * 1024) |
| 351 | CONFIG_RAM(128 * 1024) |
| 352 | SYSTEM_CONFIG_END |
| 353 | |
| 354 | |
| 355 | SYSTEM_CONFIG_START( mtx500 ) |
| 356 | CONFIG_IMPORT_FROM(mtx_common) |
| 357 | CONFIG_RAM_DEFAULT(32 * 1024) |
| 358 | CONFIG_RAM(64 * 1024) |
| 359 | CONFIG_RAM(96 * 1024) |
| 360 | CONFIG_RAM(128 * 1024) |
| 361 | SYSTEM_CONFIG_END |
| 362 | |
| 363 | SYSTEM_CONFIG_START( rs128 ) |
| 364 | CONFIG_IMPORT_FROM(mtx_common) |
| 365 | CONFIG_RAM_DEFAULT(128 * 1024) |
| 366 | SYSTEM_CONFIG_END |
| 367 | |
| 368 | |
| 369 | |
| 370 | /************************************* |
| 371 | * |
| 372 | * Driver definitions |
| 373 | * |
| 374 | *************************************/ |
| 375 | |
| 376 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG, COMPANY FULLNAME FLAGS */ |
| 377 | COMP( 1983, mtx512, 0, 0, mtx512, mtx512, 0, mtx512, "Memotech Ltd.", "MTX 512", 0 ) |
| 378 | COMP( 1983, mtx500, mtx512, 0, mtx512, mtx512, 0, mtx500, "Memotech Ltd.", "MTX 500", 0 ) |
| 379 | COMP( 1984, rs128, mtx512, 0, rs128, mtx512, rs128, rs128, "Memotech Ltd.", "RS 128", 0 ) |