src/mess/drivers/kaypro2.c
| r0 | r4484 | |
| 1 | /*************************************************************************************************
|
| 2 | |
| 3 | |
| 4 | Kaypro 2/83 computer - the very first Kaypro II - 2 full size floppy drives.
|
| 5 | Each disk was single sided, and could hold 191k. The computer had 2x pio
|
| 6 | and 1x sio. One of the sio ports communicated with the keyboard with a coiled
|
| 7 | telephone cord, complete with modular plug on each end. The keyboard carries
|
| 8 | its own processor and is an intelligent device.
|
| 9 | |
| 10 | There are 2 major problems preventing this driver from working
|
| 11 | |
| 12 | - MESS is not capable of conducting realtime serial communications between devices
|
| 13 | |
| 14 | - MAME's z80sio implementation is lacking important deatures:
|
| 15 | -- cannot change baud rate on the fly
|
| 16 | -- cannot specify different rates for each channel
|
| 17 | -- cannot specify different rates for Receive and Transmit
|
| 18 | -- the callback doesn't appear to support channel B ??
|
| 19 | |
| 20 | |
| 21 | Things that need doing:
|
| 22 | - How to specify interrupts in callbacks when a daisy-chain is in use?
|
| 23 | - Which order are devices to be specified in the daisy chain?
|
| 24 | - Keyboard is a separate device and not emulated (includes a beeper)
|
| 25 | - Floppy disks (I have no knowledge of how to set these up)
|
| 26 | - Bank switching
|
| 27 | - Rom SHA1s
|
| 28 | - Split this code to video, machine
|
| 29 | |
| 30 | This code has never been compiled. There will most likely be heaps of errors!
|
| 31 |
|
| 32 | **************************************************************************************************/
|
| 33 | |
| 34 | |
| 35 | #include "driver.h"
|
| 36 | #include "cpu/z80/z80.h"
|
| 37 | #include "cpu/z80/z80daisy.h"
|
| 38 | #include "machine/z80pio.h"
|
| 39 | #include "machine/z80sio.h"
|
| 40 | #include "machine/ctronics.h"
|
| 41 | #include "machine/wd17xx.h"
|
| 42 | #include "devices/basicdsk.h"
|
| 43 | //#include "machine/beeper.h"
|
| 44 | |
| 45 | |
| 46 | static const device_config *kaypro2_z80pio_g;
|
| 47 | static const device_config *kaypro2_z80pio_s;
|
| 48 | static const device_config *kaypro2_z80sio;
|
| 49 | //static const device_config *kaypro2_beeper;
|
| 50 | static const device_config *kaypro2_printer;
|
| 51 | static const device_config *kaypro2_fdc;
|
| 52 | |
| 53 | static printer_data;
|
| 54 | |
| 55 | |
| 56 | /***********************************************************
|
| 57 | |
| 58 | PIO
|
| 59 | |
| 60 | It seems there must have been a bulk-purchase
|
| 61 | special on pios - port B is unused on both of them
|
| 62 | |
| 63 | ************************************************************/
|
| 64 | |
| 65 | static WRITE8_DEVICE_HANDLER( pio_printer_w )
|
| 66 | {
|
| 67 | /* d7..d0 output to Centronics printer */
|
| 68 | |
| 69 | printer_data = data;
|
| 70 | }
|
| 71 | |
| 72 | static READ8_DEVICE_HANDLER( pio_system_r )
|
| 73 | {
|
| 74 | /* d3 Centronics ready flag */
|
| 75 | |
| 76 | return ~centronics_busy_r(kaypro2_printer) << 3;
|
| 77 | }
|
| 78 | |
| 79 | static WRITE8_DEVICE_HANDLER( pio_system_w )
|
| 80 | {
|
| 81 | /* d7 bank select
|
| 82 | d6 disk drive motors - not emulated
|
| 83 | d5 double-density enable
|
| 84 | d4 Centronics strobe
|
| 85 | d1 drive B
|
| 86 | d0 drive A */
|
| 87 | |
| 88 | /* get address space */
|
| 89 | const address_space *mem = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
| 90 | |
| 91 | if (data & 0x80)
|
| 92 | {
|
| 93 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP);
|
| 94 | memory_install_read8_handler (mem, 0x0000, 0x0fff, 0, 0, SMH_BANK1);
|
| 95 | memory_set_bankptr(mem->machine, 1, memory_region(mem->machine, "maincpu"+0x10000));
|
| 96 | memory_install_readwrite8_handler (mem, 0x3000, 0x3fff, 0, 0, kaypro2_videoram_r, kaypro2_videoram_w);
|
| 97 | }
|
| 98 | else
|
| 99 | {
|
| 100 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP);
|
| 101 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_BANK2, SMH_BANK3);
|
| 102 | memory_set_bankptr(mem->machine, 2, memory_region(mem->machine, "maincpu"));
|
| 103 | memory_set_bankptr(mem->machine, 3, memory_region(mem->machine, "maincpu"));
|
| 104 | }
|
| 105 | |
| 106 | wd17xx_set_density((data & 0x20) ? 1 : 0);
|
| 107 | |
| 108 | if (data & 0x10)
|
| 109 | {
|
| 110 | centronics_strobe_w(kaypro2_printer, 1);
|
| 111 | centronics_data_w(kaypro2_printer, 0, printer_data);
|
| 112 | }
|
| 113 | else
|
| 114 | centronics_strobe_w(kaypro2_printer, 0);
|
| 115 | |
| 116 | if (data & 1)
|
| 117 | wd17xx_set_drive(kaypro2_fdc, 0);
|
| 118 | else
|
| 119 | if (data & 2)
|
| 120 | wd17xx_set_drive(kaypro2_fdc, 1);
|
| 121 | |
| 122 | if (data & 3)
|
| 123 | wd17xx_set_side(kaypro2_fdc, 0); /* only has 1 side */
|
| 124 | }
|
| 125 | |
| 126 | static const z80pio_interface kaypro2_pio_g_intf =
|
| 127 | {
|
| 128 | DEVCB_NULL, /* callback when change interrupt status - assume this is handled by the daisy-chain? */
|
| 129 | DEVCB_NULL,
|
| 130 | DEVCB_NULL,
|
| 131 | DEVCB_HANDLER(pio_printer_w), /* output data to printer */
|
| 132 | DEVCB_NULL,
|
| 133 | DEVCB_NULL, /* portA ready active callback */
|
| 134 | DEVCB_NULL /* portB ready active callback */
|
| 135 | };
|
| 136 | |
| 137 | static const z80pio_interface kaypro_pio_s_intf =
|
| 138 | {
|
| 139 | DEVCB_NULL, /* callback when change interrupt status - assume this is handled by the daisy-chain? */
|
| 140 | DEVCB_HANDLER(pio_system_r), /* read printer status */
|
| 141 | DEVCB_NULL,
|
| 142 | DEVCB_HANDLER(pio_system_w), /* activate various internal devices */
|
| 143 | DEVCB_NULL,
|
| 144 | DEVCB_NULL, /* portA ready active callback */
|
| 145 | DEVCB_NULL /* portB ready active callback */
|
| 146 | };
|
| 147 | |
| 148 | READ8_DEVICE_HANDLER( kaypro2_pio_r )
|
| 149 | {
|
| 150 | if (!offset)
|
| 151 | return z80pio_d_r(device, 0);
|
| 152 | else
|
| 153 | if (offset == 1)
|
| 154 | return z80pio_c_r(device, 0);
|
| 155 | else
|
| 156 | if (offset == 2)
|
| 157 | return z80pio_d_r(device, 1);
|
| 158 | else
|
| 159 | return z80pio_c_r(device, 1);
|
| 160 | }
|
| 161 | |
| 162 | WRITE8_DEVICE_HANDLER( kaypro2_pio_w )
|
| 163 | {
|
| 164 | if (!offset)
|
| 165 | z80pio_d_w(device, 0, data);
|
| 166 | else
|
| 167 | if (offset == 1)
|
| 168 | z80pio_c_w(device, 0, data);
|
| 169 | else
|
| 170 | if (offset == 2)
|
| 171 | z80pio_d_w(device, 1, data);
|
| 172 | else
|
| 173 | z80pio_c_w(device, 1, data);
|
| 174 | }
|
| 175 | |
| 176 | /***********************************************************
|
| 177 | |
| 178 | SIO
|
| 179 | |
| 180 | ************************************************************/
|
| 181 | |
| 182 | static WRITE8_HANDLER( kaypro2_baud_w )
|
| 183 | {
|
| 184 | /* Set baud rate. bits 0..3 Rx and Tx are tied together. Baud Rate Generator is a AY-5-8116.
|
| 185 | 00h 50 |
| 186 | 11h 75 |
| 187 | 22h 110 |
| 188 | 33h 134.5 |
| 189 | 44h 150 |
| 190 | 55h 300 |
| 191 | 66h 600 |
| 192 | 77h 1200 |
| 193 | 88h 1800 |
| 194 | 99h 2000 |
| 195 | AAh 2400 |
| 196 | BBh 3600 |
| 197 | CCh 4800 |
| 198 | DDh 7200 |
| 199 | EEh 9600 |
| 200 | FFh 19200 */
|
| 201 | |
| 202 | int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 };
|
| 203 | |
| 204 | data &= 0x0f;
|
| 205 | |
| 206 | if (offset < 4)
|
| 207 | {
|
| 208 | /* channel A */
|
| 209 | // z80sio_set_rx_clock( kaypro2_z80sio, baud_clock[data], 0);
|
| 210 | // z80sio_set_tx_clock( kaypro2_z80sio, baud_clock[data], 0);
|
| 211 | }
|
| 212 | else
|
| 213 | {
|
| 214 | /* channel B */
|
| 215 | // z80sio_set_rx_clock( kaypro2_z80sio, baud_clock[data], 1);
|
| 216 | // z80sio_set_tx_clock( kaypro2_z80sio, baud_clock[data], 1);
|
| 217 | }
|
| 218 | }
|
| 219 | |
| 220 | |
| 221 | static const z80sio_interface kaypro2_sio_intf =
|
| 222 | {
|
| 223 | 0, /* interrupt handler - assume handled by daisy-chain? */
|
| 224 | 0, /* DTR changed handler */
|
| 225 | 0, /* RTS changed handler */
|
| 226 | 0, /* BREAK changed handler */
|
| 227 | 0, /* transmit handler - which channel is this for? */
|
| 228 | 0 /* receive handler - which channel is this for? */
|
| 229 | };
|
| 230 | |
| 231 | static const z80_daisy_chain kaypro2_daisy_chain[] =
|
| 232 | {
|
| 233 | /* Which order are these supposed to be in? assumed highest priority at the top */
|
| 234 | { "z80sio" }, /* sio */
|
| 235 | { "z80pio_s" }, /* System pio */
|
| 236 | { "z80pio_g" }, /* General purpose pio */
|
| 237 | { NULL }
|
| 238 | };
|
| 239 | |
| 240 | READ8_DEVICE_HANDLER( kaypro2_sio_r )
|
| 241 | {
|
| 242 | if (!offset)
|
| 243 | return z80sio_d_r(device, 0);
|
| 244 | else
|
| 245 | if (offset == 1)
|
| 246 | return z80sio_d_r(device, 1);
|
| 247 | else
|
| 248 | if (offset == 2)
|
| 249 | return z80sio_c_r(device, 0);
|
| 250 | else
|
| 251 | return z80sio_c_r(device, 1);
|
| 252 | }
|
| 253 | |
| 254 | WRITE8_DEVICE_HANDLER( kaypro2_sio_w )
|
| 255 | {
|
| 256 | if (!offset)
|
| 257 | z80sio_d_w(device, 0, data);
|
| 258 | else
|
| 259 | if (offset == 1)
|
| 260 | z80sio_d_w(device, 1, data);
|
| 261 | else
|
| 262 | if (offset == 2)
|
| 263 | z80sio_c_w(device, 0, data);
|
| 264 | else
|
| 265 | z80sio_c_w(device, 1, data);
|
| 266 | }
|
| 267 | |
| 268 | /***********************************************************
|
| 269 | |
| 270 | Address Maps
|
| 271 | |
| 272 | ************************************************************/
|
| 273 | |
| 274 | static ADDRESS_MAP_START( kaypro2_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 275 | AM_RANGE(0x1000, 0xffff) AM_RAM AM_REGION("maincpu", 0x1000)
|
| 276 | ADDRESS_MAP_END
|
| 277 | |
| 278 | static ADDRESS_MAP_START( kaypro2_io, ADDRESS_SPACE_IO, 8 )
|
| 279 | ADDRESS_MAP_GLOBAL_MASK(0xff)
|
| 280 | ADDRESS_MAP_UNMAP_HIGH
|
| 281 | AM_RANGE(0x00, 0x03) AM_WRITE(kaypro2_baud_w)
|
| 282 | AM_RANGE(0x04, 0x07) AM_DEVREADWRITE("z80sio", kaypro2_sio_r, kaypro2_sio_w)
|
| 283 | AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE("z80pio_g", kaypro2_pio_r, kaypro2_pio_w)
|
| 284 | AM_RANGE(0x0c, 0x0f) AM_WRITE(kaypro2_baud_w)
|
| 285 | AM_RANGE(0x10, 0x10) AM_DEVREADWRITE("wd1793", wd17xx_status_r, wd17xx_command_w)
|
| 286 | AM_RANGE(0x11, 0x11) AM_DEVREADWRITE("wd1793", wd17xx_track_r, wd17xx_track_w)
|
| 287 | AM_RANGE(0x12, 0x12) AM_DEVREADWRITE("wd1793", wd17xx_sector_r, wd17xx_sector_w)
|
| 288 | AM_RANGE(0x13, 0x13) AM_DEVREADWRITE("wd1793", wd17xx_data_r, wd17xx_data_w)
|
| 289 | AM_RANGE(0x1c, 0x1f) AM_DEVREADWRITE("z80pio_s", kaypro2_pio_r, kaypro2_pio_w)
|
| 290 | ADDRESS_MAP_END
|
| 291 | |
| 292 | /***********************************************************
|
| 293 | |
| 294 | Keyboard Layout
|
| 295 | |
| 296 | ************************************************************/
|
| 297 | |
| 298 | static INPUT_PORTS_START( kaypro2 )
|
| 299 | INPUT_PORTS_END
|
| 300 | |
| 301 | /***********************************************************
|
| 302 | |
| 303 | Video
|
| 304 | |
| 305 | ************************************************************/
|
| 306 | |
| 307 | static PALETTE_INIT( kaypro2 )
|
| 308 | {
|
| 309 | palette_set_color(machine,0,RGB_BLACK); /* black */
|
| 310 | palette_set_color(machine,1,MAKE_RGB(0, 200, 0)); /* green */
|
| 311 | }
|
| 312 | |
| 313 | static VIDEO_UPDATE( kaypro2 )
|
| 314 | {
|
| 315 | /* Bit 7 is the blink attribute */
|
| 316 | static UINT8 framecnt=0; /* exact flash rate not documented anywhere */
|
| 317 | UINT8 y,ra,chr,gfx,gfxbit;
|
| 318 | UINT16 sy=0,ma=0,x;
|
| 319 | UINT8 *FNT = memory_region(screen->machine, "gfx1");
|
| 320 | |
| 321 | framecnt++;
|
| 322 | |
| 323 | for (y = 0; y < 24; y++) /* could be 25 lines, depending on which document you read */
|
| 324 | {
|
| 325 | for (ra = 0; ra < 10; ra++)
|
| 326 | {
|
| 327 | UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
|
| 328 | |
| 329 | for (x = ma; x < ma + 80; x+=skip)
|
| 330 | {
|
| 331 | chr = videoram[x];
|
| 332 | |
| 333 | if ((chr < 0x80) || (framecnt & 0x10))
|
| 334 | chr |= 0x80;
|
| 335 | |
| 336 | /* get pattern of pixels for that character scanline */
|
| 337 | if (ra < 8) |
| 338 | gfx = FNT[(chr<<3) | ra ];
|
| 339 | else
|
| 340 | gfx = 0xff;
|
| 341 | |
| 342 | /* Display a scanline of a character (7 pixels) */
|
| 343 | *p = 0; p++;
|
| 344 | *p = ( gfx & 0x10 ) ? 0 : 1; p++;
|
| 345 | *p = ( gfx & 0x08 ) ? 0 : 1; p++;
|
| 346 | *p = ( gfx & 0x04 ) ? 0 : 1; p++;
|
| 347 | *p = ( gfx & 0x02 ) ? 0 : 1; p++;
|
| 348 | *p = ( gfx & 0x01 ) ? 0 : 1; p++;
|
| 349 | *p = 0; p++;
|
| 350 | }
|
| 351 | }
|
| 352 | }
|
| 353 | ma+=80;
|
| 354 | }
|
| 355 | return 0;
|
| 356 | }
|
| 357 | |
| 358 | /***********************************************************
|
| 359 | |
| 360 | Machine
|
| 361 | |
| 362 | ************************************************************/
|
| 363 | |
| 364 | static MACHINE_RESET( kaypro2 )
|
| 365 | {
|
| 366 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
| 367 | kaypro2_z80pio_g = devtag_get_device(machine, "z80pio_g");
|
| 368 | kaypro2_z80pio_s = devtag_get_device(machine, "z80pio_s");
|
| 369 | // kaypro2_beeper = devtag_get_device(machine, "beeper");
|
| 370 | kaypro2_printer = devtag_get_device(machine, "centronics");
|
| 371 | kaypro2_fdc = devtag_get_device(machine, "wd1793");
|
| 372 | pio_system_w(kaypro_z80pio_s, 0, 0x80);
|
| 373 | }
|
| 374 | |
| 375 | /***********************************************************
|
| 376 | |
| 377 | Machine Driver
|
| 378 | |
| 379 | ************************************************************/
|
| 380 | |
| 381 | static MACHINE_DRIVER_START( kaypro2 )
|
| 382 | /* basic machine hardware */
|
| 383 | MDRV_CPU_ADD("maincpu", Z80, 2500000) /* 2.5 MHz */
|
| 384 | MDRV_CPU_PROGRAM_MAP(kaypro2_map, 0)
|
| 385 | MDRV_CPU_IO_MAP(kaypro2_io, 0)
|
| 386 | |
| 387 | MDRV_MACHINE_RESET( kaypro2 )
|
| 388 | |
| 389 | /* video hardware */
|
| 390 | MDRV_SCREEN_ADD("screen", RASTER)
|
| 391 | MDRV_SCREEN_REFRESH_RATE(60)
|
| 392 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
|
| 393 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
|
| 394 | MDRV_SCREEN_SIZE(80*8, 25*10)
|
| 395 | MDRV_SCREEN_VISIBLE_AREA(0,80*8-1,0,25*10-1)
|
| 396 | MDRV_PALETTE_LENGTH(2)
|
| 397 | MDRV_PALETTE_INIT(kaypro2)
|
| 398 | |
| 399 | MDRV_VIDEO_UPDATE( kaypro2 )
|
| 400 | |
| 401 | /* sound hardware */
|
| 402 | // MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 403 | // MDRV_SOUND_ADD("beeper", BEEPER, 0)
|
| 404 | // MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
|
| 405 | |
| 406 | /* devices */
|
| 407 | MDRV_WD179X_ADD("wd1793", kaypro2_wd1793_interface )
|
| 408 | MDRV_CENTRONICS_ADD("centronics", standard_centronics)
|
| 409 | MDRV_Z80PIO_ADD( "z80pio_g", kaypro2_pio_g_intf )
|
| 410 | MDRV_Z80PIO_ADD( "z80pio_s", kaypro2_pio_s_intf )
|
| 411 | MDRV_Z80SIO_ADD( "z80sio", 4800, kaypro2_sio_intf ) /* start at 300 baud */
|
| 412 | MACHINE_DRIVER_END
|
| 413 | |
| 414 | /***********************************************************
|
| 415 | |
| 416 | Game driver
|
| 417 | |
| 418 | ************************************************************/
|
| 419 | |
| 420 | ROM_START(kaypro2) /* wrong sha1's here */
|
| 421 | /* The board could take a 2716 or 2732 */
|
| 422 | ROM_REGION(0x12000, "maincpu",0)
|
| 423 | ROM_LOAD("kaypro2.u47", 0x10000, 0x0800, CRC(28264bc1) SHA1(e84cf3121f9e0bb9e1b01b095f7a9581dcfaaae4))
|
| 424 | // ROM_LOAD("kaypro2.u47", 0x10000, 0x1000, CRC(4918fb91) SHA1(e84cf3121f9e0bb9e1b01b095f7a9581dcfaaae4))
|
| 425 | |
| 426 | ROM_REGION(0x01000, "gfx1",0)
|
| 427 | ROM_LOAD("kaypro2.u43", 0x00000, 0x0800, CRC(4cc7d206) SHA1(6361ee9667bf59d50059d09b0baf8672fdb2e8af))
|
| 428 | ROM_END
|
| 429 | |
| 430 | static DRIVER_INIT( lnw80 )
|
| 431 | {
|
| 432 | videoram = memory_region(machine, "maincpu")+0x11000;
|
| 433 | }
|
| 434 | |
| 435 | /* I have no idea how to set up floppies - these ones have 40 tracks, 10 sectors, 512 bytes per track, single sided */
|
| 436 | |
| 437 | static void kaypro2_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
|
| 438 | {
|
| 439 | /* floppy */
|
| 440 | switch(state)
|
| 441 | {
|
| 442 | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 443 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break;
|
| 444 | |
| 445 | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 446 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(kaypro2_floppy); break;
|
| 447 | |
| 448 | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 449 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break;
|
| 450 | |
| 451 | default: legacybasicdsk_device_getinfo(devclass, state, info); break;
|
| 452 | }
|
| 453 | }
|
| 454 | |
| 455 | static SYSTEM_CONFIG_START(kaypro2)
|
| 456 | CONFIG_DEVICE(kaypro2_floppy_getinfo)
|
| 457 | SYSTEM_CONFIG_END
|
| 458 | |
| 459 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */
|
| 460 | COMP( 1983, kaypro2, 0, 0, kaypro2, kaypro2, 0, kaypro2, "Non Linear Systems", "Kaypro 2/83" , GAME_NOT_WORKING )
|