src/mess/machine/trs80.c
| r4459 | r4460 | |
| 48 | 48 | #define CASS_RISE 0x01 /* high speed cass on Model III/4) */ |
| 49 | 49 | #define CASS_FALL 0x02 /* high speed cass on Model III/4) */ |
| 50 | 50 | |
| 51 | | #define MAX_LUMPS 192 /* crude storage units - don't now much about it */ |
| 51 | #define MAX_LUMPS 192 /* crude storage units - don't know much about it */ |
| 52 | 52 | #define MAX_GRANULES 8 /* lumps consisted of granules.. aha */ |
| 53 | 53 | #define MAX_SECTORS 5 /* and granules of sectors */ |
| 54 | 54 | |
| r4459 | r4460 | |
| 237 | 237 | return INIT_PASS; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | | MACHINE_RESET( trs80 ) |
| 241 | | { |
| 242 | | cassette_data = 0; |
| 243 | | cassette_data_timer = timer_alloc(machine, cassette_data_callback, NULL ); |
| 244 | | timer_adjust_periodic( cassette_data_timer, attotime_zero, 0, ATTOTIME_IN_HZ(11025) ); |
| 245 | | trs80_printer = devtag_get_device(machine, "centronics"); |
| 246 | | trs80_ay31015 = devtag_get_device(machine, "tr1602"); |
| 247 | | trs80_cass = devtag_get_device(machine, "cassette"); |
| 248 | | trs80_speaker = devtag_get_device(machine, "speaker"); |
| 249 | | trs80_fdc = devtag_get_device(machine, "wd179x"); |
| 250 | | videoram_size = 0x800; |
| 251 | | trs80_reg_load = 1; /* for LNW80 */ |
| 252 | | } |
| 253 | 240 | |
| 254 | 241 | |
| 255 | | |
| 256 | 242 | /************************************* |
| 257 | 243 | * |
| 258 | 244 | * Port handlers. |
| 259 | 245 | * |
| 260 | 246 | *************************************/ |
| 261 | 247 | |
| 262 | | /* lnw80 can switch out all the devices, roms and video ram to be replaced by graphics ram. */ |
| 263 | | READ8_HANDLER( lnw80_r ) |
| 264 | | { |
| 265 | | UINT8 *ROM = memory_region(space->machine, "maincpu"); |
| 266 | | if (trs80_mode & 0x40) |
| 267 | | return gfxram[offset]; |
| 268 | | else |
| 269 | | if (offset <= 0x3000) |
| 270 | | return ROM[offset]; |
| 271 | | else |
| 272 | | if (offset < 0x37e4) |
| 273 | | return trs80_irq_status_r(space, 0); |
| 274 | | else |
| 275 | | if (offset < 0x37e8) |
| 276 | | return 0xff; |
| 277 | | else |
| 278 | | if (offset < 0x37ec) |
| 279 | | return trs80_printer_r(space, 0); |
| 280 | | else |
| 281 | | if (offset == 0x37ec) |
| 282 | | return trs80_wd179x_r(trs80_fdc, 0); |
| 283 | | else |
| 284 | | if (offset == 0x37ed) |
| 285 | | return wd17xx_track_r(trs80_fdc, 0); |
| 286 | | else |
| 287 | | if (offset == 0x37ee) |
| 288 | | return wd17xx_sector_r(trs80_fdc, 0); |
| 289 | | else |
| 290 | | if (offset == 0x37ef) |
| 291 | | return wd17xx_data_r(trs80_fdc, 0); |
| 292 | | else |
| 293 | | if (offset < 0x3800) |
| 294 | | return 0xff; |
| 295 | | else |
| 296 | | if (offset < 0x3c00) |
| 297 | | return trs80_keyboard_r(space, offset & 0xff); |
| 298 | | else |
| 299 | | return videoram[offset&0x3ff]; |
| 300 | | } |
| 301 | 248 | |
| 302 | | WRITE8_HANDLER( lnw80_w ) |
| 303 | | { |
| 304 | | if (trs80_mode & 0x40) |
| 305 | | gfxram[offset] = data; |
| 306 | | else |
| 307 | | if (offset < 0x37e0) |
| 308 | | return; |
| 309 | | else |
| 310 | | if (offset < 0x37e4) |
| 311 | | trs80_motor_w(space, 0, data); |
| 312 | | else |
| 313 | | if (offset < 0x37e8) |
| 314 | | return; |
| 315 | | else |
| 316 | | if (offset < 0x37ec) |
| 317 | | trs80_printer_w(space, 0, data); |
| 318 | | else |
| 319 | | if (offset == 0x37ec) |
| 320 | | wd17xx_command_w(trs80_fdc, 0, data); |
| 321 | | else |
| 322 | | if (offset == 0x37ed) |
| 323 | | wd17xx_track_w(trs80_fdc, 0, data); |
| 324 | | else |
| 325 | | if (offset == 0x37ee) |
| 326 | | wd17xx_sector_w(trs80_fdc, 0, data); |
| 327 | | else |
| 328 | | if (offset == 0x37ef) |
| 329 | | wd17xx_data_w(trs80_fdc, 0, data); |
| 330 | | else |
| 331 | | if (offset < 0x3c00) |
| 332 | | return; |
| 333 | | else |
| 334 | | videoram[offset&0x3ff]=data; |
| 335 | | } |
| 336 | | |
| 337 | | |
| 338 | 249 | READ8_HANDLER( trs80m4_e0_r ) |
| 339 | 250 | { |
| 340 | 251 | /* Indicates which devices are interrupting - d6..d3 not emulated. |
| r4459 | r4460 | |
| 511 | 422 | |
| 512 | 423 | WRITE8_HANDLER( trs80m4_e4_w ) |
| 513 | 424 | { |
| 514 | | /* Disk to NMI interface - not emulated |
| 425 | /* Disk to NMI interface |
| 515 | 426 | d7 1=enable disk INTRQ to generate NMI |
| 516 | 427 | d6 1=enable disk Motor Timeout to generate NMI */ |
| 517 | 428 | |
| r4459 | r4460 | |
| 667 | 578 | trs80_tape_unit = (data & 0x10) ? 2 : 1; |
| 668 | 579 | } |
| 669 | 580 | |
| 581 | /* lnw80 can switch out all the devices, roms and video ram to be replaced by graphics ram. */ |
| 670 | 582 | WRITE8_HANDLER( lnw80_fe_w ) |
| 671 | 583 | { |
| 672 | | /* d3..d2 not emulated |
| 584 | /* lnw80 video options |
| 673 | 585 | d3 bankswitch lower 16k between roms and hires ram (1=hires) |
| 674 | 586 | d2 enable colour \ |
| 675 | 587 | d1 hres / these 2 are the bits from the MODE command of LNWBASIC |
| 676 | 588 | d0 inverse video (entire screen) */ |
| 677 | 589 | |
| 590 | /* get address space instead of io space */ |
| 591 | const address_space *mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 592 | |
| 678 | 593 | trs80_mode = (trs80_mode & 0x87) | ((data & 0x0f) << 3); |
| 594 | |
| 595 | if (data & 8) |
| 596 | { |
| 597 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 598 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, trs80_gfxram_r, trs80_gfxram_w); |
| 599 | } |
| 600 | else |
| 601 | { |
| 602 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 603 | memory_install_read8_handler (mem, 0x0000, 0x2fff, 0, 0, SMH_BANK1); |
| 604 | memory_set_bankptr(mem->machine, 1, memory_region(mem->machine, "maincpu")); |
| 605 | memory_install_readwrite8_handler (mem, 0x37e0, 0x37e3, 0, 0, trs80_irq_status_r, trs80_motor_w); |
| 606 | memory_install_readwrite8_handler (mem, 0x37e8, 0x37eb, 0, 0, trs80_printer_r, trs80_printer_w); |
| 607 | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ec, 0x37ec, 0, 0, trs80_wd179x_r, wd17xx_command_w); |
| 608 | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ed, 0x37ed, 0, 0, wd17xx_track_r, wd17xx_track_w); |
| 609 | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ee, 0x37ee, 0, 0, wd17xx_sector_r, wd17xx_sector_w); |
| 610 | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ef, 0x37ef, 0, 0, wd17xx_data_r, wd17xx_data_w); |
| 611 | memory_install_read8_handler (mem, 0x3800, 0x38ff, 0, 0x0300, trs80_keyboard_r); |
| 612 | memory_install_readwrite8_handler (mem, 0x3c00, 0x3fff, 0, 0, trs80_videoram_r, trs80_videoram_w); |
| 613 | } |
| 679 | 614 | } |
| 680 | 615 | |
| 681 | 616 | WRITE8_HANDLER( trs80_ff_w ) |
| r4459 | r4460 | |
| 882 | 817 | } |
| 883 | 818 | |
| 884 | 819 | /************************************* |
| 885 | | * Keyboard * |
| 820 | * Keyboard * |
| 886 | 821 | *************************************/ |
| 887 | 822 | READ8_HANDLER( trs80_keyboard_r ) |
| 888 | 823 | { |
| r4459 | r4460 | |
| 909 | 844 | } |
| 910 | 845 | |
| 911 | 846 | |
| 847 | /************************************* |
| 848 | * Machine * |
| 849 | *************************************/ |
| 850 | |
| 851 | MACHINE_RESET( trs80 ) |
| 852 | { |
| 853 | cassette_data = 0; |
| 854 | cassette_data_timer = timer_alloc(machine, cassette_data_callback, NULL ); |
| 855 | timer_adjust_periodic( cassette_data_timer, attotime_zero, 0, ATTOTIME_IN_HZ(11025) ); |
| 856 | trs80_printer = devtag_get_device(machine, "centronics"); |
| 857 | trs80_ay31015 = devtag_get_device(machine, "tr1602"); |
| 858 | trs80_cass = devtag_get_device(machine, "cassette"); |
| 859 | trs80_speaker = devtag_get_device(machine, "speaker"); |
| 860 | trs80_fdc = devtag_get_device(machine, "wd179x"); |
| 861 | videoram_size = 0x800; |
| 862 | } |
| 863 | |
| 864 | MACHINE_RESET( lnw80 ) |
| 865 | { |
| 866 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 867 | MACHINE_RESET_CALL(trs80); |
| 868 | trs80_reg_load = 1; /* for LNW80 */ |
| 869 | lnw80_fe_w(space, 0, 0); |
| 870 | } |
| 871 | |
src/mess/drivers/trs80.c
| r4459 | r4460 | |
| 43 | 43 | Model I level II and all clones - 500 baud |
| 44 | 44 | Model III/4 - 500 and 1500 baud selectable at boot time |
| 45 | 45 | - When it says "Cass?" press L for 500 baud, or Enter otherwise. |
| 46 | LNW-80 - 500 baud @1.77MHz and 1000 baud @4MHz. |
| 46 | 47 | |
| 47 | 48 | I/O ports |
| 48 | 49 | FF: |
| r4459 | r4460 | |
| 120 | 121 | TRS80 Japanese kana/ascii switch and alternate keyboard |
| 121 | 122 | TRS80 Model III/4 Hard drive, Graphics board, Alternate Character set |
| 122 | 123 | LNW80 1.77 / 4.0 MHz switch (this is a physical switch) |
| 123 | | LNW80 Colour board |
| 124 | | LNW80 Hires graphics |
| 125 | | LNW80 24x80 screen |
| 126 | 124 | |
| 127 | 125 | ***************************************************************************/ |
| 128 | 126 | |
| r4459 | r4460 | |
| 141 | 139 | |
| 142 | 140 | /* Devices */ |
| 143 | 141 | #include "devices/basicdsk.h" |
| 142 | #include "devices/mflopimg.h" |
| 144 | 143 | #include "devices/cassette.h" |
| 145 | 144 | #include "formats/trs_cas.h" |
| 145 | #include "formats/trs_dsk.h" |
| 146 | 146 | |
| 147 | 147 | UINT8 *gfxram; |
| 148 | 148 | UINT8 trs80_model4; |
| r4459 | r4460 | |
| 190 | 190 | ADDRESS_MAP_END |
| 191 | 191 | |
| 192 | 192 | static ADDRESS_MAP_START( lnw80_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 193 | | AM_RANGE(0x0000, 0x3fff) AM_READWRITE(lnw80_r, lnw80_w) |
| 194 | 193 | AM_RANGE(0x4000, 0xffff) AM_RAM |
| 195 | 194 | ADDRESS_MAP_END |
| 196 | 195 | |
| r4459 | r4460 | |
| 482 | 481 | MDRV_CPU_MODIFY( "maincpu" ) |
| 483 | 482 | MDRV_CPU_PROGRAM_MAP( lnw80_map, 0 ) |
| 484 | 483 | MDRV_CPU_IO_MAP( lnw80_io, 0 ) |
| 484 | MDRV_MACHINE_RESET( lnw80 ) |
| 485 | 485 | |
| 486 | 486 | MDRV_PALETTE_LENGTH(8) |
| 487 | 487 | MDRV_PALETTE_INIT(lnw80) |
| r4459 | r4460 | |
| 662 | 662 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(trs80_floppy); break; |
| 663 | 663 | |
| 664 | 664 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 665 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 665 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk,dmk"); break; |
| 666 | 666 | |
| 667 | // case MESS_DEVINFO_PTR_FLOPPY_OPTIONS: info->p = (void *) floppyoptions_trs80; break; |
| 668 | |
| 667 | 669 | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 668 | 670 | } |
| 669 | 671 | } |