src/mess/machine/ti99_4x.c
| r8156 | r8157 | |
| 273 | 273 | |
| 274 | 274 | static void create_grom_high2k(int first, int last) |
| 275 | 275 | { |
| 276 | | /* Generate missing chunk of each console GROMs. Although a GROM |
| 277 | | occupies 8 KiB of address space, it only has 6 KiB capacity, and |
| 278 | | the last 2 KiB mirror previous content as shown above. */ |
| 279 | | int base; |
| 280 | | for (base=(first&0xe000); base<((last+1)&0xe000); base+=0x2000) |
| 281 | | { |
| 282 | | int j; |
| 283 | | for (j=0; j<0x800; j++) |
| 284 | | { |
| 285 | | console_GROMs.data_ptr[base+0x1800+j] = |
| 286 | | console_GROMs.data_ptr[base+0x0800+j] |
| 287 | | | console_GROMs.data_ptr[base+0x1000+j]; |
| 288 | | } |
| 289 | | } |
| 276 | /* Generate missing chunk of each console GROMs. Although a GROM */ |
| 277 | /* occupies 8 KiB of address space, it only has 6 KiB capacity, and */ |
| 278 | /* the last 2 KiB mirror previous content as shown above. */ |
| 279 | int base; |
| 280 | for (base=(first&0xe000); base<((last+1)&0xe000); base+=0x2000) |
| 281 | { |
| 282 | int j; |
| 283 | for (j=0; j<0x800; j++) |
| 284 | { |
| 285 | console_GROMs.data_ptr[base+0x1800+j] = |
| 286 | console_GROMs.data_ptr[base+0x0800+j] |
| 287 | | console_GROMs.data_ptr[base+0x1000+j]; |
| 288 | } |
| 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | int ti99_is_99_8() |
| r8156 | r8157 | |
| 375 | 375 | |
| 376 | 376 | MACHINE_START( ti99_4_60hz ) |
| 377 | 377 | { |
| 378 | | ti99_common_init(machine, &tms9918_interface); |
| 378 | ti99_common_init(machine, &tms9918_interface); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | static const TMS9928a_interface tms9929_interface = |
| r8156 | r8157 | |
| 388 | 388 | |
| 389 | 389 | MACHINE_START( ti99_4_50hz ) |
| 390 | 390 | { |
| 391 | | ti99_common_init(machine, &tms9929_interface); |
| 391 | ti99_common_init(machine, &tms9929_interface); |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | static const TMS9928a_interface tms9918a_interface = |
| r8156 | r8157 | |
| 414 | 414 | |
| 415 | 415 | MACHINE_START( ti99_4a_50hz ) |
| 416 | 416 | { |
| 417 | | ti99_common_init(machine, &tms9929a_interface); |
| 417 | ti99_common_init(machine, &tms9929a_interface); |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | MACHINE_START( ti99_4ev_60hz) |
| r8156 | r8157 | |
| 428 | 428 | if (gfxparm != 0) |
| 429 | 429 | TMS9928A_configure(gfxparm); |
| 430 | 430 | |
| 431 | | /* Initialize all. Actually, at this point, we don't know |
| 432 | | how the switches are set. Later we use the configuration switches to |
| 433 | | determine which one to use. */ |
| 431 | /* Initialize all. Actually, at this point, we don't know */ |
| 432 | /* how the switches are set. Later we use the configuration switches */ |
| 433 | /* to determine which one to use. */ |
| 434 | 434 | ti99_peb_init(); |
| 435 | 435 | ti99_floppy_controllers_init_all(machine); |
| 436 | 436 | ti99_ide_init(machine); |
| 437 | 437 | ti99_hsgpl_init(machine); |
| 438 | 438 | ti99_usbsm_init(machine); |
| 439 | 439 | |
| 440 | | /* Find the cartslot device and cache it. This is a string search, |
| 441 | | and we don't want to repeat it on each memory access. */ |
| 440 | /* Find the cartslot device and cache it. This is a string search, */ |
| 441 | /* and we don't want to repeat it on each memory access. */ |
| 442 | 442 | cartslots = devtag_get_device(machine, "ti99_multicart"); |
| 443 | 443 | assert(cartslots != NULL); |
| 444 | 444 | } |
| r8156 | r8157 | |
| 485 | 485 | #endif |
| 486 | 486 | |
| 487 | 487 | if (!has_evpc) TMS9928A_reset(); |
| 488 | | else v9938_reset(0); |
| 488 | else v9938_reset(0); |
| 489 | 489 | |
| 490 | 490 | /* clear keyboard interface state (probably overkill, but can't harm) */ |
| 491 | 491 | KeyCol = 0; |
| r8156 | r8157 | |
| 536 | 536 | if (ti99_model == model_99_4p) |
| 537 | 537 | ti99_4p_internal_dsr_reset(machine); |
| 538 | 538 | |
| 539 | | if (has_speech) |
| 539 | if (has_speech) |
| 540 | 540 | { |
| 541 | 541 | static const spchroms_interface speech_intf = { region_speech_rom }; |
| 542 | 542 | |
| r8156 | r8157 | |
| 893 | 893 | { |
| 894 | 894 | if (! tms5220_readyq_r()) |
| 895 | 895 | { |
| 896 | | /* Weirdly enough, we are always seeing some problems even though |
| 897 | | everything is working fine. */ |
| 896 | /* Weirdly enough, we are always seeing some problems even */ |
| 897 | /* though everything is working fine. */ |
| 898 | 898 | attotime time_to_ready = double_to_attotime(tms5220_time_to_ready()); |
| 899 | 899 | logerror("ti99/4a speech says aaargh!\n"); |
| 900 | 900 | logerror("(time to ready: %f -> %d)\n", time_to_ready, (int) ceil(3000000*time_to_ready)); |
| r8156 | r8157 | |
| 911 | 911 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-(54+3)); /* this is just an approx. minimum, it can be much more */ |
| 912 | 912 | |
| 913 | 913 | #if 1 |
| 914 | | /* the stupid design of the tms5220 core means that ready is cleared when |
| 915 | | there are 15 bytes in FIFO. It should be 16. Of course, if it were the |
| 916 | | case, we would need to store the value on the bus, which would be more |
| 917 | | complex. */ |
| 914 | /* the stupid design of the tms5220 core means that ready is cleared */ |
| 915 | /* when there are 15 bytes in FIFO. It should be 16. Of course, if */ |
| 916 | /* it were the case, we would need to store the value on the bus, */ |
| 917 | /* which would be more complex. */ |
| 918 | 918 | if (! tms5220_readyq_r(devtag_get_device(space->machine, "tmc0285"))) |
| 919 | 919 | { |
| 920 | 920 | attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tmc0285"))); |
| r8156 | r8157 | |
| 937 | 937 | |
| 938 | 938 | if (console_GROMs.addr < 0x6000) |
| 939 | 939 | { |
| 940 | | /* GROMs are buffered. Data is retrieved from a buffer, |
| 941 | | while the buffer is replaced with the next cell |
| 942 | | content. */ |
| 940 | /* GROMs are buffered. Data is retrieved from a buffer, */ |
| 941 | /* while the buffer is replaced with the next cell content. */ |
| 943 | 942 | reply = console_GROMs.buf; |
| 944 | 943 | |
| 945 | | /* Get next value, put it in buffer. Note that the |
| 946 | | GROM wraps at 8K boundaries. */ |
| 944 | /* Get next value, put it in buffer. Note that the GROM */ |
| 945 | /* wraps at 8K boundaries. */ |
| 947 | 946 | console_GROMs.buf = console_GROMs.data_ptr[console_GROMs.addr]; |
| 948 | 947 | // printf("GROM address (cons) = %04x, offset = %04x, reply = %02x\n", console_GROMs.addr, offset, reply); |
| 949 | 948 | } |
| 950 | 949 | |
| 951 | | /* The address pointer in the cartridge system is updated by this call. |
| 952 | | We pretend to do a data read, so we mask away the address bit in the |
| 953 | | offset. */ |
| 950 | /* The address pointer in the cartridge system is updated by this */ |
| 951 | /* call. We pretend to do a data read, so we mask away the address */ |
| 952 | /* bit in the offset. */ |
| 954 | 953 | replycart = ti99_cartridge_grom_r(cartslots, offset&0xfffc); |
| 955 | 954 | |
| 956 | 955 | if (console_GROMs.addr >= 0x6000 || override_console) |
| r8156 | r8157 | |
| 958 | 957 | reply = replycart; |
| 959 | 958 | } |
| 960 | 959 | |
| 961 | | /* Each GROM chip has its own counter, so we update all of them even |
| 962 | | when we do not access them. */ |
| 963 | | /* The program counter wraps at each GROM chip size (8K), |
| 964 | | so 0x5fff + 1 = 0x4000. */ |
| 960 | /* Each GROM chip has its own counter, so we update all of them even */ |
| 961 | /* when we do not access them. */ |
| 962 | /* The program counter wraps at each GROM chip size (8K), */ |
| 963 | /* so 0x5fff + 1 = 0x4000. */ |
| 965 | 964 | console_GROMs.addr = ((console_GROMs.addr + 1) & 0x1FFF) | (console_GROMs.addr & 0xE000); |
| 966 | 965 | |
| 967 | 966 | /* Reset the read and write address flipflops. */ |
| r8156 | r8157 | |
| 980 | 979 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4 /*20+3*/); /* from 4 to 23? */ |
| 981 | 980 | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 982 | 981 | |
| 983 | | /* This implementation features a multislot cartridge system which |
| 984 | | is based on multiple GROM base addresses. The standard base |
| 985 | | is >9800 (slot 0). When we access the port >9804, we switch to |
| 986 | | slot 1, >9808 is slot 2, ... >983C is slot 15. Although theoretically |
| 987 | | we could address up to 256 banks, the TI operating system does not |
| 988 | | check more than 16 banks. |
| 989 | | Cartridges may also contain ROMs which need to be banked |
| 990 | | simultaneously. We use the cartridge slot number to swap the ROM at |
| 991 | | >6000, or RAM if available. I don't know whether this is the way |
| 992 | | Texas Instruments envisaged it in the OS, but it is the only |
| 993 | | plausible way to allow for GROM+ROM cartridges. |
| 994 | | Note that some cartridges may have programming flaws which only |
| 995 | | appear when the cartridge is used in a higher-numbered slot. |
| 996 | | Parsec is one example which only runs in slot 0 as the |
| 997 | | programmers hard-coded an access to GROM port 0. Note: This *may* |
| 998 | | be worked around if we make sure that switching only occurs |
| 999 | | when the address is set, not when data is read or written. But |
| 1000 | | it's not clear whether this has unwanted side effects. |
| 1001 | | */ |
| 982 | /* This implementation features a multislot cartridge system which */ |
| 983 | /* is based on multiple GROM base addresses. The standard base */ |
| 984 | /* is >9800 (slot 0). When we access the port >9804, we switch to */ |
| 985 | /* slot 1, >9808 is slot 2, ... >983C is slot 15. Although */ |
| 986 | /* theoretically we could address up to 256 banks, the TI operating */ |
| 987 | /* system does not check more than 16 banks. */ |
| 988 | /* Cartridges may also contain ROMs which need to be banked */ |
| 989 | /* simultaneously. We use the cartridge slot number to swap the ROM */ |
| 990 | /* at >6000, or RAM if available. I don't know whether this is the */ |
| 991 | /* way Texas Instruments envisaged it in the OS, but it is the only */ |
| 992 | /* plausible way to allow for GROM+ROM cartridges. */ |
| 993 | /* Note that some cartridges may have programming flaws which only */ |
| 994 | /* appear when the cartridge is used in a higher-numbered slot. */ |
| 995 | /* Parsec is one example which only runs in slot 0 as the */ |
| 996 | /* programmers hard-coded an access to GROM port 0. Note: This *may* */ |
| 997 | /* be worked around if we make sure that switching only occurs */ |
| 998 | /* when the address is set, not when data is read or written. But */ |
| 999 | /* it's not clear whether this has unwanted side effects. */ |
| 1002 | 1000 | |
| 1003 | 1001 | if (offset & 1) |
| 1004 | 1002 | { /* Read GROM address |