home *** CD-ROM | disk | FTP | other *** search
- /* fdins: Install the FDTBL program for various systems. See assembly
- * source code for fdtbl at the bottom of this file.
- *
- * Copyright (C) 1986, 1988 Scott E. Garfinkle. All rights reserved.
- */
-
- #include "part.h"
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <io.h>
- #include <dos.h>
-
- #pragma pack(1)
-
- struct program {
- word init_jump;
- DISK_TABLE fdtbld;
- byte unused1[24];
- word intr_off;
- byte unsused2[3];
- word intr_seg;
- byte unsed3[3];
- byte diskno;
- byte unused4[14];
- } *data;
-
- byte data_tbl[] = {
- 0xEB, 0x10,
- 0x00, 0x04, 0x04, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x11, 0x00,
- 0xBE, 0x02, 0x01, 0xBF, 0x5C, 0x00, 0x8B, 0xC7, 0x8C, 0xCB, 0x8E, 0xC3,
- 0xB9, 0x08, 0x00, 0xFC, 0xF3, 0xA5, 0x33, 0xC9, 0x8E, 0xC1, 0x26, 0xA3,
- 0x04, 0x01,
- 0x26, 0x89, 0x1E,
- 0x06, 0x01,
- 0xB4, 0x09, 0xB2,
- 0x80,
- 0xCD, 0x13, 0xB4, 0x00, 0xCD, 0x13, 0xBA, 0x07, 0x00, 0xB8, 0x00, 0x31,
- 0xCD, 0x21
- };
-
- #define DISK_NO1 0x80
- #define DISK_NO2 0x81
- #define DISK_NO1_LOC 0x41*4
- #define DISK_NO2_LOC 0x46*4
-
- char *prgname = "tbl .com";
-
- main(argc,argv)
- int argc;
- char **argv;
- {
- int i, fd, line_no=4, num_disks;
- union REGS regs;
-
- data = (struct program *)data_tbl;
-
- regs.h.ah = 8;
- regs.h.dl = 0x80;
- int86(0x13, ®s, ®s);
- num_disks = regs.h.dl;
-
- scr_smode(scr_gmode()); /* quick way to clear screen */
- scr_pos(22,0);
- printf("Custom Fixed Disk Installation, Copyright(C) 1986, 1988 S. E. Garfinkle.");
- scr_pos(23,0);
- printf("All rights reserved.");
- i = get_scr_val(line_no++,"Disk number 1 or 2?",1,1,2);
- if (i == 1) {
- data->diskno = DISK_NO1;
- data->intr_off = DISK_NO1_LOC;
- data->intr_seg = DISK_NO1_LOC+2;
- }
- else {
- data->diskno = DISK_NO2;
- data->intr_off = DISK_NO2_LOC;
- data->intr_seg = DISK_NO2_LOC+2;
- }
- if (num_disks >= i)
- data->fdtbld = *(DISK_TABLE far *) _dos_getvect(i==1 ? 0x41 : 0x46);
- prgname[3] = i+'0';
- data->fdtbld.fd_heads = get_scr_val(line_no++,"Number of heads on the disk?",data->fdtbld.fd_heads,0,72);
- data->fdtbld.fd_ncyls = get_scr_val(line_no++,"Number of cylinders (max 1024)?",data->fdtbld.fd_ncyls,20,1024);
- data->fdtbld.fd_control = get_scr_val(line_no++,"Control byte value?",0,0,0xff);
- i = get_scr_val(line_no++,"Are you using an AT (0) or XT (1) compatible?",0,0,1);
- data->fdtbld.fd_write_precomp = get_scr_val(line_no++,
- "Cylinder on which to start write precompensation?", i-1,-1,data->fdtbld.fd_ncyls-1);
- if(i) {
- data->fdtbld.fd_current = get_scr_val(line_no++,
- "Cylinder on which to start write reduced write current?",data->fdtbld.fd_write_precomp,0,data->fdtbld.fd_ncyls-1);
- data->fdtbld.fd_ecc_burst = get_scr_val(line_no++,"ECC Burst length?", 0x0b,0,0xff);
- data->fdtbld.fd_std_time = get_scr_val(line_no++,"Standard timeout value?",0x0c,0,0xff);
- data->fdtbld.fd_format_time = get_scr_val(line_no++,"Timeout value for formatting?",0xb4,0,0xff);
- data->fdtbld.fd_check_time = get_scr_val(line_no++,"Timeout value for checks?",0x28,0,0xff);
- }
- else {
- data->fdtbld.fd_lz = get_scr_val(line_no++,"Cylinder for landing zone?",data->fdtbld.fd_ncyls,0,2048);
- data->fdtbld.fd_sec_per_track = get_scr_val(line_no++,"Number of sector per track?",data->fdtbld.fd_sec_per_track,1,40);
- }
- if((fd=open(prgname,O_CREAT|O_WRONLY|O_TRUNC|O_BINARY,S_IREAD|S_IWRITE)) < 0) {
- fprintf(stderr,"\nCouldn't open %s file.\n",prgname);
- exit(1);
- }
- write(fd,data_tbl,sizeof(struct program));
- close(fd);
- exit(0);
- }
-
- #define ESC 27
- #define BACKSPACE 8
-
- int
- get_scr_val(start, m_str, def_val, low_lim, high_lim)
- int start; /* what line this goes on */
- char *m_str; /* what to say on that line */
- int def_val, /* default value */
- low_lim, /* least acceptable value */
- high_lim; /* highest acceptable value */
- {
- int val, len, len1, len2, len3;
- word pos, row, col, col2;
- char buf[8];
-
- len1 = strlen(itoa(def_val, buf, 10));
- len2 = strlen(itoa(low_lim, buf, 10));
- len3 = strlen(itoa(high_lim, buf, 10));
- len = max(max(len1,len2),len3);
- scr_pos(start,0);
- printf("%s [%*s]",m_str,len," ");
- fflush(stdout);
- pos = scr_rpos(); /* read scr_pos position */
- row = pos >> 8;
- col2 = (pos & 0xff) - 2;
- col = col2-len+1;
- #ifdef DEBUG
- scr_pos(24,0); printf("len %d, row %d, col2 %d",len,row,col2);
- fflush(stdout);
- #endif
- do {
- int c;
-
- val = 0;
- do {
- scr_pos(row, col);
- printf("%*d",len,val ? val : def_val);
- fflush(stdout);
- scr_pos(row, col2);
- c=getch();
- #ifdef DEBUG
- scr_pos(18,0);printf("!! val %d, c %d\n",val,c);fflush(stdout);
- #endif
- switch (c) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if((val = val*10 + c - '0') > high_lim) {
- scr_pos(row+2,0);
- printf("Maximum value is %d.",high_lim);
- sleep(1000L);
- erase_eol(row+2);
- val = 0;
- }
- break;
- case BACKSPACE:
- if(val)
- val /= 10;
- break;
-
- case EOF:
- exit(1); /* assume we need an immediate abort */
- /* NOTREACHED */
-
- /* default: ignore the character. */
-
- } /* end of switch */
- } while (c != '\r' && c != '\n' && c != ESC);
- if(!val)
- val = def_val;
- else if (val<low_lim) {
- scr_pos(row+2,0);
- printf("Minimum value is %d.",low_lim);
- sleep(1000L);
- erase_eol(row+2);
- }
- } while(val<low_lim);
- return(val);
- }
-
- void
- erase_eol(from) /* erase line "from" and stay there */
- word from;
- {
- scr_scroll(from, 0, from, 79, 0, 7);
- scr_pos(from,0);
- }
-
- /*
- ; FDTBL: Create fixed disk table to use instead of default DOS ones.
- ; This version can ONLY be used if you aren't going to use the Diagnostic
- ; routines -- these routines screw up the memory management and overwrite the
- ; table. See accompanying program FDTBLINT if you're going to use the diags.
- ;
- .RADIX 16
- INTR EQU (41*4)
- DISKNO EQU 80
-
- CSEG SEGMENT
- ORG 100
- ASSUME CS:CSEG,DS:CSEG
- BEGIN: JMP SHORT START
- DATA: DW 400 ; number of cylinders
- DB 4 ; number of heads
- DW -1 ; starting reduced write current cylinder (XT only)
- DW -1 ; starting write precompensation cylinder
- DB 0 ; max ECC data burst length (XT only)
- DB 0 ; control byte
- DB 0 ; standard time out value (XT only)
- DB 0 ; format time out value (XT only)
- DB 0 ; check drive time out value (XT only)
- DW 400 ; landing zone cyl (usually same as number of cyl)
- DB 11 ; number of sectors per track (don't change)
- DB 0 ; reserved
- START: MOV SI,OFFSET DATA
- MOV DI,5C
- MOV AX,DI
- MOV BX,CS
- MOV ES,BX
- MOV CX,8
- CLD
- REP MOVSW
- XOR CX,CX
- MOV ES,CX
- MOV ES:[INTR],AX
- MOV ES:[INTR+2],BX
- MOV AH,9 ; "initialize characteristics"
- MOV DL,DISKNO
- INT 13
- MOV AH,0 ; "reset disk"
- INT 13
- MOV DX,7 ; retain 7 paragraphs -- first 70 hex bytes
- MOV AX,3100 ; terminate and stay resident
- INT 21
- CSEG ENDS
- END BEGIN
- */
-