/* This is the THIRD function to call for completely initializing the emulation engine. */ int ti68k_init(void) { // init libs ticables_library_init(); tifiles_library_init(); ticalcs_library_init(); // check if image has been loaded if(img_loaded == 0) return ERR_NO_IMAGE; // set calc type and init hardware memset(&tihw, 0, sizeof(Ti68kHardware)); tihw.calc_type = img_infos.calc_type; TRY(hw_init()); return 0; }
int main(int argc, char **argv) { CableHandle *handle; int err; // int i, j; // uint8_t buf[65536], data; // int status, result; // uint8_t scr[3840 + 6]; // int **probing = NULL; #if 0 tiTIME ref, end; unsigned long k; to_START(ref); for(k = 0; k < 1000000; k++) printf(" "); to_START(end); printf("%lu %lu\n", ref, end); printf("%lu\n", to_CURRENT(ref)); printf("%i\n", to_ELAPSED(ref, 60)); return 0; #endif printf("USB support: %i\n", ticables_is_usb_enabled()); // init lib ticables_library_init(); print_lc_error(1); #if 0 ticables_probing_do(&probing, 5, PROBE_ALL); for(i = 1; i <= 7; i++) printf("%i: %i %i %i %i\n", i, probing[i][1], probing[i][2], probing[i][3], probing[i][4]); ticables_probing_finish(&probing); #endif #if 0 { int *list = NULL; int i, n; int *p; ticables_get_usb_devices(&list, &n); printf("List of devices:\n"); for(i = 0; i < n; i++) printf("%i: %04x\n", i, list[i]); } #endif // set cable handle = ticables_handle_new(CABLE_PAR, PORT_1); if(handle == NULL) return -1; ticables_options_set_timeout(handle, 15); ticables_options_set_delay(handle, 10); ticables_handle_show(handle); // open cable err = ticables_cable_open(handle); if(err) print_lc_error(err); if(err) return -1; #if 0 // simple test with DirectLink hand-helds (buf size req/neg) buf[0]=0x00; buf[1]=0x00; buf[2]=0x00; buf[3]=0x04; buf[4]=0x01; buf[5]=0x00; buf[6]=0x00; buf[7]=0x04; buf[8]=0x00; err = ticables_cable_send(handle, buf, 9); if(err) print_lc_error(err); // display answer memset(buf, 0, sizeof(buf)); err = ticables_cable_recv(handle, buf, 9); if(err) print_lc_error(err); for(i = 0; i < 9; i++) printf("%02x ", buf[i]); printf("\n"); #endif #if 0 // mode set i = 0; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x10; buf[i++]=0x04; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x0a; buf[i++]=0x00; buf[i++]=0x01; buf[i++]=0x00; buf[i++]=0x03; buf[i++]=0x00; buf[i++]=0x01; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x07; buf[i++]=0xd0; err = ticables_cable_send(handle, buf, i); if(err) print_lc_error(err); err = ticables_cable_recv(handle, buf, 7); if(err) print_lc_error(err); for(i = 0; i < 7; i++) printf("%02x ", buf[i]); printf("\n"); // mode ack err = ticables_cable_recv(handle, buf, 15); if(err) print_lc_error(err); for(i = 0; i < 15; i++) printf("%02x ", buf[i]); printf("\n"); i = 0; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02; buf[i++]=0x05; buf[i++]=0xe0; buf[i++]=0x00; err = ticables_cable_send(handle, buf, i); if(err) print_lc_error(err); PAUSE(500); #endif #if 0 // param req (TI84+ only) i = 0; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0xa; buf[i++]=0x04; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x04; buf[i++]=0x00; buf[i++]=0x07; buf[i++]=0x00; buf[i++]=0x01; buf[i++]=0x00; buf[i++]=0x22; err = ticables_cable_send(handle, buf, i); if(err) print_lc_error(err); err = ticables_cable_recv(handle, buf, 7); if(err) print_lc_error(err); for(i = 0; i < 7; i++) printf("%02x ", buf[i]); printf("\n"); // delay ack err = ticables_cable_recv(handle, buf, 15); if(err) print_lc_error(err); for(i = 0; i < 15; i++) printf("%02x ", buf[i]); printf("\n"); i = 0; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02; buf[i++]=0x05; buf[i++]=0xe0; buf[i++]=0x00; err = ticables_cable_send(handle, buf, i); if(err) print_lc_error(err); // param data for(j = 0; j < 3; j++) { err = ticables_cable_recv(handle, buf, 255); if(err) print_lc_error(err); for(i = 0; i < 16; i++) printf("%02x ", buf[i]); printf("\n"); i = 0; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02; buf[i++]=0x05; buf[i++]=0xe0; buf[i++]=0x00; err = ticables_cable_send(handle, buf, i); if(err) print_lc_error(err); } { err = ticables_cable_recv(handle, buf, 36); if(err) print_lc_error(err); for(i = 0; i < 16; i++) printf("%02x ", buf[i]); printf("\n"); i = 0; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x00; buf[i++]=0x02; buf[i++]=0x05; buf[i++]=0xe0; buf[i++]=0x00; err = ticables_cable_send(handle, buf, i); if(err) print_lc_error(err); } PAUSE(500); #endif #if 0 // do a simple test with a TI89/92+ calculator buf[0] = 0x08; buf[1] = 0x68; buf[2] = 0x00; buf[3] = 0x00; // RDY err = ticables_cable_send(handle, buf, 4); if(err) print_lc_error(err); // display answer memset(buf, 0xff, 4); err = ticables_cable_recv(handle, buf, 4); if(err) print_lc_error(err); for(i = 0; i < 4; i++) printf("%02x ", buf[i]); printf("\n"); #endif #if 0 // do a screendump buf[0] = 0x08; buf[1] = 0x6D; buf[2] = 0x00; buf[3] = 0x00; // SCR err = ticables_cable_send(handle, buf, 4); if(err) print_lc_error(err); memset(buf, 0xff, 4); err = ticables_cable_recv(handle, buf, 4); // ACK if(err) print_lc_error(err); err = ticables_cable_recv(handle, scr, 0x0f00 + 6); // XDP if(err) print_lc_error(err); printf("%02x %02x\n", scr[2], scr[3]); buf[0] = 0x08; buf[1] = 0x56; buf[2] = 0x00; buf[3] = 0x00; // ACK err = ticables_cable_send(handle, buf, 4); if(err) print_lc_error(err); #endif #if 0 // simple test for data arrival detection buf[0] = 0x08; buf[1] = 0x87; buf[2] = 'A'; buf[3] = 0x00; // KEY err = ticables_cable_send(handle, buf, 4); if(err) print_lc_error(err); for(status = 0; !status;) { err = ticables_cable_check(handle, &status); if(err) print_lc_error(err); } // display answer memset(buf, 0xff, 4); err = ticables_cable_recv(handle, buf, 4); if(err) print_lc_error(err); for(i = 0; i < 4; i++) printf("%02x ", buf[i]); printf("\n"); #endif #if 0 for(status = 0; !status;) { //fprintf(stdout, "$\n"); //fflush(stdout); err = ticables_cable_check(handle, &status); if(err) print_lc_error(err); } // display answer memset(buf, 0xff, 4); err = ticables_cable_recv(handle, buf, 4); if(err) print_lc_error(err); for(i = 0; i < 4; i++) printf("%02x ", buf[i]); printf("\n"); #endif // close cable ticables_cable_close(handle); // release handle ticables_handle_del(handle); // exit lib ticables_library_exit(); #ifdef __WIN32__ while(!kbhit()); #endif return 0; }
/* This function must be the first function to call in your function 'main'. It initializes the TiLP core engine. */ int tilp_init(int *argc, char ***argv) { /* Display program version */ tilp_cmdline_version(); /* Initialize platform independant paths */ tilp_paths_init(); /* Init i18n support */ #ifdef ENABLE_NLS tilp_info("setlocale: %s", setlocale(LC_ALL, "")); tilp_info("bindtextdomain: %s", bindtextdomain(PACKAGE, inst_paths.locale_dir)); bind_textdomain_codeset(PACKAGE, "UTF-8"/*"ISO-8859-15"*/); tilp_info("textdomain: %s", textdomain(PACKAGE)); #endif /* Initialize callbacks with default functions */ tilp_gif_set_default(); /* Initialize/reload config */ tilp_config_default(); tilp_config_read(); /* Scan and modify command line and change to working folder*/ tilp_cmdline_scan(argc, argv); tilp_file_chdir(options.working_dir); /* Catch 'Ctrl-C' */ signal(SIGINT, signal_handler); /* Check the version of libraries and init framework */ if (strcmp(ticonv_version_get(), TILP_REQUIRES_LIBCONV_VERSION) < 0) tilp_error(_("libticonv library version is %s but %s mini required.\n"), ticonv_version_get(), TILP_REQUIRES_LIBCONV_VERSION); if (strcmp(tifiles_version_get(), TILP_REQUIRES_LIBFILES_VERSION) < 0) tilp_error(_("libtifiles library version is %s but %s mini required.\n"), tifiles_version_get(), TILP_REQUIRES_LIBFILES_VERSION); if (strcmp(ticables_version_get(), TILP_REQUIRES_LIBCABLES_VERSION) < 0) tilp_error(_("libticables library version is %s but %s mini required.\n"), ticables_version_get(), TILP_REQUIRES_LIBCABLES_VERSION); if (strcmp(ticalcs_version_get(), TILP_REQUIRES_LIBCALCS_VERSION) < 0) tilp_error(_("libticalcs library version is %s but %s mini required.\n"), ticalcs_version_get(), TILP_REQUIRES_LIBCALCS_VERSION); ticables_library_init(); tifiles_library_init(); ticalcs_library_init(); /* Check for USB support */ options.usb_avail = ticables_is_usb_enabled(); /* Set cable & calc */ if(options.auto_detect && options.usb_avail) { int ret; CableModel cable; CalcModel calc; CablePort port; ret = tilp_device_probe_usb(&cable, &port, &calc); if(!ret) { options.cable_model = cable; options.cable_port = port; options.calc_model = calc; } } tilp_device_open(); /* If we are in command line mode, does the required operation and exit else fallback on a graphic interface. */ if((working_mode & MODE_CMD) && !(working_mode & MODE_GUI)) { int ret; ret = tilp_cmdline_send(); exit(ret); } else if(working_mode == MODE_INI) exit(0); return 0; }