Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////////////
- // This file is HDIMAGE
- // 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.
- //
- //////////////////////////////////////////////////////////////////////////////////
- // Compile with Turbo C 2.0 for DOS
- #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)
- int obtener_parametros_disco (int unidad, unsigned *cilindros, unsigned *cabezas, unsigned *sectores)
- {
- int nc,nh,ns,estado;
- estado=nc=ns=nh=0;
- asm push bx
- asm push cx
- asm push dx
- asm push si
- asm push di
- asm mov ah,8
- asm mov dl,byte ptr unidad
- asm int 13h
- asm mov byte ptr estado,ah
- asm mov byte ptr ns,cl
- asm and cl,0c0h
- asm shr cl,6
- asm xchg cl,ch
- asm inc cx
- asm mov nc,cx
- asm inc dh
- asm mov byte ptr nh,dh
- asm pop di
- asm pop si
- asm pop dx
- asm pop cx
- asm pop bx
- ns&=0x3f;
- *cilindros=nc;
- *cabezas=nh;
- *sectores=ns;
- return estado;
- }
- void escribe_paralelo (char *buffer, int tam)
- {
- int i;
- char dato;
- for (i=0;i<tam;i++)
- {
- dato=buffer[i];
- while ((inp(ESTADO) & 0x80)==0)
- {
- if (kbhit())
- if (getch()==27)
- exit(1);
- }
- outp (DATOS, dato);
- outp (CONTROL, 1);
- while (inp(ESTADO) & 0x80)
- {
- if (kbhit())
- if (getch()==27)
- exit(1);
- }
- outp (CONTROL, 0);
- }
- }
- void main (int argc, char *argv[])
- {
- unsigned unidad, cilindros, cabezas, sectores;
- unsigned cylact, cabact, secact, estado;
- unsigned long total;
- int *dpuerto;
- char *buffer;
- dpuerto=MK_FP (0x40, 0x8);
- base=*dpuerto;
- unidad=atoi(argv[1]);
- estado=obtener_parametros_disco (unidad, &cilindros, &cabezas, §ores);
- if (argc<5 && estado!=0)
- {
- printf ("Uso: HDIMAGE unidad cilindros cabezas sectores\n");
- exit(1);
- }
- if (argc>=5)
- {
- cilindros=atoi(argv[2]);
- cabezas=atoi(argv[3]);
- sectores=atoi(argv[4]);
- }
- buffer=malloc(sectores*512);
- printf ("Se ha encontrado un puerto paralelo en %04.4X\n", base);
- printf ("Se va a proceder a leer desde la unidad %02.2X, con geometr¡a: %4u cilindros, %4u cabezas, %4u sectores por pista\n",
- unidad, cilindros, cabezas, sectores);
- total=(unsigned long)cilindros*(unsigned long)cabezas*(unsigned long)sectores;
- printf ("Se transferiran %lu Mb.\n", total/2048);
- printf ("Continuar? (S/N)");
- if (getch()!='s')
- exit(1);
- printf ("\n\n");
- for (cylact=0;cylact<cilindros;cylact++)
- {
- for (cabact=0;cabact<cabezas;cabact++)
- {
- for (secact=1;secact<=sectores;secact++)
- {
- estado=biosdisk(2,unidad,cabact,cylact,secact,1,buffer);
- if (estado)
- {
- printf ("\n\nERROR!!! No se pudo leer el disco. (C=%d,H=%d,S=%d)\n",cylact,cabact,secact);
- exit(1);
- }
- escribe_paralelo (buffer,512);
- printf ("Realizado el %d %% de la operacion... (%u:%u:%u) \r", cylact*100/(cilindros-1), cylact, cabact, secact);
- }
- }
- }
- free(buffer);
- }
Add Comment
Please, Sign In to add comment