umm well i havent quite made a read_fat_file function but i have made this
Code:
unsigned char* read_disk(drive_params t) /*reads a single sector and returns it */
{
byte ret[512];
byte temp;
word tmp2;
word tmp3;
byte tmp;
asm mov tmp3,cs
asm mov es,tmp3
tmp2=&ret;
asm mov bx,tmp2
asm mov ah,0x02
asm mov al,1
asm mov ch,t.cylinder
asm mov cl,t.sector
asm mov dh,t.head
asm mov dl,t.drive
asm mov ah,0x02
asm int 0x13
asm mov temp,ah
if (temp>0x00) {
ret[0]=temp;
}
return ret;
}
byte write_disk(drive_params t,byte data[512]) /*writes a single sector*/
{
byte ret2;
byte temp;
word tmp2;
dword tmp3;
asm mov tmp3,cs
asm mov es,tmp3
tmp2=&*data;
asm mov bx,tmp2
asm mov ah,0x03
asm mov al,1
asm mov ch,t.cylinder
asm mov cl,t.sector
asm mov dh,t.head
asm mov dl,t.drive
asm mov ah,0x03
asm int 0x13
asm mov ret2,ah
temp=ret2;
return ret2;
}
void testing(void) /*just a reserved function for testing junk*/
{
byte tmp2;
drive_params t;
t.cylinder=0;
t.head=0;
t.sector=1;
t.drive=0x00;
reset_disks(0x00);
*tmp5="hi";
tmp2=write_disk(t,*tmp5);
*tmp5=read_disk(t);
printf(*tmp5);
if (streq(*tmp5,"hi")==1) { printf("yay!");}
/*try using get the address rather than return the var
/*asm mov WORD [es:20*4+2], CS omg that actually works*/
/*U IDIOT u never did write hi to disk*/
}
it reads/writes a single sector into/from a C 512 byte character array