📄 gformat.htm
字号:
strcat(sspeed_idt,"%");
inregs.h.ah=0x2;
inregs.h.bh=0;
inregs.h.dh=23;
inregs.h.dl=0;
int86(0x10,&inregs,&outregs);
while(*sspeed_idt)
{
inregs.h.ah=0xE;
inregs.h.bh=0;
inregs.h.bl=6;
inregs.h.al=*sspeed_idt++;
int86(0x10,&inregs,&outregs);
}
}
/*将DOS引导扇区的信息写入到磁盘*/
dosboot.jmp_instruction[0]=-21; /*跳转指令*/
dosboot.jmp_instruction[1]=60;
dosboot.jmp_instruction[2]=-112;
strcpy(dosboot.oem_name,"XMG 1.0"); /*软件厂商及版本号*/
dosboot.bpb.bytes_per_sector=bytes_per_sector; /*每扇区字节数*/
dosboot.bpb.sectors_per_cluster=sectors_per_cluster;/*每簇扇区数*/
dosboot.bpb.number_of_reserved_sectors=number_of_reserved_sectors;/*保留扇区数*/
dosboot.bpb.number_of_FATs=number_of_FATs; /*文件分配表数*/
dosboot.bpb.maximum_number_of_root_entries=maximum_number_of_root_entries;/*根目录中目录项数*/
if(part_size<=32*(1048576/512))
{
dosboot.bpb.total_number_of_sectors=total_number_of_sectors; /*总扇区数*/
dosboot.bpb.total_huge_sectors=0; /*巨扇区数*/
}
else
{
dosboot.bpb.total_number_of_sectors=0;
dosboot.huge_sectors=total_number_of_sectors;
}
dosboot.bpb.media_descriptor=media_descriptor; /*磁盘介质标志*/
dosboot.bpb.sectors_per_FAT=sectors_per_FAT; /*每FAT字节数*/
dosboot.bpb.sectors_per_track=sectors_per_track; /*每磁道扇区数*/
dosboot.bpb.number_of_heads=number_of_heads; /*磁头树*/
dosboot.bpb.number_of_hidden_sectors=number_of_hidden_sectors;/*隐藏扇区数*/
dosboot.drive_no=0x80+drive_no-1; /*驱动器号*/
dosboot.boot_signature=0x29; /*扩展标志*/
dosboot.volume_id=volume_id; /*卷序列号*/
strcpy(dosboot.volume_label,""); /*卷标志*/
strcpy(dosboot.file_system_type,"FAT16"); /*文件系统类型*/
fp=fopen("\\os\\format\\load.bin","rb"); /* 加载程序*/
if(fp==NULL)
printf("\nCan't open load file!\n");
else
{
fread(dosboot.loader,1,450,fp);
fclose(fp);
}
}
inregs.h.ah=0x3;
inregs.h.al=1;
inregs.h.ch=priboot.part[rpno].beginning_cylinder;
inregs.h.cl=priboot.part[rpno].beginning_sector;
inregs.h.dh=priboot.part[rpno].beginning_head;
inregs.h.dl=0x80+drive_no-1;
inregs.x.bx=(unsigned)&dosboot;
segread(&segs);
int86x(013,&inregs,&outregs,&segs);
/*初始化目录缓冲区*/
direntry=(DirEntry*)malloc(bytes_per_sector);
for(i=0;i<bytes_per_sector/32;i++)
{
direntry[i].filename[0]=0x0;
direntry[i].extension[0]=0x0;
direntry[i].fileattributes=0x0;
direntry[i].time_stamp=0;
direntry[i].data_stamp=0;
direntry[i].starting_cluster=0;
direntry[i].file_size=0;
}
/*根目录区起始位置*/
ttcylinder2=bcylinder+(bsector+1+sectors_per_FAT*number_of_FATs-1)/sector_count/head_count;
tthead2=(bhead+(bsector+1+sectors_per_FAT*number_of_FATs-1)/sector_count)%head_count;
ttsector2=(bsector+1+sectors_per_FAT*number_of_FATs-1)%sector_count+1;/*初始化根目录区*/
for(i=0;i<maximum_number_of_root_entries*32/bytes_per_sector;i++)
{
inregs.h.ah=0x3;
inregs.h.al=1;
inregs.h.ch=ttcylinder2;
inregs.h.cl=ttsector2;
inregs.h.dh=tthead2;
inregs.h.dl=0x80+drive_no-1;
inregs.x.bx=(unsigned)direntry;
segread(&segs);
int86x(0x13,&inregs,&outregs,&segs);
ttsector2++;
if(ttsector2>sector_count)
{
ttsector2=1;
tthead2++;
if(tthead2>head_count-1)
{
tthead2=0;
ttcylinder2++;
}
}
}
}
return;
}
//////////////////////////////////////////////////////////
(3)\tc\xmg\format\gformat.h
#ifndef XM_FORMAT_H
#define XM_FORMAT_H
typedef struct Part_Entrytag{
char part_flag;
char beginning_head;
char beginning_sector;
char beginning_cylinder;
char file_system;
char ending_head;
char ending_sector;
long first_sector;
long sector_count;
}Part_Entry;
typedef struct BootSectortag{
unsigned loader[120];
unsigned reserved1[103];
Part_Entry part[4];
unsigned end_flag;
}BootSector;
typedef struct BPBtag{
unsigned bytes_per_sector;
char sectors_per_cluster;
unsigned number_of_reserved_sectors;
char number_of_FATs;
unsigned maximum_number_of_root_entries;
unsigned total_number_of_sectors;
char media_descriptor;
unsigned sectors_per_FAT;
unsigned sectors_per_track;
unsigned number_of_heads;
long number_of_hidden_sectors;
}BPB;
typedef struct DOSBootSectorstag{
char jmp_instruction[3];
char oem_name[8];
BPB bpb;
long huge_sectors;
char drive_no;
char reserved;
char boot_signature;
long volume_id;
char volume_label[11];
char file_system_type[8];
char loader[450];
}DOSBootSector;
typedef struct FAT16tag{
unsigned item[256];
}FAT16;
typedef struct DirEntrytag{
char filename[8];
char extension[3];
char fileattributes;
char reserved[10];
unsigned date_stamp;
unsigned time_stamp;
unsigned starting_cluster;
long file_size;
}DirEntry;
typedef struct Format_Idtag{
char cylinder;
char head;
char sector;
char sectorlength;
}Format_Id;
/*
typedef struct FDPBtag{
char step_speed;
char loade_time;
char wait_time;
char bytes_per_sector;
char sectors_per_track;
char number_of_dis_sectors;
char bytes_per_sector2;
char number_of_fmt_dis_sectors;
char fill_bytes;
char wait_time2;
char wait_time3;
}FDPB;
typedef struct FBootSectortag{
char jmp_instructon[3];
char oem_name[8];
BPB bpb;
char reserved;
FDPB fdpb;
char loader[486];
}FBootSector;
*/
#endif
///////////////////////////////////////////////////////////////
(4) \tc\xmg\format\genfunc.c
#include<dos.h>
#include<stdio.h>
#include<genfunc.h>
int a16toi10(char* a16)
{
int nlen;
int i;
int tt,ttm;
int res;
nlen=strlen(a16);
ttm=1;
res=0;
for(i=0;i<nlen;i++)
{
tt=a16[nlen-1-i];
if(tt>=48&&tt<=57)
res+=tt%48*ttm;
else if(tt>=65&&tt<=70)
res+=(tt%65+10)*ttm;
else if(tt>=97&&tt<=102)
res+=(tt%97+10)*ttm;
else return -1;
ttm*=16;
}
return res;
}
void Textout(int y,int x,char* text)
{
union REGS inregs,outregs;
while(*text)
{
inregs.h.ah=0x2;
inregs.h.bh=0;
inregs.h.dh=y;
inregs.h.dl=x+y;
int86(0x10,&inregs,&outregs);
inregs.h.ah=0xA;
inregs.h.bh=0;
inregs.h.bl=16;
inregs.h.al=*text++;
inregs.x.cx=1;
int86(0x10,&inregs,&outregs);
}
}
void ClearScreen(void)
{
union REGS inregs,outregs;
int i,j;
char* letter=" ";
inregs.h.ah=0x2;
inregs.h.bh=0;
inregs.h.dh=0;
inregs.h.dl=0;
int86(0x10,&inregs,&outregs);
for(i=0;i<25;i++)
{
for(j=0;j<80;j++)
{
inregs.h.ah=0xE;
inregs.h.al=*letter;
inregs.h.bh=0;
inregs.h.bl=0;
int86(0x10,&inregs,&outregs);
}
}
inregs.h.ah=0x2;
inregs.h.bh=0;
inregs.h.dh=0;
inregs.h.dl=0;
int86(0x10,&inregs,&outregs);
return;
}
//////////////////////////////////////////////////////////
(5) \tc\xmg\format\genfunc.h
#ifdef XM_GENFUNC_H
#define XM_GENFUNC_H
int a16to10(char* a16);
void Textout(int ,int ,char*);
void ClearScreen(void);
#endif</PRE><!-- CoreMail Version 2.5 Copyright (c) 2002-2005 www.mailtech.cn --></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -