src/mess/drivers/kaypro2.c
| r4484 | r4485 | |
| 23 | 23 | - Which order are devices to be specified in the daisy chain?
|
| 24 | 24 | - Keyboard is a separate device and not emulated (includes a beeper)
|
| 25 | 25 | - Floppy disks (I have no knowledge of how to set these up)
|
| 26 | | - Bank switching
|
| 27 | | - Rom SHA1s
|
| 28 | 26 | - Split this code to video, machine
|
| 29 | 27 | |
| 30 | | This code has never been compiled. There will most likely be heaps of errors!
|
| 31 | |
|
| 28 | |
| 32 | 29 | **************************************************************************************************/
|
| 33 | 30 | |
| 34 | 31 | |
| r4484 | r4485 | |
| 50 | 47 | static const device_config *kaypro2_printer;
|
| 51 | 48 | static const device_config *kaypro2_fdc;
|
| 52 | 49 | |
| 53 | | static printer_data;
|
| 50 | static UINT8 printer_data;
|
| 54 | 51 | |
| 55 | 52 | |
| 56 | 53 | /***********************************************************
|
| 57 | 54 | |
| 55 | Video
|
| 56 | |
| 57 | ************************************************************/
|
| 58 | |
| 59 | static PALETTE_INIT( kaypro2 )
|
| 60 | {
|
| 61 | palette_set_color(machine,0,RGB_BLACK); /* black */
|
| 62 | palette_set_color(machine,1,MAKE_RGB(0, 200, 0)); /* green */
|
| 63 | }
|
| 64 | |
| 65 | static VIDEO_UPDATE( kaypro2 )
|
| 66 | {
|
| 67 | /* The display consists of 80 columns and 24 rows. Each row is allocated 128 bytes of ram,
|
| 68 | but only the first 80 are used. The total video ram therefore is 0x0c00 bytes.
|
| 69 | There is one video attribute: bit 7 causes blinking. The first half of the
|
| 70 | character generator is blank, with the visible characters in the 2nd half.
|
| 71 | During the "off" period of blanking, the first half is used. Only 5 pixels are
|
| 72 | connected from the rom to the shift register, the remaining pixels are held high.
|
| 73 | A high pixel is black and a low pixel is green. */
|
| 74 | |
| 75 | static UINT8 framecnt=0;
|
| 76 | UINT8 y,ra,chr,gfx;
|
| 77 | UINT16 sy=0,ma=0,x;
|
| 78 | UINT8 *FNT = memory_region(screen->machine, "gfx1");
|
| 79 | |
| 80 | framecnt++;
|
| 81 | |
| 82 | for (y = 0; y < 24; y++)
|
| 83 | {
|
| 84 | for (ra = 0; ra < 10; ra++)
|
| 85 | {
|
| 86 | UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
|
| 87 | |
| 88 | for (x = ma; x < ma + 80; x++)
|
| 89 | {
|
| 90 | chr = videoram[x]^0x80;
|
| 91 | |
| 92 | if ((chr < 0x80) && (framecnt & 0x08))
|
| 93 | chr |= 0x80;
|
| 94 | |
| 95 | /* get pattern of pixels for that character scanline */
|
| 96 | if (ra < 8) |
| 97 | gfx = FNT[(chr<<3) | ra ];
|
| 98 | else
|
| 99 | gfx = 0xff;
|
| 100 | |
| 101 | /* Display a scanline of a character (7 pixels) */
|
| 102 | *p = 0; p++;
|
| 103 | *p = ( gfx & 0x10 ) ? 0 : 1; p++;
|
| 104 | *p = ( gfx & 0x08 ) ? 0 : 1; p++;
|
| 105 | *p = ( gfx & 0x04 ) ? 0 : 1; p++;
|
| 106 | *p = ( gfx & 0x02 ) ? 0 : 1; p++;
|
| 107 | *p = ( gfx & 0x01 ) ? 0 : 1; p++;
|
| 108 | *p = 0; p++;
|
| 109 | }
|
| 110 | }
|
| 111 | ma+=128;
|
| 112 | }
|
| 113 | return 0;
|
| 114 | }
|
| 115 | |
| 116 | static READ8_HANDLER( kaypro2_videoram_r )
|
| 117 | {
|
| 118 | return videoram[offset];
|
| 119 | }
|
| 120 | |
| 121 | static WRITE8_HANDLER( kaypro2_videoram_w )
|
| 122 | {
|
| 123 | videoram[offset] = data;
|
| 124 | }
|
| 125 | |
| 126 | |
| 127 | /***********************************************************
|
| 128 | |
| 58 | 129 | PIO
|
| 59 | 130 | |
| 60 | 131 | It seems there must have been a bulk-purchase
|
| r4484 | r4485 | |
| 92 | 163 | {
|
| 93 | 164 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP);
|
| 94 | 165 | memory_install_read8_handler (mem, 0x0000, 0x0fff, 0, 0, SMH_BANK1);
|
| 95 | | memory_set_bankptr(mem->machine, 1, memory_region(mem->machine, "maincpu"+0x10000));
|
| 166 | memory_set_bankptr(mem->machine, 1, memory_region(mem->machine, "maincpu"));
|
| 96 | 167 | memory_install_readwrite8_handler (mem, 0x3000, 0x3fff, 0, 0, kaypro2_videoram_r, kaypro2_videoram_w);
|
| 97 | 168 | }
|
| 98 | 169 | else
|
| 99 | 170 | {
|
| 100 | 171 | memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP);
|
| 101 | 172 | 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"));
|
| 173 | memory_set_bankptr(mem->machine, 2, memory_region(mem->machine, "rambank"));
|
| 174 | memory_set_bankptr(mem->machine, 3, memory_region(mem->machine, "rambank"));
|
| 104 | 175 | }
|
| 105 | 176 | |
| 106 | | wd17xx_set_density((data & 0x20) ? 1 : 0);
|
| 177 | wd17xx_set_density(kaypro2_fdc, (data & 0x20) ? 1 : 0);
|
| 107 | 178 | |
| 108 | 179 | if (data & 0x10)
|
| 109 | 180 | {
|
| r4484 | r4485 | |
| 134 | 205 | DEVCB_NULL /* portB ready active callback */
|
| 135 | 206 | };
|
| 136 | 207 | |
| 137 | | static const z80pio_interface kaypro_pio_s_intf =
|
| 208 | static const z80pio_interface kaypro2_pio_s_intf =
|
| 138 | 209 | {
|
| 139 | 210 | DEVCB_NULL, /* callback when change interrupt status - assume this is handled by the daisy-chain? */
|
| 140 | 211 | DEVCB_HANDLER(pio_system_r), /* read printer status */
|
| r4484 | r4485 | |
| 145 | 216 | DEVCB_NULL /* portB ready active callback */
|
| 146 | 217 | };
|
| 147 | 218 | |
| 148 | | READ8_DEVICE_HANDLER( kaypro2_pio_r )
|
| 219 | static READ8_DEVICE_HANDLER( kaypro2_pio_r )
|
| 149 | 220 | {
|
| 150 | 221 | if (!offset)
|
| 151 | 222 | return z80pio_d_r(device, 0);
|
| r4484 | r4485 | |
| 159 | 230 | return z80pio_c_r(device, 1);
|
| 160 | 231 | }
|
| 161 | 232 | |
| 162 | | WRITE8_DEVICE_HANDLER( kaypro2_pio_w )
|
| 233 | static WRITE8_DEVICE_HANDLER( kaypro2_pio_w )
|
| 163 | 234 | {
|
| 164 | 235 | if (!offset)
|
| 165 | 236 | z80pio_d_w(device, 0, data);
|
| r4484 | r4485 | |
| 199 | 270 | EEh 9600 |
| 200 | 271 | FFh 19200 */
|
| 201 | 272 | |
| 202 | | int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 };
|
| 273 | // int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 };
|
| 203 | 274 | |
| 204 | 275 | data &= 0x0f;
|
| 205 | 276 | |
| r4484 | r4485 | |
| 237 | 308 | { NULL }
|
| 238 | 309 | };
|
| 239 | 310 | |
| 240 | | READ8_DEVICE_HANDLER( kaypro2_sio_r )
|
| 311 | static READ8_DEVICE_HANDLER( kaypro2_sio_r )
|
| 241 | 312 | {
|
| 242 | 313 | if (!offset)
|
| 243 | 314 | return z80sio_d_r(device, 0);
|
| r4484 | r4485 | |
| 251 | 322 | return z80sio_c_r(device, 1);
|
| 252 | 323 | }
|
| 253 | 324 | |
| 254 | | WRITE8_DEVICE_HANDLER( kaypro2_sio_w )
|
| 325 | static WRITE8_DEVICE_HANDLER( kaypro2_sio_w )
|
| 255 | 326 | {
|
| 256 | 327 | if (!offset)
|
| 257 | 328 | z80sio_d_w(device, 0, data);
|
| r4484 | r4485 | |
| 265 | 336 | z80sio_c_w(device, 1, data);
|
| 266 | 337 | }
|
| 267 | 338 | |
| 339 | |
| 268 | 340 | /***********************************************************
|
| 269 | 341 | |
| 342 | Floppy DIsk
|
| 343 | |
| 344 | If there is no diskette in the drive, the cpu will
|
| 345 | HALT, until the fdc does a NMI. NMI is deactivated
|
| 346 | otherwise.
|
| 347 | |
| 348 | ************************************************************/
|
| 349 | |
| 350 | static WD17XX_CALLBACK( kaypro2_fdc_callback )
|
| 351 | {
|
| 352 | switch (state)
|
| 353 | {
|
| 354 | case WD17XX_DRQ_CLR:
|
| 355 | case WD17XX_IRQ_CLR:
|
| 356 | cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, 0);
|
| 357 | break;
|
| 358 | case WD17XX_DRQ_SET:
|
| 359 | case WD17XX_IRQ_SET:
|
| 360 | if (cpu_get_reg(device->machine->cpu[0], Z80_HALT))
|
| 361 | cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
|
| 362 | break;
|
| 363 | }
|
| 364 | }
|
| 365 | |
| 366 | static const wd17xx_interface kaypro2_wd1793_interface = { kaypro2_fdc_callback, NULL };
|
| 367 | |
| 368 | /* I have no idea how to set up floppies - these ones have 40 tracks, 10 sectors, 512 bytes per track, single sided */
|
| 369 | |
| 370 | static void kaypro2_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
|
| 371 | {
|
| 372 | /* floppy */
|
| 373 | switch(state)
|
| 374 | {
|
| 375 | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 376 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break;
|
| 377 | |
| 378 | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 379 | // case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(kaypro2_floppy); break;
|
| 380 | |
| 381 | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 382 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break;
|
| 383 | |
| 384 | default: legacybasicdsk_device_getinfo(devclass, state, info); break;
|
| 385 | }
|
| 386 | }
|
| 387 | |
| 388 | /***********************************************************
|
| 389 | |
| 270 | 390 | Address Maps
|
| 271 | 391 | |
| 272 | 392 | ************************************************************/
|
| 273 | 393 | |
| 274 | 394 | static ADDRESS_MAP_START( kaypro2_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 275 | | AM_RANGE(0x1000, 0xffff) AM_RAM AM_REGION("maincpu", 0x1000)
|
| 395 | AM_RANGE(0x0000, 0x0fff) AM_ROM AM_REGION("maincpu", 0x0000)
|
| 396 | AM_RANGE(0x3000, 0x3fff) AM_RAM AM_REGION("maincpu", 0x3000) AM_BASE(&videoram) AM_SIZE(&videoram_size)
|
| 397 | AM_RANGE(0x4000, 0xffff) AM_RAM AM_REGION("rambank", 0x4000)
|
| 276 | 398 | ADDRESS_MAP_END
|
| 277 | 399 | |
| 278 | 400 | static ADDRESS_MAP_START( kaypro2_io, ADDRESS_SPACE_IO, 8 )
|
| r4484 | r4485 | |
| 298 | 420 | static INPUT_PORTS_START( kaypro2 )
|
| 299 | 421 | INPUT_PORTS_END
|
| 300 | 422 | |
| 301 | | /***********************************************************
|
| 302 | 423 | |
| 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 | 424 | /***********************************************************
|
| 359 | 425 | |
| 360 | 426 | Machine
|
| r4484 | r4485 | |
| 363 | 429 | |
| 364 | 430 | static MACHINE_RESET( kaypro2 )
|
| 365 | 431 | {
|
| 366 | | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
| 367 | 432 | kaypro2_z80pio_g = devtag_get_device(machine, "z80pio_g");
|
| 368 | 433 | kaypro2_z80pio_s = devtag_get_device(machine, "z80pio_s");
|
| 434 | kaypro2_z80sio = devtag_get_device(machine, "z80sio");
|
| 369 | 435 | // kaypro2_beeper = devtag_get_device(machine, "beeper");
|
| 370 | 436 | kaypro2_printer = devtag_get_device(machine, "centronics");
|
| 371 | 437 | kaypro2_fdc = devtag_get_device(machine, "wd1793");
|
| 372 | | pio_system_w(kaypro_z80pio_s, 0, 0x80);
|
| 438 | pio_system_w(kaypro2_z80pio_s, 0, 0x80);
|
| 373 | 439 | }
|
| 374 | 440 | |
| 375 | 441 | /***********************************************************
|
| r4484 | r4485 | |
| 391 | 457 | MDRV_SCREEN_REFRESH_RATE(60)
|
| 392 | 458 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
|
| 393 | 459 | 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)
|
| 460 | MDRV_SCREEN_SIZE(80*7, 24*10)
|
| 461 | MDRV_SCREEN_VISIBLE_AREA(0,80*7-1,0,24*10-1)
|
| 396 | 462 | MDRV_PALETTE_LENGTH(2)
|
| 397 | 463 | MDRV_PALETTE_INIT(kaypro2)
|
| 398 | 464 | |
| r4484 | r4485 | |
| 417 | 483 | |
| 418 | 484 | ************************************************************/
|
| 419 | 485 | |
| 420 | | ROM_START(kaypro2) /* wrong sha1's here */
|
| 486 | ROM_START(kaypro2)
|
| 421 | 487 | /* 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))
|
| 488 | ROM_REGION(0x4000, "maincpu",0)
|
| 489 | ROM_LOAD("kaypro2.u47", 0x0000, 0x0800, CRC(28264bc1) SHA1(a12afb11a538fc0217e569bc29633d5270dfa51b))
|
| 490 | // ROM_LOAD("kaypro2.u47", 0x0000, 0x1000, CRC(4918fb91) SHA1(cd9f45cc3546bcaad7254b92c5d501c40e2ef0b2))
|
| 425 | 491 | |
| 426 | | ROM_REGION(0x01000, "gfx1",0)
|
| 427 | | ROM_LOAD("kaypro2.u43", 0x00000, 0x0800, CRC(4cc7d206) SHA1(6361ee9667bf59d50059d09b0baf8672fdb2e8af))
|
| 492 | ROM_REGION(0x10000, "rambank",0)
|
| 493 | ROM_FILL( 0, 0x10000, 0xff)
|
| 494 | |
| 495 | ROM_REGION(0x0800, "gfx1",0)
|
| 496 | ROM_LOAD("kaypro2.u43", 0x00000, 0x0800, CRC(4cc7d206) SHA1(5cb880083b94bd8220aac1f87d537db7cfeb9013))
|
| 428 | 497 | ROM_END
|
| 429 | 498 | |
| 430 | | static DRIVER_INIT( lnw80 )
|
| 431 | | {
|
| 432 | | videoram = memory_region(machine, "maincpu")+0x11000;
|
| 433 | | }
|
| 434 | 499 | |
| 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 | 500 | static SYSTEM_CONFIG_START(kaypro2)
|
| 456 | 501 | CONFIG_DEVICE(kaypro2_floppy_getinfo)
|
| 457 | 502 | SYSTEM_CONFIG_END
|