src/mess/devices/ti99cart.c
| r8282 | r8283 | |
| 320 | 320 | // Handle the GRAM Kracker |
| 321 | 321 | if ((cartslots->gk_slot != -1) && (input_port_read(device->machine, "CARTSLOT")==CART_GK)) |
| 322 | 322 | cartridge_gram_kracker_writeg(device,data); |
| 323 | |
| 324 | cartslots->grom_address = ((cartslots->grom_address + 1) & 0x1FFF) | (cartslots->grom_address & 0xE000); |
| 325 | |
| 326 | /* Reset the read and write address flipflops. */ |
| 327 | cartslots->raddr_LSB = cartslots->waddr_LSB = FALSE; |
| 323 | 328 | } |
| 324 | 329 | } |
| 325 | 330 | |
| r8282 | r8283 | |
| 434 | 439 | //printf("Empty socket at address G(%d)>%04x\n", slot, cartslots->grom_address); |
| 435 | 440 | } |
| 436 | 441 | } |
| 437 | | // printf("GROM address (cart) = %04x, reply = %02x\n", cartslots->grom_address, value); |
| 438 | 442 | /* The program counter wraps at each GROM chip size (8K), */ |
| 439 | 443 | /* so 0x5fff + 1 = 0x4000. */ |
| 440 | 444 | /* The address must be increased even if there is no cartridge slot */ |
| r8282 | r8283 | |
| 2217 | 2221 | value = (UINT8)cartslots->grom_buffer; |
| 2218 | 2222 | /* read ahead */ |
| 2219 | 2223 | cartslots->grom_buffer = cartridge->grom_ptr[cartslots->grom_address-0x6000]; |
| 2220 | | // printf("GROM address = %04x, reply = %02x\n", console_GROMs.addr, reply>>8); |
| 2221 | 2224 | // The program counter wraps at each GROM chip size (8K), |
| 2222 | 2225 | // so 0x5fff + 1 = 0x4000. |
| 2223 | 2226 | cartslots->grom_address = ((cartslots->grom_address + 1) & 0x1FFF) | (cartslots->grom_address & 0xE000); |
| r8282 | r8283 | |
| 2550 | 2553 | cartslots->cartridge[id].rom_ptr = cartrom; |
| 2551 | 2554 | cartslots->cartridge[id].rom_size = filesize; |
| 2552 | 2555 | } |
| 2553 | | // printf("loaded ROM, size = %d\n", filesize); |
| 2554 | 2556 | break; |
| 2555 | 2557 | |
| 2556 | 2558 | case SLOTC_MINIMEM: |
| r8282 | r8283 | |
| 2570 | 2572 | cartslots->cartridge[id].ram_ptr = (UINT16 *)cartrom + 0x800; |
| 2571 | 2573 | } |
| 2572 | 2574 | cartslots->cartridge[id].ram_size = 0x1000; |
| 2573 | | // printf("loaded NVRAM\n"); |
| 2574 | 2575 | break; |
| 2575 | 2576 | |
| 2576 | 2577 | case SLOTC_MBX: |
| r8282 | r8283 | |
| 2608 | 2609 | cartslots->cartridge[id].rom2_ptr = cartrom2; |
| 2609 | 2610 | } |
| 2610 | 2611 | cartslots->cartridge[id].rom_size = filesize; |
| 2611 | | // printf("loaded second ROM, size = %d\n", filesize); |
| 2612 | 2612 | break; |
| 2613 | 2613 | } |
| 2614 | 2614 | return INIT_PASS; |
| r8282 | r8283 | |
| 2725 | 2725 | static DEVICE_START(ti99_multicart) |
| 2726 | 2726 | { |
| 2727 | 2727 | int i; |
| 2728 | | // printf("DEVICE_START(ti99_multicart)\n"); |
| 2729 | 2728 | ti99_multicart_state *cartslots = (ti99_multicart_state *)device->token; |
| 2730 | 2729 | |
| 2731 | 2730 | cartslots->active_slot = 0; |
| r8282 | r8283 | |
| 2882 | 2881 | { |
| 2883 | 2882 | if (!slot_is_empty(device, slot)) |
| 2884 | 2883 | { |
| 2885 | | // printf("writing to cartridge in slot %d\n", slot); |
| 2886 | 2884 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 2887 | 2885 | (*pcbdef->write)(cart->pcb, offset, data, mem_mask); |
| 2888 | 2886 | } |
| r8282 | r8283 | |
| 3000 | 2998 | |
| 3001 | 2999 | if (!slot_is_empty(device, slot)) |
| 3002 | 3000 | { |
| 3003 | | // printf("accessing cartridge in slot %d\n", slot); |
| 3004 | 3001 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 3005 | 3002 | return (*pcbdef->read8)(cart->pcb, offset); |
| 3006 | 3003 | } |
| 3007 | 3004 | else |
| 3008 | 3005 | { |
| 3009 | | // printf("No cartridge in slot %d\n", slot); |
| 3010 | 3006 | return 0; |
| 3011 | 3007 | } |
| 3012 | 3008 | } |
| r8282 | r8283 | |
| 3164 | 3160 | if (get_gk_switch(4)!=GK_WP) |
| 3165 | 3161 | { |
| 3166 | 3162 | // Write protection off |
| 3167 | | if (((cartslots->grom_address < 0x2000) |
| 3163 | if (((write_addr < 0x2000) |
| 3168 | 3164 | && (get_gk_switch(2)==GK_GRAM0)) |
| 3169 | | || ((cartslots->grom_address >= 0x2000) && (cartslots->grom_address < 0x4000) |
| 3165 | || ((write_addr >= 0x2000) && (write_addr < 0x4000) |
| 3170 | 3166 | && (get_gk_switch(3)==GK_GRAM12) |
| 3171 | 3167 | && (get_gk_switch(5)==GK_LDOFF)) |
| 3172 | | || ((cartslots->grom_address >= 0x4000) && (cartslots->grom_address < 0x6000) |
| 3168 | || ((write_addr >= 0x4000) && (write_addr < 0x6000) |
| 3173 | 3169 | && (get_gk_switch(3)==GK_GRAM12)) |
| 3174 | | || ((cartslots->grom_address >= 0x6000) && (cartslots->gk_guest_slot==-1) |
| 3170 | || ((write_addr >= 0x6000) && (cartslots->gk_guest_slot==-1) |
| 3175 | 3171 | && (get_gk_switch(1)==GK_NORMAL))) |
| 3176 | 3172 | { |
| 3177 | 3173 | ((UINT8 *)gkcartridge->ram_ptr)[write_addr] = data; |
| 3178 | 3174 | } |
| 3179 | 3175 | // There is no GRAM in cartridges |
| 3180 | | |
| 3181 | 3176 | } |
| 3182 | | cartslots->grom_address = ((cartslots->grom_address + 1) & 0x1FFF) | (cartslots->grom_address & 0xE000); |
| 3183 | | |
| 3184 | | /* Reset the read and write address flipflops. */ |
| 3185 | | cartslots->raddr_LSB = cartslots->waddr_LSB = FALSE; |
| 3186 | 3177 | } |
| 3187 | 3178 | |
| 3188 | 3179 | /* |
src/mess/machine/ti99_4x.c
| r8282 | r8283 | |
| 454 | 454 | /* Initialize all. Actually, at this point, we don't know */ |
| 455 | 455 | /* how the switches are set. Later we use the configuration switches */ |
| 456 | 456 | /* to determine which one to use. */ |
| 457 | | ti99_peb_init(); |
| 458 | 457 | ti99_floppy_controllers_init_all(machine); |
| 459 | 458 | ti99_ide_init(machine); |
| 460 | 459 | ti99_hsgpl_init(machine); |
| r8282 | r8283 | |
| 475 | 474 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 476 | 475 | /*console_GROMs.data_ptr = memory_region(machine, region_grom);*/ |
| 477 | 476 | console_GROMs.addr = 0; |
| 477 | console_GROMs.buf = 0; |
| 478 | console_GROMs.raddr_LSB = FALSE; |
| 479 | console_GROMs.waddr_LSB = FALSE; |
| 478 | 480 | |
| 479 | 481 | if (ti99_model == model_99_8) |
| 480 | 482 | { |
| r8282 | r8283 | |
| 543 | 545 | has_pcode = input_port_read(machine, "EXTCARD") & EXT_PCODE; |
| 544 | 546 | |
| 545 | 547 | /* Get the GK settings once */ |
| 546 | | gk_switch[1] = input_port_read(machine, "GKSWITCH1"); |
| 547 | | gk_switch[2] = input_port_read(machine, "GKSWITCH2"); |
| 548 | | gk_switch[3] = input_port_read(machine, "GKSWITCH3"); |
| 549 | | gk_switch[4] = input_port_read(machine, "GKSWITCH4"); |
| 550 | | gk_switch[5] = input_port_read(machine, "GKSWITCH5"); |
| 548 | if (ti99_model != model_99_4p) |
| 549 | { |
| 550 | gk_switch[1] = input_port_read(machine, "GKSWITCH1"); |
| 551 | gk_switch[2] = input_port_read(machine, "GKSWITCH2"); |
| 552 | gk_switch[3] = input_port_read(machine, "GKSWITCH3"); |
| 553 | gk_switch[4] = input_port_read(machine, "GKSWITCH4"); |
| 554 | gk_switch[5] = input_port_read(machine, "GKSWITCH5"); |
| 555 | } |
| 551 | 556 | |
| 552 | | /* set up optional expansion hardware */ |
| 557 | // Removes all card handlers |
| 558 | ti99_peb_init(); |
| 559 | |
| 560 | // set up optional expansion hardware |
| 553 | 561 | ti99_peb_reset(ti99_model == model_99_4p, tms9901_set_int1, NULL); |
| 554 | 562 | |
| 555 | 563 | if (ti99_model == model_99_8) |
| r8282 | r8283 | |
| 673 | 681 | else |
| 674 | 682 | filename = "hsgpl40.nv"; |
| 675 | 683 | |
| 676 | | if ((ti99_model == model_99_4p) || (input_port_read(machine, "EXTCARD") & (EXT_HSGPL_ON | EXT_HSGPL_FLASH))) |
| 684 | // We always try to read the HSGPL, even when the config switch is |
| 685 | // set to off. Otherwise, when the system is started without HSGPL |
| 686 | // and we later switch on the card and do a reset, the console locks |
| 687 | // up as it does not find any content. Likewise, we save the contents |
| 688 | // even when the card has been turned off during runtime. |
| 689 | if (read_or_write==0) |
| 677 | 690 | { |
| 678 | | if (read_or_write==0) |
| 679 | | { |
| 680 | | ti99_hsgpl_load_flashroms(machine, filename); |
| 681 | | } |
| 682 | | else |
| 683 | | { |
| 684 | | ti99_hsgpl_save_flashroms(machine, filename); |
| 685 | | } |
| 691 | ti99_hsgpl_load_flashroms(machine, filename); |
| 686 | 692 | } |
| 693 | else |
| 694 | { |
| 695 | ti99_hsgpl_save_flashroms(machine, filename); |
| 696 | } |
| 687 | 697 | } |
| 688 | 698 | |
| 689 | 699 | INPUT_CHANGED( hsgpl_changed ) |
| r8282 | r8283 | |
| 1044 | 1054 | console_GROMs.buf = console_GROMs.data_ptr[console_GROMs.addr]; |
| 1045 | 1055 | } |
| 1046 | 1056 | |
| 1047 | | // The address pointer in the cartridge system is updated by this call. |
| 1057 | // The address pointer in the cartridge system is updated by this call |
| 1048 | 1058 | replycart = ti99_cartridge_grom_r(cartslots, offset); |
| 1049 | 1059 | |
| 1050 | 1060 | if (console_GROMs.addr >= 0x6000 || override_console) |
| r8282 | r8283 | |
| 1141 | 1151 | console_GROMs.raddr_LSB = TRUE; |
| 1142 | 1152 | } |
| 1143 | 1153 | /* GROM address values must be globally unique. */ |
| 1144 | | // FIXME: Parsec in slot 2 asserts here (bug in Parsec, but |
| 1145 | | // should never bring the emulation into trouble) |
| 1146 | | // last actions were invalid reads from 99fa |
| 1147 | 1154 | // FIXME: HSGPL asserts here when switched on during runtime |
| 1148 | 1155 | // You should not do that, but again the emulation should |
| 1149 | 1156 | // not assert either |
| r8282 | r8283 | |
| 1255 | 1262 | assert (replycart == reply); |
| 1256 | 1263 | } |
| 1257 | 1264 | else |
| 1265 | { |
| 1258 | 1266 | reply = GROM_dataread(space->machine, offset); |
| 1259 | | |
| 1267 | } |
| 1260 | 1268 | return reply; |
| 1261 | 1269 | } |
| 1262 | 1270 | |
| r8282 | r8283 | |
| 1276 | 1284 | { |
| 1277 | 1285 | console_GROMs.addr = (console_GROMs.addr & 0xFF00) | (data & 0xFF); |
| 1278 | 1286 | |
| 1279 | | GROM_dataread(space->machine, offset); |
| 1287 | GROM_dataread(space->machine, offset&0xfffc); |
| 1280 | 1288 | console_GROMs.waddr_LSB = FALSE; |
| 1281 | 1289 | } |
| 1282 | 1290 | else |