#include "../_sdk/io.h"
#include "../_sdk/str.h"
VAR BYTE psystrk[0x900];
FUNC BOOL comparedesc(PCHAR filename, PBYTE desc)
{
VAR CHAR c;
VAR BOOL res;
VAR BYTE i = 0x08;
res = +FALSE;
filename = findlastslash(filename);
loop:
c = *(PCHAR)filename;
INC filename;
IF (c == '.') {
dot:
while (i != 0x00) {
if (*(PCHAR)desc != ' ') {goto quit;};
INC desc;
DEC i;
};
//desc = (PBYTE)((UINT)desc + (UINT)i);
res = (*(PCHAR)desc == *(PCHAR)filename);
goto quit;
};
IF (c != *(PCHAR)desc) {goto quit;};
INC desc;
DEC i;
IF (i == 0x00) {
c = *(PCHAR)filename;
INC filename;
IF (c == '.') {goto dot;};
res = ((c == '\0') && (*(PCHAR)desc == ' ')); //filenam8 (without ext); else filename too long
goto quit;
};
goto loop;
quit:
RETURN res;
}
PROC main(PCHAR fn)
{
VAR BYTE nerased;
//VAR BYTE nfiles;
VAR PBYTE curfiledesc;
//ўшЄрхь ёшёЄхьэє■ фюЁюцъє
readsectors((PBYTE)psystrk, 0x0000, 0x09);
//nfiles = psystrk[0x8e4];
nerased = psystrk[0x8f4];
//Єхъє∙шщ Їрщыют√щ фхёъЁшяЄюЁ = &psystrk[0x0000]
curfiledesc = (PBYTE)psystrk;
loop:
//ш∙хь эхєфры╕ээ√щ Їрщы
IF (*(PBYTE)curfiledesc == 0x00) goto quit;
IF (comparedesc(fn, curfiledesc)) {
//ъюЁЁхъЄшЁєхь фшЁхъЄюЁш■
curfiledesc[0] = 0x01; //erased
//DEC nfiles;
INC nerased;
};
//яхЁхїюфшь ъ ёыхфє■∙хьє фхъёЁшяЄюЁє
curfiledesc = &curfiledesc[16];
//яютЄюЁ хь фю 0
goto loop;
quit:
//ъюЁЁхъЄшЁєхь ёшёЄхьэ√щ ёхъЄюЁ
//psystrk[0x8e4] = nfiles; //number of files
psystrk[0x8f4] = nerased; //number of erased files
//яш°хь ёшёЄхьэє■ фюЁюцъє
writesectors((PBYTE)psystrk, 0x0000, 0x09);
}