src/mess/devices/ti99cart.c
| r5297 | r5298 | |
| 2113 | 2113 | for (i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
| 2114 | 2114 | { |
| 2115 | 2115 | cartslots->cartridge[i].pcb = NULL; |
| 2116 | clear_slot(device, i); |
| 2116 | 2117 | } |
| 2117 | 2118 | |
| 2118 | 2119 | /* Initialize the legacy system. */ |
| r5297 | r5298 | |
| 2146 | 2147 | READ16_DEVICE_HANDLER( ti99_multicart_r ) |
| 2147 | 2148 | { |
| 2148 | 2149 | ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token; |
| 2149 | | cartridge_t *cart = &cartslots->cartridge[cartslots->active_slot]; |
| 2150 | int slot = cartslots->active_slot; |
| 2151 | cartridge_t *cart; |
| 2152 | |
| 2153 | /* Sanity check. Higher slots are always empty. */ |
| 2154 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2155 | return 0; |
| 2156 | |
| 2157 | /* Same as above (GROM read): If there is only one cartridge there |
| 2158 | is no use of trying other banks. There is one issue with the |
| 2159 | selection mechanism: When the console probes the GROM banks and |
| 2160 | we have a ROM-only cartridge plugged in, it checks bank 0 and bank 1, |
| 2161 | finds no GROM, and then fails to dummy-check bank 0 again which would |
| 2162 | have set our cartridge expander to slot 0. But in slot 1 there is no |
| 2163 | ROM cartridge, so nothing shows up in the selection list. We work |
| 2164 | around this with the following line. */ |
| 2165 | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2166 | slot=0; |
| 2150 | 2167 | |
| 2168 | cart = &cartslots->cartridge[slot]; |
| 2169 | |
| 2151 | 2170 | /* Idle the CPU */ |
| 2152 | 2171 | cpu_adjust_icount(cputag_get_cpu(device->machine, "maincpu"),-4); |
| 2153 | 2172 | |
| r5297 | r5298 | |
| 2162 | 2181 | return ti99_cart_r_legacy(device, offset, mem_mask); |
| 2163 | 2182 | } |
| 2164 | 2183 | |
| 2165 | | if (cart->pcb!=NULL) |
| 2184 | if (!slot_is_empty(device, slot)) |
| 2166 | 2185 | { |
| 2167 | | // printf("accessing cartridge in slot %d\n", cartslots->active_slot); |
| 2186 | // printf("accessing cartridge in slot %d\n", slot); |
| 2168 | 2187 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 2188 | // printf("address=%lx, offset=%lx\n", pcbdef, offset); |
| 2169 | 2189 | return (*pcbdef->read)(cart->pcb, offset, mem_mask); |
| 2170 | 2190 | } |
| 2171 | 2191 | else |
| 2172 | 2192 | { |
| 2173 | | // printf("No cartridge in slot %d\n", cartslots->active_slot); |
| 2193 | // printf("No cartridge in slot %d\n", slot); |
| 2174 | 2194 | return 0; |
| 2175 | 2195 | } |
| 2176 | 2196 | } |
| r5297 | r5298 | |
| 2188 | 2208 | WRITE16_DEVICE_HANDLER( ti99_multicart_w ) |
| 2189 | 2209 | { |
| 2190 | 2210 | ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token; |
| 2211 | int slot = cartslots->active_slot; |
| 2212 | cartridge_t *cart; |
| 2213 | |
| 2214 | /* Sanity check. Higher slots are always empty. */ |
| 2215 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2216 | return; |
| 2217 | |
| 2218 | /* Same as above (READ16). */ |
| 2219 | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2220 | slot=0; |
| 2191 | 2221 | |
| 2192 | | cartridge_t *cart = &cartslots->cartridge[cartslots->active_slot]; |
| 2222 | cart = &cartslots->cartridge[slot]; |
| 2193 | 2223 | |
| 2194 | 2224 | /* Idle the CPU */ |
| 2195 | 2225 | cpu_adjust_icount(cputag_get_cpu(device->machine, "maincpu"),-4); |
| r5297 | r5298 | |
| 2202 | 2232 | } |
| 2203 | 2233 | else |
| 2204 | 2234 | { |
| 2205 | | if (cart->pcb!=NULL) |
| 2235 | if (!slot_is_empty(device, slot)) |
| 2206 | 2236 | { |
| 2207 | | // printf("writing to cartridge in slot %d\n", cartslots->active_slot); |
| 2237 | // printf("writing to cartridge in slot %d\n", slot); |
| 2208 | 2238 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 2209 | 2239 | (*pcbdef->write)(cart->pcb, offset, data, mem_mask); |
| 2210 | 2240 | } |
| r5297 | r5298 | |
| 2219 | 2249 | READ8_DEVICE_HANDLER( ti99_multicart_cru_r ) |
| 2220 | 2250 | { |
| 2221 | 2251 | ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token; |
| 2222 | | cartridge_t *cart = &cartslots->cartridge[cartslots->active_slot]; |
| 2252 | cartridge_t *cart; |
| 2253 | |
| 2254 | int slot = cartslots->active_slot; |
| 2255 | |
| 2256 | /* Sanity check. Higher slots are always empty. */ |
| 2257 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2258 | return 0; |
| 2259 | |
| 2260 | /* Same as above (READ16). */ |
| 2261 | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2262 | slot=0; |
| 2223 | 2263 | |
| 2224 | | if (cart->pcb!=NULL) |
| 2264 | cart = &cartslots->cartridge[slot]; |
| 2265 | |
| 2266 | if (!slot_is_empty(device, slot)) |
| 2225 | 2267 | { |
| 2226 | 2268 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 2227 | 2269 | if (pcbdef->cruread != NULL) |
| r5297 | r5298 | |
| 2236 | 2278 | WRITE8_DEVICE_HANDLER( ti99_multicart_cru_w ) |
| 2237 | 2279 | { |
| 2238 | 2280 | ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token; |
| 2239 | | cartridge_t *cart = &cartslots->cartridge[cartslots->active_slot]; |
| 2281 | cartridge_t *cart; |
| 2282 | |
| 2283 | int slot = cartslots->active_slot; |
| 2284 | |
| 2285 | /* Sanity check. Higher slots are always empty. */ |
| 2286 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2287 | return; |
| 2288 | |
| 2289 | /* Same as above (READ16). */ |
| 2290 | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2291 | slot=0; |
| 2240 | 2292 | |
| 2241 | | if (cart->pcb!=NULL) |
| 2293 | cart = &cartslots->cartridge[slot]; |
| 2294 | |
| 2295 | if (!slot_is_empty(device, slot)) |
| 2242 | 2296 | { |
| 2243 | 2297 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 2244 | 2298 | if (pcbdef->cruwrite != NULL) |
| r5297 | r5298 | |
| 2253 | 2307 | READ8_DEVICE_HANDLER(ti99_multicart8_r) |
| 2254 | 2308 | { |
| 2255 | 2309 | ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token; |
| 2256 | | cartridge_t *cart = &cartslots->cartridge[cartslots->active_slot]; |
| 2310 | cartridge_t *cart; |
| 2311 | |
| 2312 | int slot = cartslots->active_slot; |
| 2313 | |
| 2314 | /* Sanity check. Higher slots are always empty. */ |
| 2315 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2316 | return 0; |
| 2317 | |
| 2318 | /* Same as above (READ16). */ |
| 2319 | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2320 | slot=0; |
| 2257 | 2321 | |
| 2322 | cart = &cartslots->cartridge[slot]; |
| 2323 | |
| 2258 | 2324 | /* Idle the CPU. TODO: Check whether this is correct for this machine. */ |
| 2259 | 2325 | cpu_adjust_icount(cputag_get_cpu(device->machine, "maincpu"),-4); |
| 2260 | 2326 | |
| r5297 | r5298 | |
| 2264 | 2330 | return ti99_cart_r_legacy8(device, offset); |
| 2265 | 2331 | } |
| 2266 | 2332 | |
| 2267 | | if (cart->pcb!=NULL) |
| 2333 | if (!slot_is_empty(device, slot)) |
| 2268 | 2334 | { |
| 2269 | | // printf("accessing cartridge in slot %d\n", cartslots->active_slot); |
| 2335 | // printf("accessing cartridge in slot %d\n", slot); |
| 2270 | 2336 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 2271 | 2337 | return (*pcbdef->read8)(cart->pcb, offset); |
| 2272 | 2338 | } |
| 2273 | 2339 | else |
| 2274 | 2340 | { |
| 2275 | | // printf("No cartridge in slot %d\n", cartslots->active_slot); |
| 2341 | // printf("No cartridge in slot %d\n", slot); |
| 2276 | 2342 | return 0; |
| 2277 | 2343 | } |
| 2278 | 2344 | } |
| r5297 | r5298 | |
| 2280 | 2346 | WRITE8_DEVICE_HANDLER(ti99_multicart8_w) |
| 2281 | 2347 | { |
| 2282 | 2348 | ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token; |
| 2349 | cartridge_t *cart; |
| 2350 | |
| 2351 | int slot = cartslots->active_slot; |
| 2352 | |
| 2353 | /* Sanity check. Higher slots are always empty. */ |
| 2354 | if (slot >= NUMBER_OF_CARTRIDGE_SLOTS) |
| 2355 | return; |
| 2356 | |
| 2357 | /* Same as above (READ16). */ |
| 2358 | if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1) |
| 2359 | slot=0; |
| 2283 | 2360 | |
| 2284 | | cartridge_t *cart = &cartslots->cartridge[cartslots->active_slot]; |
| 2361 | cart = &cartslots->cartridge[slot]; |
| 2285 | 2362 | |
| 2286 | 2363 | /* Idle the CPU. TODO: Check whether this is correct for this machine. */ |
| 2287 | 2364 | cpu_adjust_icount(cputag_get_cpu(device->machine, "maincpu"),-4); |
| r5297 | r5298 | |
| 2293 | 2370 | } |
| 2294 | 2371 | else |
| 2295 | 2372 | { |
| 2296 | | if (cart->pcb!=NULL) |
| 2373 | if (!slot_is_empty(device, slot)) |
| 2297 | 2374 | { |
| 2298 | 2375 | ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token; |
| 2299 | 2376 | (*pcbdef->write8)(cart->pcb, offset, data); |
| r5297 | r5298 | |
| 2310 | 2387 | MDRV_CARTSLOT_PCBTYPE(3, "minimem", TI99_CARTRIDGE_PCB_MINIMEM) |
| 2311 | 2388 | MDRV_CARTSLOT_PCBTYPE(4, "super", TI99_CARTRIDGE_PCB_SUPER) |
| 2312 | 2389 | MDRV_CARTSLOT_PCBTYPE(5, "mbx", TI99_CARTRIDGE_PCB_MBX) |
| 2313 | | // MDRV_CARTSLOT_PCBTYPE(6, "gk", TI99_CARTRIDGE_PCB_GK) |
| 2314 | 2390 | |
| 2315 | 2391 | MDRV_CARTSLOT_START(ti99_cartridge) |
| 2316 | 2392 | MDRV_CARTSLOT_LOAD(ti99_cartridge) |
| r5297 | r5298 | |
| 2324 | 2400 | MDRV_CARTSLOT_PCBTYPE(3, "minimem", TI99_CARTRIDGE_PCB_MINIMEM) |
| 2325 | 2401 | MDRV_CARTSLOT_PCBTYPE(4, "super", TI99_CARTRIDGE_PCB_SUPER) |
| 2326 | 2402 | MDRV_CARTSLOT_PCBTYPE(5, "mbx", TI99_CARTRIDGE_PCB_MBX) |
| 2327 | | // MDRV_CARTSLOT_PCBTYPE(6, "gk", TI99_CARTRIDGE_PCB_GK) |
| 2403 | |
| 2328 | 2404 | MDRV_CARTSLOT_START(ti99_cartridge) |
| 2329 | 2405 | MDRV_CARTSLOT_LOAD(ti99_cartridge) |
| 2330 | 2406 | MDRV_CARTSLOT_UNLOAD(ti99_cartridge) |
| r5297 | r5298 | |
| 2337 | 2413 | MDRV_CARTSLOT_PCBTYPE(3, "minimem", TI99_CARTRIDGE_PCB_MINIMEM) |
| 2338 | 2414 | MDRV_CARTSLOT_PCBTYPE(4, "super", TI99_CARTRIDGE_PCB_SUPER) |
| 2339 | 2415 | MDRV_CARTSLOT_PCBTYPE(5, "mbx", TI99_CARTRIDGE_PCB_MBX) |
| 2340 | | // MDRV_CARTSLOT_PCBTYPE(6, "gk", TI99_CARTRIDGE_PCB_GK) |
| 2416 | |
| 2341 | 2417 | MDRV_CARTSLOT_START(ti99_cartridge) |
| 2342 | 2418 | MDRV_CARTSLOT_LOAD(ti99_cartridge) |
| 2343 | 2419 | MDRV_CARTSLOT_UNLOAD(ti99_cartridge) |
| r5297 | r5298 | |
| 2350 | 2426 | MDRV_CARTSLOT_PCBTYPE(3, "minimem", TI99_CARTRIDGE_PCB_MINIMEM) |
| 2351 | 2427 | MDRV_CARTSLOT_PCBTYPE(4, "super", TI99_CARTRIDGE_PCB_SUPER) |
| 2352 | 2428 | MDRV_CARTSLOT_PCBTYPE(5, "mbx", TI99_CARTRIDGE_PCB_MBX) |
| 2353 | | // MDRV_CARTSLOT_PCBTYPE(6, "gk", TI99_CARTRIDGE_PCB_GK) |
| 2429 | |
| 2354 | 2430 | MDRV_CARTSLOT_START(ti99_cartridge) |
| 2355 | 2431 | MDRV_CARTSLOT_LOAD(ti99_cartridge) |
| 2356 | 2432 | MDRV_CARTSLOT_UNLOAD(ti99_cartridge) |