int mccl_read (const char *filename, unsigned int parport) { unsigned char buffer[0x1760], inbyte; char dest_name[FILENAME_MAX]; int count = 0; time_t starttime; parport_print_info (); puts ("Resetting device"); do { outportb (CONTROL, 0x24); while ((inportb (STATUS) & 0x20) == 0) ; } while ((inportw (DATA) & 0xf) != 4); outportb (CONTROL, 0x22); while ((inportb (STATUS) & 0x20) != 0) ; outportb (CONTROL, 0x26); printf ("Receive: %d Bytes (%.4f Mb)\n\n", 0x1760, (float) 0x1760 / MBIT); starttime = time (NULL); do { outportb (CONTROL, 0x26); while ((inportb (STATUS) & 0x20) == 0) ; inbyte = (unsigned char) (inportw (DATA) & 0xf); outportb (CONTROL, 0x22); while ((inportb (STATUS) & 0x20) != 0) ; outportb (CONTROL, 0x26); while ((inportb (STATUS) & 0x20) == 0) ; inbyte |= (unsigned char) ((inportw (DATA) & 0xf) << 4); outportb (CONTROL, 0x22); while ((inportb (STATUS) & 0x20) != 0) ; buffer[count++] = inbyte; if ((count & 0x1f) == 0) ucon64_gauge (starttime, count, 0x1760); } while (count < 0x1760); strcpy (dest_name, filename); ucon64_file_handler (dest_name, NULL, 0); ucon64_fwrite (buffer, 0, count, dest_name, "wb"); printf (ucon64_msg[WROTE], dest_name); return 0; }
void ttt_init_io (unsigned int port) { #if (defined __unix__ || defined __BEOS__) && !defined __MSDOS__ init_conio (); #endif port_8 = port; // original code used 0x378 for port_8 port_9 = port + 1; port_a = port + 2; port_b = port + 3; port_c = port + 4; parport_print_info (); init_port (); }
int mcd_read_rom (const char *filename, unsigned short parport) { FILE *file; unsigned char buffer[BUFFERSIZE]; int n_bytes = 0, size; time_t starttime; #if (defined __unix__ || defined __BEOS__) && !defined __MSDOS__ init_conio (); if (register_func (deinit_conio) == -1) { fputs ("ERROR: Could not register function with register_func()\n", stderr); exit (1); } #endif parport_print_info (); if ((file = fopen (filename, "wb")) == NULL) { fprintf (stderr, ucon64_msg[OPEN_WRITE_ERROR], filename); exit (1); } read_block (buffer, 1, parport); size = (buffer[0] + 1) * 64 * 1024; printf ("Receive: %d Bytes (%.4f Mb)\n\n", size, (float) size / MBIT); puts ("Press q to abort\n"); starttime = time (NULL); while (n_bytes < size) { read_block (buffer, BUFFERSIZE, parport); fwrite (buffer, 1, BUFFERSIZE, file); n_bytes += BUFFERSIZE; ucon64_gauge (starttime, n_bytes, size); checkabort (2); } fclose (file); return 0; }
static struct cd64_t * cd64_init (void) { struct cd64_t *cd64; #ifdef USE_PPDEV uint16_t port = strtol (&ucon64.parport_dev[strlen (ucon64.parport_dev) - 1], NULL, 10); method_t method = PPDEV; #else uint16_t port = ucon64.parport; method_t method = RAWIO; #endif int is_parallel = 1; if ((cd64 = (struct cd64_t *) calloc (1, sizeof (struct cd64_t))) == NULL) { fprintf (stderr, ucon64_msg[BUFFER_ERROR], sizeof (struct cd64_t)); exit (1); } #ifndef USE_PPDEV if (ucon64.parport == (uint16_t) UCON64_UNKNOWN) { fputs ("ERROR: No port or invalid port specified\n" "TIP: Specify one with --port or in the configuration file\n", stderr); exit (1); } if (port >= 0x300 && port <= 0x330) is_parallel = 0; #endif cd64->notice_callback = cd64_notice; cd64->notice_callback2 = cd64_notice2; if (!cd64_create (cd64, method, port, (protocol_t) ucon64.io_mode, is_parallel)) { fputs ("ERROR: Could not initialise libcd64\n", stderr); exit (1); } cd64->read_callback = fread_wrapper; // actually f*2(), if zlib cd64->write_callback = fwrite_wrapper; // support is enabled cd64->tell_callback = ftell_wrapper; cd64->seek_callback = fseek_wrapper; cd64->progress_callback = cd64_progress; strcpy (cd64->io_driver_dir, ucon64.configdir); // parport_print_info() displays a reasonable message (even if we're using a // comms link) parport_print_info (); if (!cd64->devopen (cd64)) { fputs ("ERROR: Could not open I/O device for CD64\n", stderr); exit (1); } #if defined __unix__ && !defined __MSDOS__ drop_privileges (); #endif return cd64; }