diff options
Diffstat (limited to 'v4.0/src/SELECT/INT13.C')
| -rw-r--r-- | v4.0/src/SELECT/INT13.C | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/v4.0/src/SELECT/INT13.C b/v4.0/src/SELECT/INT13.C new file mode 100644 index 0000000..daf32c2 --- /dev/null +++ b/v4.0/src/SELECT/INT13.C | |||
| @@ -0,0 +1,194 @@ | |||
| 1 | |||
| 2 | #include "stdio.h" /* ;AN000; */ | ||
| 3 | #include "stdlib.h" /* ;AN000; */ | ||
| 4 | #include "string.h" /* ;AN000; */ | ||
| 5 | #include "dos.h" /* ;AN000; */ | ||
| 6 | #include "get_stat.h" /* ;AN000; */ | ||
| 7 | #include "extern.h" /* ;AN000; */ | ||
| 8 | /* ;AN000; */ | ||
| 9 | char read_boot_record(unsigned,unsigned char,unsigned char,unsigned char); /* ;AN000; */ | ||
| 10 | void DiskIo(union REGS *,union REGS *, struct SREGS *); /* ;AN000; */ | ||
| 11 | unsigned cylinders_to_mbytes(unsigned,unsigned char,unsigned char); /* ;AN000; */ | ||
| 12 | char get_drive_parameters(unsigned char); /* ;AN000; */ | ||
| 13 | char get_disk_info(void); /* ;AN000; */ | ||
| 14 | /* ;AN000; */ | ||
| 15 | /* */ /* ;AN000; */ | ||
| 16 | char get_disk_info() /* ;AN000; */ | ||
| 17 | /* ;AN000; */ | ||
| 18 | BEGIN /* ;AN000; */ | ||
| 19 | /* ;AN000; */ | ||
| 20 | unsigned char i; /* ;AN000; */ | ||
| 21 | /* ;AN000; */ | ||
| 22 | /* Initialize values */ /* ;AN000; */ | ||
| 23 | number_of_drives = uc(0); /* ;AN000; */ | ||
| 24 | for (i=uc(0); i < uc(2); i++) /* ;AN000; */ | ||
| 25 | BEGIN /* ;AN000; */ | ||
| 26 | total_disk[i] = u(0); /* ;AN000; */ | ||
| 27 | total_mbytes[i] = f(0); /* ;AN000; */ | ||
| 28 | max_sector[i] = uc(0); /* ;AN000; */ | ||
| 29 | max_head[0] = uc(0); /* ;AN000; */ | ||
| 30 | END /* ;AN000; */ | ||
| 31 | /* ;AN000; */ | ||
| 32 | /* See how many drives there are */ /* ;AN000; */ | ||
| 33 | if (get_drive_parameters(uc(0x80))) /* ;AN000; */ | ||
| 34 | /* ;AN000; */ | ||
| 35 | BEGIN /* ;AN000; */ | ||
| 36 | /* Get the drive parameters for all drives */ /* ;AN000; */ | ||
| 37 | for (i = uc(0); i < number_of_drives;i++) /* ;AN000; */ | ||
| 38 | /* ;AN000; */ | ||
| 39 | BEGIN /* ;AN000; */ | ||
| 40 | if (get_drive_parameters(uc(0x80)+i)) /* ;AN000; */ | ||
| 41 | /* ;AN000; */ | ||
| 42 | BEGIN /* ;AN000; */ | ||
| 43 | /* Save drive parameters */ /* ;AN000; */ | ||
| 44 | max_sector[i] = ((unsigned char)(regs.h.cl & 0x3F)); /* ;AN000; */ | ||
| 45 | max_head[i] = ((unsigned char)(regs.h.dh +1)); /* ;AN000; */ | ||
| 46 | total_disk[i] = ((((unsigned)(regs.h.cl & 0xC0 )) & 0x00C0) << 2)+ ((unsigned)regs.h.ch) +1; /* ;AN000; */ | ||
| 47 | total_mbytes[i] = cylinders_to_mbytes(total_disk[i], max_sector[i], max_head[i]); /* ;AN000; */ | ||
| 48 | END /* ;AN000; */ | ||
| 49 | else /* ;AN000; */ | ||
| 50 | BEGIN /* ;AN000; */ | ||
| 51 | good_disk[i] = FALSE; /* ;AN000; */ | ||
| 52 | return(FALSE); /* ;AN000; */ | ||
| 53 | END /* ;AN000; */ | ||
| 54 | END /* ;AN000; */ | ||
| 55 | return(TRUE); /* ;AN000; */ | ||
| 56 | END /* ;AN000; */ | ||
| 57 | else /* ;AN000; */ | ||
| 58 | /* No drives present */ /* ;AN000; */ | ||
| 59 | BEGIN /* ;AN000; */ | ||
| 60 | no_fatal_error = FALSE; /* ;AN000; */ | ||
| 61 | return(FALSE); /* ;AN000; */ | ||
| 62 | END /* ;AN000; */ | ||
| 63 | END /* ;AN000; */ | ||
| 64 | /* ;AN000; */ | ||
| 65 | /* ;AN000; */ | ||
| 66 | /* ;AN000; */ | ||
| 67 | /* ;AN000; */ | ||
| 68 | /* */ /* ;AN000; */ | ||
| 69 | char get_drive_parameters(drive) /* ;AN000; */ | ||
| 70 | /* ;AN000; */ | ||
| 71 | unsigned char drive; /* ;AN000; */ | ||
| 72 | /* ;AN000; */ | ||
| 73 | BEGIN /* ;AN000; */ | ||
| 74 | /* See how many drives there are */ /* ;AN000; */ | ||
| 75 | regs.h.ah = uc(DISK_INFO); /* ;AN000; */ | ||
| 76 | regs.h.dl = drive; /* ;AN000; */ | ||
| 77 | DiskIo(®s,®s,&segregs); /* ;AN000; */ | ||
| 78 | /* ;AN000; */ | ||
| 79 | /* See if any drives exist */ /* ;AN000; */ | ||
| 80 | if ((regs.h.dl == uc(0)) || ((regs.x.cflag & 1) == u(1))) /* ;AN000; */ | ||
| 81 | BEGIN /* ;AN000; */ | ||
| 82 | return(FALSE); /* ;AN000; */ | ||
| 83 | END /* ;AN000; */ | ||
| 84 | else /* ;AN000; */ | ||
| 85 | BEGIN /* ;AN000; */ | ||
| 86 | /* Save the number of drives */ /* ;AN000; */ | ||
| 87 | number_of_drives = regs.h.dl; /* ;AN000; */ | ||
| 88 | if (number_of_drives < 2) good_disk[1] = FALSE; /* ;AN000; */ | ||
| 89 | if (number_of_drives < 1) good_disk[0] = FALSE; /* ;AN000; */ | ||
| 90 | return(TRUE); /* ;AN000; */ | ||
| 91 | END /* ;AN000; */ | ||
| 92 | /* ;AN000; */ | ||
| 93 | END /* ;AN000; */ | ||
| 94 | /* ;AN000; */ | ||
| 95 | /* */ /* ;AN000; */ | ||
| 96 | char read_boot_record(cylinder,which_disk,which_head,which_sector) /* ;AN000; */ | ||
| 97 | /* ;AN000; */ | ||
| 98 | unsigned cylinder; /* ;AN000; */ | ||
| 99 | unsigned char which_disk; /* ;AN000; */ | ||
| 100 | unsigned char which_head; /* ;AN000; */ | ||
| 101 | unsigned char which_sector; /* ;AN000; */ | ||
| 102 | /* ;AN000; */ | ||
| 103 | BEGIN /* ;AN000; */ | ||
| 104 | /* ;AN000; */ | ||
| 105 | char far *buffer_pointer = boot_record; /* ;AN000; */ | ||
| 106 | /* ;AN000; */ | ||
| 107 | /* Setup read, always on a cylinder boundary */ /* ;AN000; */ | ||
| 108 | regs.h.ah = uc(READ_DISK); /* ;AN000; */ | ||
| 109 | regs.h.al = uc(1); /* ;AN000; */ | ||
| 110 | regs.h.dh = which_head; /* ;AN000; */ | ||
| 111 | regs.h.cl = which_sector; /* ;AN000; */ | ||
| 112 | /* ;AN000; */ | ||
| 113 | /* Specify the disk */ /* ;AN000; */ | ||
| 114 | regs.h.dl = which_disk + 0x80; /* ;AN000; */ | ||
| 115 | /* ;AN000; */ | ||
| 116 | /* Need to scramble CX so that sectors and cyl's are in INT 13 format */ /* ;AN000; */ | ||
| 117 | /* ;AN000; */ | ||
| 118 | if (cylinder > u(255)) /* ;AN000; */ | ||
| 119 | BEGIN /* ;AN000; */ | ||
| 120 | regs.h.cl = regs.h.cl | ((char)((cylinder /256) << 6)); /* ;AN000; */ | ||
| 121 | END /* ;AN000; */ | ||
| 122 | regs.h.ch = (unsigned char)(cylinder & 0xFF); /* ;AN000; */ | ||
| 123 | /* ;AN000; */ | ||
| 124 | /* Point at the place to write the boot record */ /* ;AN000; */ | ||
| 125 | regs.x.bx = FP_OFF(buffer_pointer); /* ;AN000; */ | ||
| 126 | segregs.es = FP_SEG(buffer_pointer); /* ;AN000; */ | ||
| 127 | /* ;AN000; */ | ||
| 128 | /* read in the boot record */ /* ;AN000; */ | ||
| 129 | DiskIo(®s,®s,&segregs); /* ;AN000; */ | ||
| 130 | /* Check for error reading it */ /* ;AN000; */ | ||
| 131 | if ((regs.x.cflag & 1) != u(1)) /* ;AN000; */ | ||
| 132 | BEGIN /* ;AN000; */ | ||
| 133 | return(TRUE); /* ;AN000; */ | ||
| 134 | END /* ;AN000; */ | ||
| 135 | else /* ;AN000; */ | ||
| 136 | BEGIN /* ;AN000; */ | ||
| 137 | /* Tell user there was an error */ /* ;AN000; */ | ||
| 138 | good_disk[which_disk] = FALSE; /* ;AN000; */ | ||
| 139 | return(FALSE); /* ;AN000; */ | ||
| 140 | END /* ;AN000; */ | ||
| 141 | END /* ;AN000; */ | ||
| 142 | /* ;AN000; */ | ||
| 143 | /* */ /* ;AN000; */ | ||
| 144 | void DiskIo(InRegs,OutRegs,SegRegs) /* ;AN000; */ | ||
| 145 | union REGS *InRegs; /* ;AN000; */ | ||
| 146 | union REGS *OutRegs; /* ;AN000; */ | ||
| 147 | struct SREGS *SegRegs; /* ;AN000; */ | ||
| 148 | /* ;AN000; */ | ||
| 149 | BEGIN /* ;AN000; */ | ||
| 150 | /* ;AN000; */ | ||
| 151 | char *WritePtr; /* ;AN000; */ | ||
| 152 | /* ;AN000; */ | ||
| 153 | #ifdef DEBUG /* ;AN000; */ | ||
| 154 | /* ;AN000; */ | ||
| 155 | switch(InRegs->h.ah) /* ;AN000; */ | ||
| 156 | { /* ;AN000; */ | ||
| 157 | case 0: /* ;AN000; */ | ||
| 158 | case 1: /* ;AN000; */ | ||
| 159 | case 2: /* ;AN000; */ | ||
| 160 | case 4: /* ;AN000; */ | ||
| 161 | case 8: /* ;AN000; */ | ||
| 162 | case 15: /* ;AN000; */ | ||
| 163 | case 16: /* ;AN000; */ | ||
| 164 | int86x((int)DISK,InRegs,OutRegs,SegRegs); /* ;AN000; */ | ||
| 165 | break; /* ;AN000; */ | ||
| 166 | /* ;AN000; */ | ||
| 167 | default: /* ;AN000; */ | ||
| 168 | WritePtr = getenv("WRITE"); /* ;AN000; */ | ||
| 169 | if (strcmpi(WritePtr,"ON") != 0) /* ;AN000; */ | ||
| 170 | BEGIN /* ;AN000; */ | ||
| 171 | printf("\nDisallowing Disk I/O Request\n"); /* ;AN000; */ | ||
| 172 | printf("AX:%04X BX:%04X CX:%04X DX:%04X ES:%04X\n", /* ;AN000; */ | ||
| 173 | InRegs->x.ax,InRegs->x.bx,InRegs->x.cx,InRegs->x.dx,SegRegs->es); /* ;AN000; */ | ||
| 174 | /* ;AN000; */ | ||
| 175 | OutRegs->h.ah = (unsigned char) 0; /* ;AN000; */ | ||
| 176 | OutRegs->x.cflag = (unsigned) 0; /* ;AN000; */ | ||
| 177 | END /* ;AN000; */ | ||
| 178 | else int86x((int)DISK,InRegs,OutRegs,SegRegs); /* ;AN000; */ | ||
| 179 | /* ;AN000; */ | ||
| 180 | break; /* ;AN000; */ | ||
| 181 | /* ;AN000; */ | ||
| 182 | } /* ;AN000; */ | ||
| 183 | /* ;AN000; */ | ||
| 184 | #else /* ;AN000; */ | ||
| 185 | /* ;AN000; */ | ||
| 186 | int86x((int)DISK,InRegs,OutRegs,SegRegs); /* ;AN000; */ | ||
| 187 | /* ;AN000; */ | ||
| 188 | #endif /* ;AN000; */ | ||
| 189 | /* ;AN000; */ | ||
| 190 | return; /* ;AN000; */ | ||
| 191 | /* ;AN000; */ | ||
| 192 | END /* ;AN000; */ | ||
| 193 | /* ;AN000; */ | ||
| 194 | \ No newline at end of file | ||