src/mess/devices/mflopimg.c
| r1401 | r1402 | |
| 11 | 11 | #include "image.h" |
| 12 | 12 | #include "devices/flopdrv.h" |
| 13 | 13 | |
| 14 | |
| 15 | |
| 16 | /*************************************************************************** |
| 17 | CONSTANTS |
| 18 | ***************************************************************************/ |
| 19 | |
| 14 | 20 | #define FLOPPY_TAG "floptag" |
| 15 | 21 | #define LOG_FLOPPY 0 |
| 16 | 22 | |
| 17 | | struct mess_flopimg |
| 23 | |
| 24 | |
| 25 | /*************************************************************************** |
| 26 | TYPE DEFINITIONS |
| 27 | ***************************************************************************/ |
| 28 | |
| 29 | typedef struct _mess_flopimg mess_flopimg; |
| 30 | struct _mess_flopimg |
| 18 | 31 | { |
| 19 | 32 | floppy_image *floppy; |
| 20 | 33 | int track; |
| r1401 | r1402 | |
| 22 | 35 | int (*tracktranslate_proc)(mess_image *image, floppy_image *floppy, int physical_track); |
| 23 | 36 | }; |
| 24 | 37 | |
| 25 | | struct floppy_error_map |
| 38 | |
| 39 | |
| 40 | typedef struct _floppy_error_map floppy_error_map; |
| 41 | struct _floppy_error_map |
| 26 | 42 | { |
| 27 | 43 | floperr_t ferr; |
| 28 | 44 | image_error_t ierr; |
| 29 | 45 | const char *message; |
| 30 | 46 | }; |
| 31 | 47 | |
| 32 | | static const struct floppy_error_map errmap[] = |
| 48 | |
| 49 | |
| 50 | /*************************************************************************** |
| 51 | GLOBAL VARIABLES |
| 52 | ***************************************************************************/ |
| 53 | |
| 54 | static const floppy_error_map errmap[] = |
| 33 | 55 | { |
| 34 | 56 | { FLOPPY_ERROR_SUCCESS, IMAGE_ERROR_SUCCESS }, |
| 35 | 57 | { FLOPPY_ERROR_INTERNAL, IMAGE_ERROR_INTERNAL }, |
| r1401 | r1402 | |
| 38 | 60 | { FLOPPY_ERROR_INVALIDIMAGE, IMAGE_ERROR_INVALIDIMAGE } |
| 39 | 61 | }; |
| 40 | 62 | |
| 63 | static int flopimg_keep_geometry; /* hack for TI-99 - please fix when possible */ |
| 41 | 64 | |
| 42 | | static struct mess_flopimg *get_flopimg(mess_image *image) |
| 65 | |
| 66 | |
| 67 | /*************************************************************************** |
| 68 | IMPLEMENTATION |
| 69 | ***************************************************************************/ |
| 70 | |
| 71 | static mess_flopimg *get_flopimg(mess_image *image) |
| 43 | 72 | { |
| 44 | | return (struct mess_flopimg *) image_lookuptag(image, FLOPPY_TAG); |
| 73 | return (mess_flopimg *) image_lookuptag(image, FLOPPY_TAG); |
| 45 | 74 | } |
| 46 | 75 | |
| 47 | 76 | |
| r1401 | r1402 | |
| 55 | 84 | |
| 56 | 85 | static void flopimg_seek_callback(mess_image *image, int physical_track) |
| 57 | 86 | { |
| 58 | | struct mess_flopimg *flopimg; |
| 87 | mess_flopimg *flopimg; |
| 59 | 88 | |
| 60 | 89 | flopimg = get_flopimg(image); |
| 61 | 90 | if (!flopimg || !flopimg->floppy) |
| r1401 | r1402 | |
| 72 | 101 | |
| 73 | 102 | static int flopimg_get_sectors_per_track(mess_image *image, int side) |
| 74 | 103 | { |
| 75 | | struct mess_flopimg *flopimg; |
| 104 | mess_flopimg *flopimg; |
| 76 | 105 | floperr_t err; |
| 77 | 106 | int sector_count; |
| 78 | 107 | |
| r1401 | r1402 | |
| 90 | 119 | |
| 91 | 120 | static void flopimg_get_id_callback(mess_image *image, chrn_id *id, int id_index, int side) |
| 92 | 121 | { |
| 93 | | struct mess_flopimg *flopimg; |
| 122 | mess_flopimg *flopimg; |
| 94 | 123 | int cylinder, sector, N; |
| 95 | 124 | UINT32 sector_length; |
| 96 | 125 | |
| r1401 | r1402 | |
| 125 | 154 | |
| 126 | 155 | static void flopimg_read_sector_data_into_buffer(mess_image *image, int side, int index1, char *ptr, int length) |
| 127 | 156 | { |
| 128 | | struct mess_flopimg *flopimg; |
| 157 | mess_flopimg *flopimg; |
| 129 | 158 | |
| 130 | 159 | flopimg = get_flopimg(image); |
| 131 | 160 | if (!flopimg || !flopimg->floppy) |
| r1401 | r1402 | |
| 141 | 170 | |
| 142 | 171 | static void flopimg_write_sector_data_from_buffer(mess_image *image, int side, int index1, const char *ptr, int length,int ddam) |
| 143 | 172 | { |
| 144 | | struct mess_flopimg *flopimg; |
| 173 | mess_flopimg *flopimg; |
| 145 | 174 | |
| 146 | 175 | flopimg = get_flopimg(image); |
| 147 | 176 | if (!flopimg || !flopimg->floppy) |
| r1401 | r1402 | |
| 157 | 186 | |
| 158 | 187 | static void flopimg_read_track_data_info_buffer(mess_image *image, int side, void *ptr, int *length) |
| 159 | 188 | { |
| 160 | | struct mess_flopimg *flopimg; |
| 189 | mess_flopimg *flopimg; |
| 161 | 190 | |
| 162 | 191 | flopimg = get_flopimg(image); |
| 163 | 192 | if (!flopimg || !flopimg->floppy) |
| r1401 | r1402 | |
| 170 | 199 | |
| 171 | 200 | static void flopimg_write_track_data_info_buffer(mess_image *image, int side, const void *ptr, int *length) |
| 172 | 201 | { |
| 173 | | struct mess_flopimg *flopimg; |
| 202 | mess_flopimg *flopimg; |
| 174 | 203 | |
| 175 | 204 | flopimg = get_flopimg(image); |
| 176 | 205 | if (!flopimg || !flopimg->floppy) |
| r1401 | r1402 | |
| 234 | 263 | |
| 235 | 264 | static int device_init_floppy(mess_image *image) |
| 236 | 265 | { |
| 237 | | if (!image_alloctag(image, FLOPPY_TAG, sizeof(struct mess_flopimg))) |
| 266 | flopimg_keep_geometry = FALSE; |
| 267 | if (!image_alloctag(image, FLOPPY_TAG, sizeof(mess_flopimg))) |
| 238 | 268 | return INIT_FAIL; |
| 239 | 269 | return floppy_drive_init(image, &mess_floppy_interface); |
| 240 | 270 | } |
| r1401 | r1402 | |
| 244 | 274 | static int internal_floppy_device_load(mess_image *image, int create_format, option_resolution *create_args) |
| 245 | 275 | { |
| 246 | 276 | floperr_t err; |
| 247 | | struct mess_flopimg *flopimg; |
| 277 | mess_flopimg *flopimg; |
| 248 | 278 | const struct IODevice *dev; |
| 249 | 279 | const struct FloppyFormat *floppy_options; |
| 250 | 280 | int floppy_flags, i; |
| r1401 | r1402 | |
| 276 | 306 | } |
| 277 | 307 | |
| 278 | 308 | /* if we can get head and track counts, then set the geometry accordingly */ |
| 279 | | if (floppy_callbacks(flopimg->floppy)->get_heads_per_disk |
| 309 | if (!flopimg_keep_geometry |
| 310 | && floppy_callbacks(flopimg->floppy)->get_heads_per_disk |
| 280 | 311 | && floppy_callbacks(flopimg->floppy)->get_tracks_per_disk) |
| 281 | 312 | { |
| 282 | 313 | floppy_drive_set_geometry_absolute(image, |
| r1401 | r1402 | |
| 312 | 343 | |
| 313 | 344 | static void device_unload_floppy(mess_image *image) |
| 314 | 345 | { |
| 315 | | struct mess_flopimg *flopimg; |
| 346 | mess_flopimg *flopimg; |
| 316 | 347 | flopimg = image_lookuptag(image, FLOPPY_TAG); |
| 317 | 348 | |
| 318 | 349 | /* if we have one of our hacky unload procs, call it */ |
| r1401 | r1402 | |
| 333 | 364 | |
| 334 | 365 | void floppy_install_unload_proc(mess_image *image, void (*proc)(mess_image *image)) |
| 335 | 366 | { |
| 336 | | struct mess_flopimg *flopimg; |
| 367 | mess_flopimg *flopimg; |
| 337 | 368 | flopimg = image_lookuptag(image, FLOPPY_TAG); |
| 338 | 369 | flopimg->unload_proc = proc; |
| 339 | 370 | } |
| r1401 | r1402 | |
| 342 | 373 | |
| 343 | 374 | void floppy_install_tracktranslate_proc(mess_image *image, int (*proc)(mess_image *image, floppy_image *floppy, int physical_track)) |
| 344 | 375 | { |
| 345 | | struct mess_flopimg *flopimg; |
| 376 | mess_flopimg *flopimg; |
| 346 | 377 | flopimg = image_lookuptag(image, FLOPPY_TAG); |
| 347 | 378 | flopimg->tracktranslate_proc = proc; |
| 348 | 379 | } |
| 349 | 380 | |
| 350 | 381 | |
| 382 | /************ |
| 383 | * Another hack for ti99: Drive track count may differ from medium track count. |
| 384 | * It is possible to insert a 40 track medium in an 80 track drive; the TI |
| 385 | * controllers read the track count from sector 0 and automatically |
| 386 | * apply double steps. Setting the track count of the drive to the medium |
| 387 | * track count will lead to unreachable tracks. |
| 388 | * This function is called from 99_dsk.c to switch off the lines in |
| 389 | * internal_floppy_device_load which set the drive geometry to the medium |
| 390 | * geometry. |
| 391 | *************/ |
| 392 | void floppy_keep_drive_geometry(void) |
| 393 | { |
| 394 | assert_always(mame_get_phase(Machine) == MAME_PHASE_INIT, "Can only call floppy_keep_drive_geometry at init time!"); |
| 395 | flopimg_keep_geometry = TRUE; |
| 396 | } |
| 351 | 397 | |
| 398 | |
| 399 | |
| 352 | 400 | /************************************* |
| 353 | 401 | * |
| 354 | 402 | * Device specification function |
src/mess/machine/99_dsk.c
| r1401 | r1402 | |
| 267 | 267 | int success; |
| 268 | 268 | floperr_t err; |
| 269 | 269 | |
| 270 | /* Prevents internal_floppy_device_load (mflopimg) to set the drive |
| 271 | geometry to the medium geometry. TI disk controllers determine the |
| 272 | number of tracks from a field in sector 0, and if the medium has |
| 273 | 40 tracks but the drive has 80, the DSR ROM automatically |
| 274 | double-steps the tracks. |
| 275 | */ |
| 276 | floppy_keep_drive_geometry(); |
| 277 | |
| 270 | 278 | geometry1 = floppy_create_tag(floppy, TI99DSK_TAG, sizeof(*geometry1)); |
| 271 | 279 | |
| 272 | 280 | ti99_guess_geometry(floppy, geometry1, NULL, &success); |
| r1401 | r1402 | |
| 362 | 370 | */ |
| 363 | 371 | void ti99_fdc_init(void) |
| 364 | 372 | { |
| 373 | wd17xx_init(WD_TYPE_179X, fdc_callback, NULL); /* initialize the floppy disk controller */ |
| 374 | ti99_install_tracktranslate_procs(); |
| 375 | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 376 | use_80_track_drives = FALSE; |
| 377 | } |
| 378 | |
| 379 | /* |
| 380 | Reset fdc card, set up handlers |
| 381 | */ |
| 382 | void ti99_fdc_reset(void) |
| 383 | { |
| 365 | 384 | ti99_disk_DSR = memory_region(region_dsr) + offset_fdc_dsr; |
| 366 | | |
| 367 | 385 | DSEL = 0; |
| 368 | 386 | DSKnum = -1; |
| 369 | 387 | DSKside = 0; |
| 370 | 388 | |
| 371 | 389 | DVENA = 0; |
| 372 | 390 | motor_on = 0; |
| 373 | | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 374 | | |
| 375 | 391 | ti99_peb_set_card_handlers(0x1100, & fdc_handlers); |
| 376 | | |
| 377 | | wd17xx_init(WD_TYPE_179X, fdc_callback, NULL); /* initialize the floppy disk controller */ |
| 392 | wd17xx_reset(); /* resets the fdc */ |
| 378 | 393 | wd17xx_set_density(DEN_FM_LO); |
| 379 | | |
| 380 | | use_80_track_drives = FALSE; |
| 381 | | |
| 382 | | ti99_install_tracktranslate_procs(); |
| 383 | 394 | } |
| 384 | 395 | |
| 385 | 396 | |
| r1401 | r1402 | |
| 627 | 638 | */ |
| 628 | 639 | void ti99_ccfdc_init(void) |
| 629 | 640 | { |
| 641 | wd17xx_init(WD_TYPE_179X, fdc_callback, NULL); /* initialize the floppy disk controller */ |
| 642 | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 643 | ti99_install_tracktranslate_procs(); |
| 644 | use_80_track_drives = FALSE; |
| 645 | } |
| 646 | |
| 647 | void ti99_ccfdc_reset(void) |
| 648 | { |
| 630 | 649 | ti99_disk_DSR = memory_region(region_dsr) + offset_ccfdc_dsr; |
| 631 | | |
| 632 | 650 | DSEL = 0; |
| 633 | 651 | DSKnum = -1; |
| 634 | 652 | DSKside = 0; |
| 635 | 653 | |
| 636 | 654 | DVENA = 0; |
| 637 | 655 | motor_on = 0; |
| 638 | | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 639 | 656 | |
| 640 | 657 | ti99_peb_set_card_handlers(0x1100, & ccfdc_handlers); |
| 641 | 658 | |
| 642 | | wd17xx_init(WD_TYPE_179X, fdc_callback, NULL); /* initialize the floppy disk controller */ |
| 659 | wd17xx_reset(); /* initialize the floppy disk controller */ |
| 643 | 660 | wd17xx_set_density(DEN_MFM_LO); |
| 661 | } |
| 644 | 662 | |
| 645 | 663 | |
| 646 | | use_80_track_drives = FALSE; |
| 647 | 664 | |
| 648 | | ti99_install_tracktranslate_procs(); |
| 649 | | } |
| 650 | | |
| 651 | | |
| 652 | 665 | /* |
| 653 | 666 | Read disk CRU interface |
| 654 | 667 | |
| r1401 | r1402 | |
| 842 | 855 | */ |
| 843 | 856 | void ti99_bwg_init(void) |
| 844 | 857 | { |
| 858 | wd17xx_init(WD_TYPE_179X, fdc_callback, NULL); /* initialize the floppy disk controller */ |
| 859 | mm58274c_init(1, 1); /* initialize the RTC */ |
| 860 | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 861 | ti99_install_tracktranslate_procs(); |
| 862 | use_80_track_drives = FALSE; |
| 863 | } |
| 864 | |
| 865 | void ti99_bwg_reset(void) |
| 866 | { |
| 845 | 867 | ti99_disk_DSR = memory_region(region_dsr) + offset_bwg_dsr; |
| 846 | | bwg_ram = memory_region(region_dsr) + offset_bwg_ram; |
| 868 | bwg_ram = memory_region(region_dsr) + offset_bwg_ram; |
| 847 | 869 | bwg_ram_offset = 0; |
| 848 | 870 | bwg_rom_offset = 0; |
| 849 | 871 | bwg_rtc_enable = 0; |
| r1401 | r1402 | |
| 854 | 876 | |
| 855 | 877 | DVENA = 0; |
| 856 | 878 | motor_on = 0; |
| 857 | | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 858 | | |
| 859 | 879 | ti99_peb_set_card_handlers(0x1100, & bwg_handlers); |
| 860 | 880 | |
| 861 | | wd17xx_init(WD_TYPE_179X, fdc_callback, NULL); /* initialize the floppy disk controller */ |
| 881 | wd17xx_reset(); /* initialize the floppy disk controller */ |
| 862 | 882 | wd17xx_set_density(DEN_MFM_LO); |
| 863 | | |
| 864 | | |
| 865 | | mm58274c_init(1, 1); /* initialize the RTC */ |
| 866 | | |
| 867 | | use_80_track_drives = FALSE; |
| 868 | | |
| 869 | | ti99_install_tracktranslate_procs(); |
| 870 | 883 | } |
| 871 | 884 | |
| 872 | | |
| 873 | 885 | /* |
| 874 | 886 | Read disk CRU interface |
| 875 | 887 | |
| r1401 | r1402 | |
| 1236 | 1248 | */ |
| 1237 | 1249 | void ti99_hfdc_init(void) |
| 1238 | 1250 | { |
| 1251 | /* initialize the floppy disk controller */ |
| 1252 | smc92x4_init(0, & hfdc_intf); |
| 1253 | mm58274c_init(1, 1); /* initialize the RTC */ |
| 1254 | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 1255 | ti99_install_tracktranslate_procs(); |
| 1256 | use_80_track_drives = TRUE; |
| 1257 | } |
| 1258 | |
| 1259 | |
| 1260 | void ti99_hfdc_reset(void) |
| 1261 | { |
| 1239 | 1262 | ti99_disk_DSR = memory_region(region_dsr) + offset_hfdc_dsr; |
| 1240 | 1263 | hfdc_ram = memory_region(region_dsr) + offset_hfdc_ram; |
| 1241 | 1264 | hfdc_ram_offset[0] = hfdc_ram_offset[1] = hfdc_ram_offset[2] = 0; |
| r1401 | r1402 | |
| 1248 | 1271 | |
| 1249 | 1272 | DVENA = 0; |
| 1250 | 1273 | motor_on = 0; |
| 1251 | | motor_on_timer = timer_alloc(motor_on_timer_callback, NULL); |
| 1252 | 1274 | |
| 1253 | 1275 | ti99_peb_set_card_handlers(0x1100, & hfdc_handlers); |
| 1254 | 1276 | |
| 1255 | | /* initialize the floppy disk controller */ |
| 1256 | | smc92x4_init(0, & hfdc_intf); |
| 1257 | | |
| 1258 | | mm58274c_init(1, 1); /* initialize the RTC */ |
| 1259 | | |
| 1260 | | use_80_track_drives = TRUE; |
| 1261 | | |
| 1262 | | ti99_install_tracktranslate_procs(); |
| 1277 | smc92x4_reset(0); |
| 1263 | 1278 | } |
| 1264 | 1279 | |
| 1265 | 1280 | |
| r1401 | r1402 | |
| 1269 | 1284 | static int hfdc_cru_r(int offset) |
| 1270 | 1285 | { |
| 1271 | 1286 | int reply; |
| 1272 | | |
| 1273 | 1287 | switch (offset) |
| 1274 | 1288 | { |
| 1275 | 1289 | case 0: |
src/mess/machine/geneve.c
| r1401 | r1402 | |
| 200 | 200 | /*has_genmod = TRUE;*/ |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | | |
| 204 | 203 | MACHINE_START( geneve ) |
| 205 | 204 | { |
| 205 | tms9901_init(0, & tms9901reset_param_ti99); |
| 206 | |
| 207 | /* Initialize all. Actually, at this point, we don't know |
| 208 | how the switches are set. Later we use the configuration switches to |
| 209 | determine which one to use. */ |
| 210 | ti99_peb_init(); |
| 211 | ti99_fdc_init(); |
| 212 | #if HAS_99CCFDC |
| 213 | ti99_ccfdc_init(); |
| 214 | #endif |
| 215 | ti99_bwg_init(); |
| 216 | ti99_hfdc_init(); |
| 217 | ti99_ide_init(); |
| 218 | ti99_rs232_init(); |
| 219 | ti99_usbsm_init(); |
| 220 | mm58274c_init(0, 1); |
| 221 | add_exit_callback(machine, machine_stop_geneve); |
| 222 | } |
| 223 | |
| 224 | MACHINE_RESET( geneve ) |
| 225 | { |
| 206 | 226 | mode_flags = /*0*/mf_mapmode; |
| 207 | 227 | /* initialize page lookup */ |
| 208 | 228 | memset(page_lookup, 0, sizeof(page_lookup)); |
| r1401 | r1402 | |
| 219 | 239 | cartridge_page = 0; |
| 220 | 240 | |
| 221 | 241 | /* init tms9901 */ |
| 222 | | tms9901_init(0, & tms9901reset_param_ti99); |
| 242 | tms9901_reset(0); |
| 223 | 243 | |
| 224 | 244 | v9938_reset(); |
| 225 | 245 | |
| 226 | | mm58274c_init(0, 1); |
| 227 | | |
| 228 | 246 | /* clear keyboard interface state (probably overkill, but can't harm) */ |
| 229 | 247 | JoySel = 0; |
| 230 | 248 | KeyQueueHead = KeyQueueLen = 0; |
| r1401 | r1402 | |
| 247 | 265 | has_usb_sm = (readinputport(input_port_config) >> config_usbsm_bit) & config_usbsm_mask; |
| 248 | 266 | |
| 249 | 267 | /* set up optional expansion hardware */ |
| 250 | | ti99_peb_init(0, inta_callback, intb_callback); |
| 268 | ti99_peb_reset(0, inta_callback, intb_callback); |
| 251 | 269 | |
| 252 | 270 | if (has_speech) |
| 253 | 271 | { |
| r1401 | r1402 | |
| 259 | 277 | switch (fdc_kind) |
| 260 | 278 | { |
| 261 | 279 | case fdc_kind_TI: |
| 262 | | ti99_fdc_init(); |
| 280 | ti99_fdc_reset(); |
| 263 | 281 | break; |
| 264 | 282 | #if HAS_99CCFDC |
| 265 | 283 | case fdc_kind_CC: |
| 266 | | ti99_ccfdc_init(); |
| 284 | ti99_ccfdc_reset(); |
| 267 | 285 | break; |
| 268 | 286 | #endif |
| 269 | 287 | case fdc_kind_BwG: |
| 270 | | ti99_bwg_init(); |
| 288 | ti99_bwg_reset(); |
| 271 | 289 | break; |
| 272 | 290 | case fdc_kind_hfdc: |
| 273 | | ti99_hfdc_init(); |
| 291 | ti99_hfdc_reset(); |
| 274 | 292 | break; |
| 275 | 293 | case fdc_kind_none: |
| 276 | 294 | break; |
| r1401 | r1402 | |
| 278 | 296 | |
| 279 | 297 | if (has_ide) |
| 280 | 298 | { |
| 281 | | ti99_ide_init(TRUE); |
| 299 | ti99_ide_reset(TRUE); |
| 282 | 300 | ti99_ide_load_memcard(); |
| 283 | 301 | } |
| 284 | 302 | |
| 285 | 303 | if (has_rs232) |
| 286 | | ti99_rs232_init(); |
| 304 | ti99_rs232_reset(); |
| 287 | 305 | |
| 288 | 306 | if (has_usb_sm) |
| 289 | | ti99_usbsm_init(TRUE); |
| 290 | | |
| 291 | | add_exit_callback(machine, machine_stop_geneve); |
| 307 | ti99_usbsm_reset(TRUE); |
| 292 | 308 | } |
| 293 | 309 | |
| 294 | 310 | static void machine_stop_geneve(running_machine *machine) |
src/mess/machine/ti99_4x.c
| r1401 | r1402 | |
| 72 | 72 | #include "devices/harddriv.h" /* for device_init_mess_hd() */ |
| 73 | 73 | #include "smc92x4.h" /* for smc92x4_hd_load()/smc92x4_hd_unload() */ |
| 74 | 74 | |
| 75 | | |
| 76 | 75 | /* prototypes */ |
| 77 | 76 | static READ16_HANDLER ( ti99_rspeech_r ); |
| 78 | 77 | static WRITE16_HANDLER ( ti99_wspeech_w ); |
| r1401 | r1402 | |
| 100 | 99 | static void ti99_audio_gate(int offset, int data); |
| 101 | 100 | static void ti99_CS_output(int offset, int data); |
| 102 | 101 | |
| 103 | | static void ti99_8_internal_dsr_init(void); |
| 102 | static void ti99_8_internal_dsr_reset(void); |
| 104 | 103 | |
| 105 | | static void ti99_4p_internal_dsr_init(void); |
| 104 | static void ti99_4p_internal_dsr_reset(void); |
| 106 | 105 | static void ti99_TIxram_init(void); |
| 107 | 106 | static void ti99_sAMSxram_init(void); |
| 108 | 107 | static void ti99_4p_mapper_init(void); |
| 109 | 108 | static void ti99_myarcxram_init(void); |
| 110 | | static void ti99_evpc_init(void); |
| 109 | static void ti99_evpc_reset(void); |
| 111 | 110 | |
| 111 | static void ti99_common_init(const TMS9928a_interface *intf); |
| 112 | |
| 113 | |
| 112 | 114 | /* |
| 113 | 115 | pointer to extended RAM area |
| 114 | 116 | */ |
| r1401 | r1402 | |
| 667 | 669 | |
| 668 | 670 | MACHINE_START( ti99_4_60hz ) |
| 669 | 671 | { |
| 670 | | TMS9928A_configure(&tms9918_interface); |
| 672 | ti99_common_init(&tms9918_interface); |
| 671 | 673 | } |
| 672 | 674 | |
| 673 | 675 | static const TMS9928a_interface tms9929_interface = |
| r1401 | r1402 | |
| 680 | 682 | |
| 681 | 683 | MACHINE_START( ti99_4_50hz ) |
| 682 | 684 | { |
| 683 | | TMS9928A_configure(&tms9929_interface); |
| 685 | ti99_common_init(&tms9929_interface); |
| 684 | 686 | } |
| 685 | 687 | |
| 686 | 688 | static const TMS9928a_interface tms9918a_interface = |
| r1401 | r1402 | |
| 693 | 695 | |
| 694 | 696 | MACHINE_START( ti99_4a_60hz ) |
| 695 | 697 | { |
| 696 | | TMS9928A_configure(&tms9918a_interface); |
| 698 | ti99_common_init(&tms9918a_interface); |
| 697 | 699 | } |
| 698 | 700 | |
| 699 | 701 | static const TMS9928a_interface tms9929a_interface = |
| r1401 | r1402 | |
| 706 | 708 | |
| 707 | 709 | MACHINE_START( ti99_4a_50hz ) |
| 708 | 710 | { |
| 709 | | TMS9928A_configure(&tms9929a_interface); |
| 711 | ti99_common_init(&tms9929a_interface); |
| 710 | 712 | } |
| 711 | 713 | |
| 714 | MACHINE_START( ti99_4ev_60hz) |
| 715 | { |
| 716 | tms9901_init(0, & tms9901reset_param_ti99_4x); |
| 717 | ti99_peb_init(); |
| 718 | ti99_fdc_init(); |
| 719 | #if HAS_99CCFDC |
| 720 | ti99_ccfdc_init(); |
| 721 | #endif |
| 722 | ti99_bwg_init(); |
| 723 | ti99_hfdc_init(); |
| 724 | ti99_ide_init(); |
| 725 | ti99_rs232_init(); |
| 726 | ti99_hsgpl_init(); |
| 727 | ti99_usbsm_init(); |
| 728 | } |
| 729 | |
| 730 | static void ti99_common_init(const TMS9928a_interface *gfxparm) { |
| 731 | |
| 732 | tms9901_init(0, & tms9901reset_param_ti99_4x); |
| 733 | |
| 734 | TMS9928A_configure(gfxparm); |
| 735 | |
| 736 | /* Initialize all. Actually, at this point, we don't know |
| 737 | how the switches are set. Later we use the configuration switches to |
| 738 | determine which one to use. */ |
| 739 | ti99_peb_init(); |
| 740 | ti99_fdc_init(); |
| 741 | #if HAS_99CCFDC |
| 742 | ti99_ccfdc_init(); |
| 743 | #endif |
| 744 | ti99_bwg_init(); |
| 745 | ti99_hfdc_init(); |
| 746 | ti99_ide_init(); |
| 747 | ti99_rs232_init(); |
| 748 | ti99_hsgpl_init(); |
| 749 | ti99_usbsm_init(); |
| 750 | } |
| 751 | |
| 752 | |
| 712 | 753 | /* |
| 713 | 754 | ti99_init_machine(); called before ti99_load_rom... |
| 714 | 755 | */ |
| r1401 | r1402 | |
| 744 | 785 | } |
| 745 | 786 | |
| 746 | 787 | /* init tms9901 */ |
| 747 | | if (ti99_model == model_99_8) |
| 748 | | tms9901_init(0, & tms9901reset_param_ti99_8); |
| 749 | | else |
| 750 | | tms9901_init(0, & tms9901reset_param_ti99_4x); |
| 788 | tms9901_reset(0); |
| 789 | |
| 790 | if (!has_evpc) TMS9928A_reset(); |
| 791 | else v9938_reset(); |
| 751 | 792 | |
| 752 | | if (! has_evpc) |
| 753 | | TMS9928A_reset(); |
| 754 | | if (has_evpc) |
| 755 | | v9938_reset(); |
| 756 | | |
| 757 | 793 | /* clear keyboard interface state (probably overkill, but can't harm) */ |
| 758 | 794 | KeyCol = 0; |
| 759 | 795 | AlphaLockLine = 0; |
| r1401 | r1402 | |
| 784 | 820 | has_usb_sm = (readinputport(input_port_config) >> config_usbsm_bit) & config_usbsm_mask; |
| 785 | 821 | |
| 786 | 822 | /* set up optional expansion hardware */ |
| 787 | | ti99_peb_init(ti99_model == model_99_4p, tms9901_set_int1, NULL); |
| 823 | ti99_peb_reset(ti99_model == model_99_4p, tms9901_set_int1, NULL); |
| 788 | 824 | |
| 789 | 825 | if (ti99_model == model_99_8) |
| 790 | | ti99_8_internal_dsr_init(); |
| 826 | ti99_8_internal_dsr_reset(); |
| 791 | 827 | |
| 792 | 828 | if (ti99_model == model_99_4p) |
| 793 | | ti99_4p_internal_dsr_init(); |
| 829 | ti99_4p_internal_dsr_reset(); |
| 794 | 830 | |
| 795 | | if (has_speech) |
| 831 | if (has_speech) |
| 796 | 832 | { |
| 797 | 833 | spchroms_interface speech_intf = { region_speech_rom }; |
| 798 | 834 | |
| r1401 | r1402 | |
| 819 | 855 | { |
| 820 | 856 | case xRAM_kind_none: |
| 821 | 857 | default: |
| 822 | | /* reset mem handler to none */ |
| 823 | 858 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, ti99_nop_8_r); |
| 824 | 859 | memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, ti99_nop_8_w); |
| 825 | 860 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xffff, 0, 0, ti99_nop_8_r); |
| r1401 | r1402 | |
| 841 | 876 | ti99_myarcxram_init(); |
| 842 | 877 | break; |
| 843 | 878 | case xRAM_kind_99_8: |
| 844 | | /* nothing needs to be done */ |
| 845 | 879 | break; |
| 846 | 880 | } |
| 847 | 881 | |
| 848 | 882 | switch (fdc_kind) |
| 849 | 883 | { |
| 850 | 884 | case fdc_kind_TI: |
| 851 | | ti99_fdc_init(); |
| 885 | ti99_fdc_reset(); |
| 852 | 886 | break; |
| 853 | 887 | #if HAS_99CCFDC |
| 854 | 888 | case fdc_kind_CC: |
| 855 | | ti99_ccfdc_init(); |
| 889 | ti99_ccfdc_reset(); |
| 856 | 890 | break; |
| 857 | 891 | #endif |
| 858 | 892 | case fdc_kind_BwG: |
| 859 | | ti99_bwg_init(); |
| 893 | ti99_bwg_reset(); |
| 860 | 894 | break; |
| 861 | 895 | case fdc_kind_hfdc: |
| 862 | | ti99_hfdc_init(); |
| 896 | ti99_hfdc_reset(); |
| 863 | 897 | break; |
| 864 | 898 | case fdc_kind_none: |
| 865 | 899 | break; |
| 866 | 900 | } |
| 867 | 901 | |
| 868 | | if (has_ide) |
| 869 | | { |
| 870 | | ti99_ide_init(ti99_model == model_99_8); |
| 902 | if (has_ide) { |
| 903 | ti99_ide_reset(ti99_model == model_99_8); |
| 871 | 904 | ti99_ide_load_memcard(); |
| 872 | 905 | } |
| 873 | 906 | |
| 874 | 907 | if (has_rs232) |
| 875 | | ti99_rs232_init(); |
| 908 | ti99_rs232_reset(); |
| 876 | 909 | |
| 877 | | if (has_hsgpl) |
| 878 | | { |
| 879 | | ti99_hsgpl_init(); |
| 880 | | ti99_hsgpl_load_memcard(); |
| 910 | if (has_hsgpl) { |
| 911 | ti99_hsgpl_reset(); |
| 912 | ti99_hsgpl_load_memcard(); |
| 881 | 913 | } |
| 882 | 914 | else |
| 883 | 915 | hsgpl_crdena = 0; |
| 884 | 916 | |
| 885 | 917 | if (has_usb_sm) |
| 886 | | ti99_usbsm_init(ti99_model == model_99_8); |
| 918 | ti99_usbsm_reset(ti99_model == model_99_8); |
| 887 | 919 | |
| 888 | 920 | if (has_evpc) |
| 889 | | ti99_evpc_init(); |
| 921 | ti99_evpc_reset(); |
| 890 | 922 | |
| 891 | 923 | /* initialize mechatronics mouse */ |
| 892 | 924 | mecmouse_sel = 0; |
| r1401 | r1402 | |
| 2406 | 2438 | |
| 2407 | 2439 | |
| 2408 | 2440 | /* set up handlers, and set initial state */ |
| 2409 | | static void ti99_8_internal_dsr_init(void) |
| 2441 | static void ti99_8_internal_dsr_reset(void) |
| 2410 | 2442 | { |
| 2411 | 2443 | ti99_8_internal_DSR = memory_region(REGION_CPU1) + offset_rom0_8 + 0x4000; |
| 2412 | 2444 | |
| r1401 | r1402 | |
| 2463 | 2495 | |
| 2464 | 2496 | |
| 2465 | 2497 | /* set up handlers, and set initial state */ |
| 2466 | | static void ti99_4p_internal_dsr_init(void) |
| 2498 | static void ti99_4p_internal_dsr_reset(void) |
| 2467 | 2499 | { |
| 2468 | 2500 | ti99_4p_internal_DSR = (UINT16 *) (memory_region(REGION_CPU1) + offset_rom4_4p); |
| 2469 | 2501 | ti99_4p_internal_ROM6 = (UINT16 *) (memory_region(REGION_CPU1) + offset_rom6_4p); |
| r1401 | r1402 | |
| 3000 | 3032 | /* |
| 3001 | 3033 | Reset evpc card, set up handlers |
| 3002 | 3034 | */ |
| 3003 | | static void ti99_evpc_init(void) |
| 3035 | static void ti99_evpc_reset(void) |
| 3004 | 3036 | { |
| 3005 | 3037 | ti99_evpc_DSR = memory_region(region_dsr) + offset_evpc_dsr; |
| 3006 | 3038 | |