Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////////////
- // This file is LEEPAR
- // Creation date is sometime in the 90's by Miguel Angel Rodriguez Jodar
- // (c)2020 Miguel Angel Rodriguez Jodar. ZXProjects
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this core. If not, see <https://www.gnu.org/licenses/>.
- //
- // All copies of this file must keep this notice intact.
- //
- //////////////////////////////////////////////////////////////////////////////////
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <string.h>
- #include <dos.h>
- #include <bios.h>
- int base;
- #define DATOS (base)
- #define ESTADO (DATOS+1)
- #define CONTROL (DATOS+2)
- void main (int argc, char *argv[])
- {
- char *buffer;
- FILE *f;
- int fin;
- char dato;
- int *dpuerto;
- unsigned long i=0;
- dpuerto=MK_FP (0x40, 0x8);
- base=*dpuerto;
- if (argc<2)
- {
- printf ("Uso: LEEPAR fichero\n");
- exit(1);
- }
- printf ("Encontrado puerto parlelo en %04.4X\n", base);
- buffer=malloc(512);
- f=fopen (argv[1], "wb");
- fin=0;
- while (!fin)
- {
- outp (CONTROL, 0x22); //autofeed=1, el en otro lado, busy=1
- while ((inp(ESTADO) & 0x40))
- {
- if (kbhit())
- if (getch()==27)
- {
- fin=1;
- break;
- }
- }
- outp (CONTROL, 0x20);
- dato=inp (DATOS);
- fwrite (&dato, 1, 1, f);
- printf ("Leidos %lu bytes \r", ++i);
- while ((inp(ESTADO) & 0x40)==0)
- {
- if (kbhit())
- if (getch()==27)
- {
- fin=1;
- break;
- }
- }
- }
- fclose(f);
- free(buffer);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement