src/mess/drivers/v1050.c
| r5186 | r5187 | |
| 11 | 11 | TODO: |
| 12 | 12 | |
| 13 | 13 | - video |
| 14 | | - memory banking |
| 15 | 14 | - µPB8214 chip |
| 16 | 15 | - RTC58321 chip |
| 17 | 16 | - floppy |
| r5186 | r5187 | |
| 26 | 25 | #include "cpu/z80/z80.h" |
| 27 | 26 | #include "cpu/m6502/m6502.h" |
| 28 | 27 | #include "cpu/mcs48/mcs48.h" |
| 28 | #include "devices/basicdsk.h" |
| 29 | #include "machine/ctronics.h" |
| 30 | #include "machine/8255ppi.h" |
| 29 | 31 | #include "machine/msm8251.h" |
| 30 | | #include "machine/8255ppi.h" |
| 31 | 32 | #include "machine/wd17xx.h" |
| 32 | 33 | #include "video/mc6845.h" |
| 33 | 34 | |
| 35 | INLINE const device_config *get_floppy_image(running_machine *machine, int drive) |
| 36 | { |
| 37 | return image_from_devtype_and_index(machine, IO_FLOPPY, drive); |
| 38 | } |
| 39 | |
| 40 | static void v1050_bankswitch(running_machine *machine) |
| 41 | { |
| 42 | v1050_state *state = machine->driver_data; |
| 43 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 44 | |
| 45 | int bank = (state->bank >> 1) & 0x03; |
| 46 | |
| 47 | if (BIT(state->bank, 0)) |
| 48 | { |
| 49 | memory_install_readwrite8_handler(program, 0x0000, 0x1fff, 0, 0, SMH_BANK(1), SMH_BANK(1)); |
| 50 | memory_set_bank(machine, 1, bank); |
| 51 | } |
| 52 | else |
| 53 | { |
| 54 | memory_install_readwrite8_handler(program, 0x0000, 0x1fff, 0, 0, SMH_BANK(1), SMH_UNMAP); |
| 55 | memory_set_bank(machine, 1, 3); |
| 56 | } |
| 57 | |
| 58 | memory_set_bank(machine, 2, bank); |
| 59 | |
| 60 | if (bank == 2) |
| 61 | { |
| 62 | memory_install_readwrite8_handler(program, 0x4000, 0xbfff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | memory_install_readwrite8_handler(program, 0x4000, 0x7fff, 0, 0, SMH_BANK(3), SMH_BANK(3)); |
| 67 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK(4), SMH_BANK(4)); |
| 68 | memory_set_bank(machine, 3, bank); |
| 69 | memory_set_bank(machine, 4, bank); |
| 70 | } |
| 71 | |
| 72 | memory_set_bank(machine, 5, bank); |
| 73 | } |
| 74 | |
| 34 | 75 | /* Read/Write Handlers */ |
| 35 | 76 | |
| 36 | 77 | static WRITE8_HANDLER( dvint_clr_w ) |
| r5186 | r5187 | |
| 38 | 79 | cputag_set_input_line(space->machine, M6502_TAG, INPUT_LINE_IRQ0, CLEAR_LINE); |
| 39 | 80 | } |
| 40 | 81 | |
| 82 | static WRITE8_HANDLER( bank_w ) |
| 83 | { |
| 84 | v1050_state *state = space->machine->driver_data; |
| 85 | |
| 86 | state->bank = data; |
| 87 | |
| 88 | v1050_bankswitch(space->machine); |
| 89 | } |
| 90 | |
| 41 | 91 | /* Memory Maps */ |
| 42 | 92 | |
| 43 | 93 | static ADDRESS_MAP_START( v1050_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 44 | 94 | ADDRESS_MAP_UNMAP_HIGH |
| 45 | | AM_RANGE(0x0000, 0x1fff) AM_ROM |
| 46 | | AM_RANGE(0x2000, 0xffff) AM_RAM |
| 95 | AM_RANGE(0x0000, 0x1fff) AM_RAMBANK(1) |
| 96 | AM_RANGE(0x2000, 0x3fff) AM_RAMBANK(2) |
| 97 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(3) |
| 98 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK(4) |
| 99 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK(5) |
| 47 | 100 | ADDRESS_MAP_END |
| 48 | 101 | |
| 49 | 102 | static ADDRESS_MAP_START( v1050_io, ADDRESS_SPACE_IO, 8 ) |
| r5186 | r5187 | |
| 59 | 112 | // AM_RANGE(0xa0, 0xa0) AM_READWRITE(vint_clr_r, vint_clr_w) |
| 60 | 113 | // AM_RANGE(0xb0, 0xb0) AM_READWRITE(dint_clr_r, dint_clr_w) |
| 61 | 114 | // AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE(UPB8214_TAG, pic8214_r, pic8214_w) |
| 62 | | // AM_RANGE(0xd0, 0xd0) AM_WRITE(bank_w) |
| 115 | AM_RANGE(0xd0, 0xd0) AM_WRITE(bank_w) |
| 63 | 116 | // AM_RANGE(0xe0, 0xe1) AM_READWRITE(sasi_r, sasi_w) |
| 64 | 117 | ADDRESS_MAP_END |
| 65 | 118 | |
| 66 | 119 | static ADDRESS_MAP_START( v1050_crt_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 67 | 120 | AM_RANGE(0x0000, 0x1fff) AM_RAM |
| 68 | | AM_RANGE(0x2000, 0x7fff) AM_RAM AM_BASE_MEMBER(v1050_state, video_ram) |
| 121 | AM_RANGE(0x2000, 0x7fff) AM_RAM AM_READWRITE(v1050_videoram_r, v1050_videoram_w) AM_BASE_MEMBER(v1050_state, video_ram) |
| 69 | 122 | AM_RANGE(0x8000, 0x8000) AM_DEVWRITE(HD6845_TAG, mc6845_address_w) |
| 70 | 123 | AM_RANGE(0x8001, 0x8001) AM_DEVREADWRITE(HD6845_TAG, mc6845_register_r, mc6845_register_w) |
| 71 | 124 | // AM_RANGE(0x9000, 0x9003) AM_DEVREADWRITE(CRT_M6502_PPI8255_TAG, ppi8255_r, ppi8255_w) |
| 72 | | // AM_RANGE(0xa000, 0xa000) AM_WRITE(attr_w) |
| 125 | AM_RANGE(0xa000, 0xa000) AM_READWRITE(v1050_attr_r, v1050_attr_w) |
| 73 | 126 | // AM_RANGE(0xb000, 0xb000) AM_WRITE(z80int_w) |
| 74 | 127 | AM_RANGE(0xc000, 0xc000) AM_WRITE(dvint_clr_w) |
| 75 | 128 | AM_RANGE(0xe000, 0xffff) AM_ROM |
| r5186 | r5187 | |
| 205 | 258 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) |
| 206 | 259 | INPUT_PORTS_END |
| 207 | 260 | |
| 261 | /* Miscellanous 8255A Interface */ |
| 262 | |
| 263 | static WRITE8_DEVICE_HANDLER( misc_ppi8255_a_w ) |
| 264 | { |
| 265 | /* |
| 266 | |
| 267 | bit signal description |
| 268 | |
| 269 | PA0 f_ds<0> drive 0 select |
| 270 | PA1 f_ds<1> drive 1 select |
| 271 | PA2 f_ds<2> drive 2 select |
| 272 | PA3 f_ds<3> drive 3 select |
| 273 | PA4 f_side_1 floppy side select |
| 274 | PA5 f_pre_comp precompensation |
| 275 | PA6 f_motor_on* floppy motor |
| 276 | PA7 f_dden* double density select |
| 277 | |
| 278 | */ |
| 279 | |
| 280 | v1050_state *state = device->machine->driver_data; |
| 281 | |
| 282 | int f_motor_on = !BIT(data, 6); |
| 283 | |
| 284 | /* floppy drive select */ |
| 285 | if (BIT(data, 0)) wd17xx_set_drive(state->mb8877, 0); |
| 286 | if (BIT(data, 1)) wd17xx_set_drive(state->mb8877, 1); |
| 287 | if (BIT(data, 2)) wd17xx_set_drive(state->mb8877, 2); |
| 288 | if (BIT(data, 3)) wd17xx_set_drive(state->mb8877, 3); |
| 289 | |
| 290 | /* floppy side select */ |
| 291 | wd17xx_set_side(state->mb8877, BIT(data, 4)); |
| 292 | |
| 293 | /* floppy motor */ |
| 294 | floppy_drive_set_motor_state(get_floppy_image(device->machine, 0), f_motor_on); |
| 295 | floppy_drive_set_motor_state(get_floppy_image(device->machine, 1), f_motor_on); |
| 296 | floppy_drive_set_ready_state(get_floppy_image(device->machine, 0), f_motor_on, 1); |
| 297 | floppy_drive_set_ready_state(get_floppy_image(device->machine, 1), f_motor_on, 1); |
| 298 | |
| 299 | /* density select */ |
| 300 | wd17xx_set_density(state->mb8877, BIT(data, 7) ? DEN_FM_LO : DEN_FM_HI); |
| 301 | } |
| 302 | |
| 303 | static READ8_DEVICE_HANDLER( misc_ppi8255_c_r ) |
| 304 | { |
| 305 | /* |
| 306 | |
| 307 | bit signal description |
| 308 | |
| 309 | PC0 pr_strobe printer strobe |
| 310 | PC1 f_int_enb floppy interrupt enable |
| 311 | PC2 baud_sel_a |
| 312 | PC3 baud_sel_b |
| 313 | PC4 pr_busy* printer busy |
| 314 | PC5 pr_pe* printer paper end |
| 315 | PC6 |
| 316 | PC7 |
| 317 | |
| 318 | */ |
| 319 | |
| 320 | v1050_state *state = device->machine->driver_data; |
| 321 | |
| 322 | UINT8 data = 0; |
| 323 | |
| 324 | data |= centronics_busy_r(state->centronics) << 4; |
| 325 | data |= centronics_pe_r(state->centronics) << 5; |
| 326 | |
| 327 | return data; |
| 328 | } |
| 329 | |
| 330 | static WRITE8_DEVICE_HANDLER( misc_ppi8255_c_w ) |
| 331 | { |
| 332 | /* |
| 333 | |
| 334 | bit signal description |
| 335 | |
| 336 | PC0 pr_strobe |
| 337 | PC1 f_int_enb |
| 338 | PC2 baud_sel_a |
| 339 | PC3 baud_sel_b |
| 340 | PC4 pr_busy* |
| 341 | PC5 pr_pe* |
| 342 | PC6 |
| 343 | PC7 |
| 344 | |
| 345 | */ |
| 346 | |
| 347 | v1050_state *state = device->machine->driver_data; |
| 348 | |
| 349 | /* printer strobe */ |
| 350 | centronics_strobe_w(state->centronics, BIT(data, 0)); |
| 351 | |
| 352 | /* floppy interrupt enable */ |
| 353 | state->f_int_enb = BIT(data, 1); |
| 354 | } |
| 355 | |
| 356 | static const ppi8255_interface misc_ppi8255_intf = |
| 357 | { |
| 358 | DEVCB_NULL, // Port A read |
| 359 | DEVCB_NULL, // Port B read |
| 360 | DEVCB_HANDLER(misc_ppi8255_c_r), // Port C read |
| 361 | DEVCB_HANDLER(misc_ppi8255_a_w), // Port A write |
| 362 | DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w),// Port B write |
| 363 | DEVCB_HANDLER(misc_ppi8255_c_w) // Port C write |
| 364 | }; |
| 365 | |
| 208 | 366 | /* MB8877 Interface */ |
| 209 | 367 | |
| 210 | 368 | static WD17XX_CALLBACK( v1050_mb8877_callback ) |
| r5186 | r5187 | |
| 241 | 399 | static MACHINE_START( v1050 ) |
| 242 | 400 | { |
| 243 | 401 | v1050_state *state = machine->driver_data; |
| 402 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 244 | 403 | |
| 245 | 404 | /* find devices */ |
| 246 | 405 | state->upb8214 = devtag_get_device(machine, UPB8214_TAG); |
| 406 | state->mb8877 = devtag_get_device(machine, MB8877_TAG); |
| 407 | state->centronics = devtag_get_device(machine, CENTRONICS_TAG); |
| 247 | 408 | |
| 248 | 409 | /* setup memory banking */ |
| 410 | memory_configure_bank(machine, 1, 0, 2, mess_ram, 0x10000); |
| 411 | memory_configure_bank(machine, 1, 2, 1, mess_ram + 0x1c000, 0); |
| 412 | memory_configure_bank(machine, 1, 3, 1, memory_region(machine, Z80_TAG), 0); |
| 249 | 413 | |
| 414 | memory_install_readwrite8_handler(program, 0x2000, 0x3fff, 0, 0, SMH_BANK(2), SMH_BANK(2)); |
| 415 | memory_configure_bank(machine, 2, 0, 2, mess_ram + 0x2000, 0x10000); |
| 416 | memory_configure_bank(machine, 2, 2, 1, mess_ram + 0x1e000, 0); |
| 417 | |
| 418 | memory_install_readwrite8_handler(program, 0x4000, 0x7fff, 0, 0, SMH_BANK(3), SMH_BANK(3)); |
| 419 | memory_configure_bank(machine, 3, 0, 2, mess_ram + 0x4000, 0x10000); |
| 420 | |
| 421 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK(4), SMH_BANK(4)); |
| 422 | memory_configure_bank(machine, 4, 0, 2, mess_ram + 0x8000, 0x10000); |
| 423 | |
| 424 | memory_install_readwrite8_handler(program, 0xc000, 0xffff, 0, 0, SMH_BANK(5), SMH_BANK(5)); |
| 425 | memory_configure_bank(machine, 5, 0, 3, mess_ram + 0xc000, 0); |
| 426 | |
| 427 | v1050_bankswitch(machine); |
| 428 | |
| 250 | 429 | /* register for state saving */ |
| 251 | 430 | // state_save_register_global(machine, state->); |
| 252 | 431 | } |
| r5186 | r5187 | |
| 263 | 442 | |
| 264 | 443 | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_15_36MHz/16) |
| 265 | 444 | MDRV_CPU_PROGRAM_MAP(v1050_crt_mem) |
| 266 | | |
| 445 | /* |
| 267 | 446 | MDRV_CPU_ADD(I8049_TAG, I8049, XTAL_4_608MHz) |
| 268 | 447 | MDRV_CPU_IO_MAP(v1050_kbd_io) |
| 269 | | |
| 448 | */ |
| 270 | 449 | MDRV_MACHINE_START(v1050) |
| 271 | 450 | |
| 272 | 451 | /* video hardware */ |
| 273 | 452 | MDRV_IMPORT_FROM(v1050_video) |
| 274 | 453 | |
| 275 | 454 | /* devices */ |
| 455 | MDRV_PPI8255_ADD(FDC_PPI8255_TAG, misc_ppi8255_intf) |
| 276 | 456 | MDRV_WD1793_ADD(MB8877_TAG, v1050_wd17xx_intf ) |
| 457 | |
| 458 | /* printer */ |
| 459 | MDRV_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics) |
| 277 | 460 | MACHINE_DRIVER_END |
| 278 | 461 | |
| 279 | 462 | /* ROMs */ |
| r5186 | r5187 | |
| 292 | 475 | |
| 293 | 476 | /* System Configuration */ |
| 294 | 477 | |
| 478 | static DEVICE_IMAGE_LOAD( v1050_floppy ) |
| 479 | { |
| 480 | if (image_has_been_created(image)) |
| 481 | return INIT_FAIL; |
| 482 | |
| 483 | return INIT_FAIL; |
| 484 | } |
| 485 | |
| 486 | static void v1050_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 487 | { |
| 488 | switch(state) |
| 489 | { |
| 490 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 491 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 492 | |
| 493 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 494 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(v1050_floppy); break; |
| 495 | |
| 496 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 497 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 498 | |
| 499 | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 500 | } |
| 501 | } |
| 502 | |
| 295 | 503 | static SYSTEM_CONFIG_START( v1050 ) |
| 296 | 504 | CONFIG_RAM_DEFAULT( 128 * 1024 ) |
| 505 | CONFIG_DEVICE(v1050_floppy_getinfo) |
| 297 | 506 | SYSTEM_CONFIG_END |
| 298 | 507 | |
| 299 | 508 | /* System Drivers */ |