
void int21_makefcb()
{
        /* TODO: most file handler routines assume that files are in the
         *       8.3 format and do not do a check for illegael file names
         */

	/* TODO: this code for fname conversion shouldn't be copy/pasted
	 *       so many times
	 */

	char fname_array[13];
	char *fname = fname_array;
	unsigned int ofs = (es << 4) + di;
	int i,i2;
	
	emumem_fname2mem(fname,ds,dx,12);
	fname[12] = '\0';

	for(i = 0;i < 12;i++)
	{
		fname[i] = tolower(fname[i]);	
	}

	fprintf(report_file,"BHole: makefcb(\"%s\")\n",fname);
	
        SET_MEM_BYTE2(ofs,0); /* should this be 0 or 3 ??? */
	mem2emudmem(ofs,fname,8);
	/* this loop finds the '.' in the fname */
	for(i = 0;i < 8;i++) if (fname[i] == '.') break;
	i2 = i + 1;
	/* this code does the required "blank-filling" in memory */
	for(     ;i < 8;i++) SET_MEM_BYTE2(ofs+i,'\0');
	
	/* this code copies the file extension */
	/* TODO: i know this routine is unefficient */
        
        for(i = 8;i < 11;i++)
        {
                if (fname[i2] == '\0')
                        break;
                SET_MEM_BYTE2(ofs+i,fname[i2]);
                i++;
        }
        /* this fills in the rest with blanks */
        for(     ;i < 16;i++)
        {
                SET_MEM_BYTE2(ofs+i,0);
        }
}

