src/mess/drivers/psion.c
| r8688 | r8689 | |
| 23 | 23 | #include "emu.h" |
| 24 | 24 | #include "cpu/m6800/m6800.h" |
| 25 | 25 | #include "sound/beep.h" |
| 26 | #include "devices/cartslot.h" |
| 26 | 27 | |
| 28 | struct datapack |
| 29 | { |
| 30 | UINT8 id; |
| 31 | UINT8 len; |
| 32 | UINT16 counter; |
| 33 | UINT8* data; |
| 34 | }; |
| 35 | |
| 27 | 36 | static struct _psion |
| 28 | 37 | { |
| 29 | 38 | UINT8 kb_counter; |
| r8688 | r8689 | |
| 37 | 46 | UINT8 ram_bank; |
| 38 | 47 | UINT8 ram_bank_count; |
| 39 | 48 | UINT8 rom_bank_count; |
| 49 | |
| 50 | UINT8 port2_ddr; |
| 51 | UINT8 port6_ddr; |
| 52 | UINT8 port6; |
| 53 | |
| 54 | struct datapack pack1; |
| 55 | struct datapack pack2; |
| 40 | 56 | } psion; |
| 41 | 57 | |
| 42 | 58 | /************************************************* |
| r8688 | r8689 | |
| 271 | 287 | } |
| 272 | 288 | } |
| 273 | 289 | |
| 290 | void datapack_w(running_machine *machine, UINT8 data) |
| 291 | { |
| 292 | //TODO |
| 293 | } |
| 294 | |
| 295 | UINT8 datapack_r(running_machine *machine) |
| 296 | { |
| 297 | if (!(psion.port6 & 0x80)) |
| 298 | { |
| 299 | if (!(psion.port6 & 0x10) && psion.pack1.len > 0) |
| 300 | return psion.pack1.data[psion.pack1.counter]; |
| 301 | else if (!(psion.port6 & 0x20) && psion.pack2.len > 0) |
| 302 | return psion.pack2.data[psion.pack2.counter]; |
| 303 | } |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 274 | 308 | WRITE8_HANDLER( hd63701_int_reg_w ) |
| 275 | 309 | { |
| 276 | 310 | switch (offset) |
| 277 | 311 | { |
| 312 | case 0x01: |
| 313 | psion.port2_ddr = data; |
| 314 | break; |
| 315 | case 0x03: |
| 316 | /* datapack i/o data bus */ |
| 317 | datapack_w(space->machine, data); |
| 318 | break; |
| 278 | 319 | case 0x08: |
| 279 | 320 | psion.tcsr_value = data; |
| 280 | 321 | break; |
| 322 | case 0x16: |
| 323 | psion.port6_ddr = data; |
| 324 | break; |
| 325 | case 0x17: |
| 326 | /* |
| 327 | datapack control lines |
| 328 | x--- ---- slot on/off |
| 329 | -x-- ---- slot 3 |
| 330 | --x- ---- slot 2 |
| 331 | ---x ---- slot 1 |
| 332 | ---- x--- output enable |
| 333 | ---- -x-- program line |
| 334 | ---- --x- reset line |
| 335 | ---- ---x clock line |
| 336 | */ |
| 337 | if (psion.port6_ddr == 0xff) |
| 338 | { |
| 339 | if ((psion.port6 & 0x01) != (data & 0x01)) |
| 340 | { |
| 341 | if (!(data & 0x10)) |
| 342 | psion.pack1.counter++; |
| 343 | else if (!(data & 0x20)) |
| 344 | psion.pack2.counter++; |
| 345 | |
| 346 | if (psion.pack1.counter >= psion.pack1.len * 0x2000) |
| 347 | psion.pack1.counter -= 0x2000; |
| 348 | } |
| 349 | |
| 350 | if (psion.port6 & 0x02) |
| 351 | { |
| 352 | if (!(data & 0x10)) |
| 353 | psion.pack1.counter = 0; |
| 354 | else if (!(data & 0x20)) |
| 355 | psion.pack2.counter = 0; |
| 356 | } |
| 357 | |
| 358 | psion.port6 = data; |
| 359 | } |
| 360 | break; |
| 281 | 361 | } |
| 282 | 362 | |
| 283 | 363 | hd63701_internal_registers_w(space, offset, data); |
| r8688 | r8689 | |
| 287 | 367 | { |
| 288 | 368 | switch (offset) |
| 289 | 369 | { |
| 370 | case 0x03: |
| 371 | /* datapack i/o data bus */ |
| 372 | return datapack_r(space->machine); |
| 290 | 373 | case 0x15: |
| 291 | 374 | /* |
| 292 | 375 | x--- ---- ON key active high |
| r8688 | r8689 | |
| 295 | 378 | ---- ---x battery status |
| 296 | 379 | */ |
| 297 | 380 | return kb_read(space->machine) | input_port_read(space->machine, "BATTERY") | input_port_read(space->machine, "ON"); |
| 381 | case 0x17: |
| 382 | return psion.port6; |
| 298 | 383 | case 0x08: |
| 299 | 384 | hd63701_internal_registers_w(space, offset, psion.tcsr_value); |
| 300 | 385 | default: |
| r8688 | r8689 | |
| 496 | 581 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D [)]") PORT_CODE(KEYCODE_D) |
| 497 | 582 | INPUT_PORTS_END |
| 498 | 583 | |
| 584 | static DEVICE_IMAGE_LOAD( psion_pack1 ) |
| 585 | { |
| 586 | running_machine *machine = image.device().machine; |
| 587 | char opk_head[6]; |
| 588 | |
| 589 | image.fread(opk_head, 6); |
| 590 | image.fread(&psion.pack1.id, 1); |
| 591 | image.fread(&psion.pack1.len, 1); |
| 592 | |
| 593 | if(strcmp(opk_head, "OPK") || psion.pack1.len * 0x2000 < image.length() - 6) |
| 594 | return IMAGE_INIT_FAIL; |
| 595 | |
| 596 | image.fseek(6, SEEK_SET); |
| 597 | psion.pack1.data = auto_alloc_array(machine, UINT8, psion.pack1.len * 0x2000); |
| 598 | memset(psion.pack1.data, 0xff, psion.pack1.len * 0x2000); |
| 599 | image.fread(psion.pack1.data, image.length() - 6); |
| 600 | |
| 601 | return IMAGE_INIT_PASS; |
| 602 | } |
| 603 | |
| 604 | static DEVICE_IMAGE_UNLOAD( psion_pack1 ) |
| 605 | { |
| 606 | auto_free(image.device().machine, psion.pack1.data); |
| 607 | memset(&psion.pack1, 0, sizeof(psion.pack1)); |
| 608 | } |
| 609 | |
| 499 | 610 | static MACHINE_START(psion) |
| 500 | 611 | { |
| 501 | 612 | if (!strcmp(machine->gamedrv->name, "psionlam")) |
| r8688 | r8689 | |
| 602 | 713 | *BITMAP_ADDR16(bitmap, (cur_y-1) * 9 + l, cur_x*6 + i) = 1; |
| 603 | 714 | } |
| 604 | 715 | |
| 605 | | #if(1) |
| 716 | #if(0) |
| 606 | 717 | popmessage("cur: %u, pos %u, shift %u", hd44780.cursor_on, hd44780.ddram_a, hd44780.disp_shift); |
| 607 | 718 | #endif |
| 608 | 719 | return 0; |
| r8688 | r8689 | |
| 673 | 784 | *BITMAP_ADDR16(bitmap, (cur_y-1) * 9 + l, cur_x*6 + i) = 1; |
| 674 | 785 | } |
| 675 | 786 | |
| 676 | | #if(1) |
| 787 | #if(0) |
| 677 | 788 | popmessage("cur: %u, pos %u, shift %u", hd44780.cursor_on, hd44780.cursor_pos, hd44780.disp_shift); |
| 678 | 789 | #endif |
| 679 | 790 | return 0; |
| r8688 | r8689 | |
| 700 | 811 | GFXDECODE_ENTRY( "chargen", 0x0000, psion_charlayout, 0, 1 ) |
| 701 | 812 | GFXDECODE_END |
| 702 | 813 | |
| 814 | |
| 815 | static MACHINE_DRIVER_START( psion_slot ) |
| 816 | /* Datapack slot 1 */ |
| 817 | MDRV_CARTSLOT_ADD("pack1") |
| 818 | MDRV_CARTSLOT_EXTENSION_LIST("opk") |
| 819 | MDRV_CARTSLOT_NOT_MANDATORY |
| 820 | MDRV_CARTSLOT_LOAD(psion_pack1) |
| 821 | MDRV_CARTSLOT_UNLOAD(psion_pack1) |
| 822 | MACHINE_DRIVER_END |
| 823 | |
| 703 | 824 | /* basic configuration for 2 lines display */ |
| 704 | 825 | static MACHINE_DRIVER_START( psion_2lines ) |
| 705 | 826 | /* basic machine hardware */ |
| r8688 | r8689 | |
| 728 | 849 | MDRV_SOUND_ADD( "beep", BEEP, 0 ) |
| 729 | 850 | MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 ) |
| 730 | 851 | |
| 852 | MDRV_IMPORT_FROM( psion_slot ) |
| 731 | 853 | MACHINE_DRIVER_END |
| 732 | 854 | |
| 733 | 855 | /* basic configuration for 4 lines display */ |
| r8688 | r8689 | |
| 757 | 879 | MDRV_SPEAKER_STANDARD_MONO( "mono" ) |
| 758 | 880 | MDRV_SOUND_ADD( "beep", BEEP, 0 ) |
| 759 | 881 | MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 ) |
| 882 | |
| 883 | MDRV_IMPORT_FROM( psion_slot ) |
| 760 | 884 | MACHINE_DRIVER_END |
| 761 | 885 | |
| 762 | 886 | static MACHINE_DRIVER_START( psioncm ) |