Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 937 → Rev 938

/programs/fs/Eolite/trunk/include/run_file.h--
File deleted
/programs/fs/Eolite/trunk/lib/IPC.H--
0,0 → 1,186
//stuff for loading images via MeView via IPC by Nable. 2008
//Last changed 13.11.2008
 
inline fastcall void registerIPCbuffer(dword ECX, dword EDX)
//ecx - pointer to buffer, edx - buffer size
{
EAX=60;
EBX=1;
$int 0x40
}
 
inline fastcall void build_param_string(dword ESI, dword EDI)
//first parameter - pointer to filename string, second - pointer to
//the output area for commandline for MeView
proc_info _p_info;
{
_p_info.GetInfo(SelfInfo);
EBX = _p_info.ID;
EAX = 'NCPI'; //'IPCN' in reversed byte order
$STOSD
ECX = 8;
 
___NEW_SYMBOL_OF_PID:
$ROL EBX,4
 
EAX = EBX;
EAX &= 0xF;
EAX += '0';
 
$CMP AL,'9'
$JBE ___NEW_SYMBOL_OF_PID_PRINT
$ADD AL,7 //('A'-'0'-10)
___NEW_SYMBOL_OF_PID_PRINT:
$STOSB
$LOOP ___NEW_SYMBOL_OF_PID
 
___NEW_SYMBOL_OF_PATH_COPY:
$LODSB
$STOSB
$OR AL,AL
$JNE ___NEW_SYMBOL_OF_PATH_COPY
}
 
char _Path2MeView[]="/sys/mv";
 
inline int RunMV(char* parameters)
f70 _run_struct;
{
_run_struct.func = 7;
_run_struct.param1 = 0;
_run_struct.param2 = parameters;
_run_struct.param3 =
_run_struct.param4 =
_run_struct.rezerv = 0;
_run_struct.name = #_Path2MeView;
 
EAX=70;
EBX=#_run_struct;
$int 0x40
//EAX (return code) will contain positive PID of new process or negative error code.
}
 
 
int loadimage_viaIPC(char* file_name_to_load, int initial_values)
//really it must be IMAGE_INFO* initial_values, but compiler rejected
//this, so I had to use 'int initial_values'
char param_string[255];
unsigned int _FrameCountTemp;
int temp0; //scratch variable
int came_size; //sizeof data that came. It's used to shrink unneeded IPC data
//added by Nable 13.11.2008 3.36am (begin)
int MVsPID; //no comments
int MVsSlot; //no comments
proc_info _p_info; //this structure will be used to test if MV is alive
//added by Nable 13.11.2008 3.36am (end)
{
int pIPCbuffer = malloc(64); //IPC buffer for the first message can be
//rather small but >= 8+8+24
 
/*Here you can add error checking code, i.e. if(!pIPCbuffer)
{ ErrorExit("OUT OF MEMORY!"); }; */
 
registerIPCbuffer(pIPCbuffer,64);
DSDWORD[pIPCbuffer+4]=8; //at +4 in IPC buffer is a relative pointer to free place
 
build_param_string(file_name_to_load, #param_string);
 
DSDWORD[pIPCbuffer]=0; //unlock the buffer
 
SetEventMask(01000000b); // 1 << (evIPC-1)
//13.11.2008 3.45am Nable's fixes (begin1)
MVsPID = RunMV(#param_string); //you can use here your function but don't forget
//about parameters (param_string).
MVsSlot = PIDtoSlot(MVsPID);
 
WHILE(!(WaitEventTimeout(100))){
//we have only one event - evIPC so return value may be 0 or evIPC but if received 0 it can mean
//either MV terminated silently or it just hasn't done the work and we should wait. Test for it
_p_info.GetInfo(MVsSlot);
IF((_p_info.status_slot > 2)||(_p_info.ID != MVsPID)) return 0;
}
//13.11.2008 4.26am Nable's fixes ( end1)
 
//else we got the message. Process it.
DSDWORD[pIPCbuffer] |= -1; //lock the buffer
 
//the first dword of the message is frame count
_FrameCountTemp = DSDWORD[pIPCbuffer+16]; //note that data of the first
//message is located at offset 16 in IPC buffer;
 
IF(_FrameCountTemp <= 1) //see docs
{
ESI = pIPCbuffer+16+12;
EDI = initial_values; //offset of CurrentImage structure
 
//Left and top corner's coords (not used in many cases but who knows?)
$MOVSD
//Width and height
$MOVSD
//bpp
$LODSD
$movzx eax,ax
CurrentImage.BitsPerPixel = EAX;
}
//see docs
came_size = DSDWORD[pIPCbuffer+24]; //amount of useful data
temp0 = came_size + 4096; //+4096 - some reserve
realloc(temp0+4096, pIPCbuffer); //+4096 - some reserve
registerIPCbuffer(pIPCbuffer, temp0); //re-register IPC buffer with a new size
 
DSDWORD[pIPCbuffer+4]=8; //delete first message, at +4 in IPC buffer is a
//relative pointer to free place
 
DSDWORD[pIPCbuffer]=0; //unlock the buffer to receive second msg
 
//13.11.2008 4.26am Nable's fixes ( begin2)
WHILE(!(WaitEventTimeout(100))){
//we have only one event - evIPC so return value may be 0 or evIPC but if received 0 it can mean
//either MV terminated silently or it just hasn't done the work and we should wait. Test for it
_p_info.GetInfo(MVsSlot);
IF((_p_info.status_slot > 2)||(_p_info.ID != MVsPID)) return 0;
}
//13.11.2008 4.26am Nable's fixes ( end2)
 
//if we are here, then we received the second message. if FrameCount==1 then
//it's a pure image data (if BitsPerPixel==15, 16, 24 or 32) or
//(dword)sizeof(palette[]) then palette[] and then the image.
//Parse it as you like, here's my way:
 
registerIPCbuffer(pIPCbuffer, 0); // there are no function 'unregister
//IPC buffer' in Kolibri - so I have to use 'dark power'
 
//shrink unneeded IPC data
ECX = came_size;
$SHR ECX,2
ECX++; //ECX = number of useful dwords
EDI = pIPCbuffer;
ESI = EDI + 16;
$CLD
$REP $MOVSD
 
//now we must interpret second message
EDI = initial_values;
IF(_FrameCountTemp <= 1)
{
IF(DSDWORD[EDI+24] > 8) //CurrentImage.BitsPerPixel
{
DSDWORD[EDI+20] = 0; //CurrentImage.pPalette=0
DSDWORD[EDI+16] = pIPCbuffer; //CurrentImage.StartOfImage=pIPCbuffer
}
ELSE
{
EAX = pIPCbuffer + 4;
DSDWORD[EDI+20] = EAX; //CurrentImage.pPalette=EAX
EAX += DSDWORD[EAX-4];
DSDWORD[EDI+16] = EAX; //CurrentImage.StartOfImage = EAX;
};
}
ELSE
{
GetNthImageInfo(pIPCbuffer,EDI,0);
};
 
EBX = _FrameCountTemp;
return pIPCbuffer;
}
/programs/fs/Eolite/trunk/lib/Nable_lib.H--
0,0 → 1,119
/*-------------------------------------------------------------------------------
C-- base library for Kolibri, Nable's variant.
-------------------------------------------------------------------------------*/
 
inline fastcall dword WaitEventTimeout(dword EBX){
EAX = 23; // wait here for event
$int 0x40
}
 
//-------------------------------------------------------------------------------
struct IMAGE_INFO{
word Left,Top,Width,Height; //+0, +2, +4, +6
dword Delay,Displacement,StartOfImage; //+8, +12, +16
dword pPalette,BitsPerPixel; //+20, +24
};
 
IMAGE_INFO CurrentImage;
 
//-------------------------------------------------------------------------------
fastcall int GetNthImageInfo(dword ESI, EDI, ECX)
//esi - pointer to structure with multiple images
//edi - pointer to structure of type IMG_INFO
//ecx - CurrentFrameNum
//returns 0 if error
int pCurrentImage;
{
pCurrentImage = EDI;
EAX = 0;
EBX = ESI;
$jecxz _END_LOOP
_1:
$TEST ESI,ESI
$JE __EXIT
 
//MOV ESI,[ESI] - c-- refused to compile it
$DB 8Bh
$DB 36h
 
$ADD ESI,EBX
$loop _1
_END_LOOP:
$LODSD
//left and top
$MOVSD
//width and height
$MOVSD
//delay
$MOVSD
//displacement
$MOVSD
 
EDI = pCurrentImage;
 
$LODSD
$TEST EAX,EAX
$JS _NO_PALETTE
$ADD EAX,EBX
 
//Stay calm, this pervertion is only because of uncomplete
//pointers' support in C--
 
//CurrentImage.pPalette=ESI;
DSDWORD[EDI+20] = ESI;
 
//CurrentImage.StartOfImage=EAX;
DSDWORD[EDI+16] = EAX;
 
//CurrentImage.BitsPerPixel=8;
DSDWORD[EDI+24] = 8;
GOTO __EXIT;
 
_NO_PALETTE:
$NEG EAX
//CurrentImage.BitsPerPixel=EAX;
DSDWORD[EDI+24] = EAX;
 
//CurrentImage.pPalette=0;
DSDWORD[EDI+20] = 0;
 
//CurrentImage.StartOfImage=ESI;
DSDWORD[EDI+16] = ESI;
__EXIT:
}
 
//As a parameter you should send PID of needed slot
//return value will be 0 if not found
inline fastcall int PIDtoSlot(dword EDX)
{
proc_info _p_info;
EBX=#_p_info; //pointer to the structure
ECX=2;//slot 1 is system
WHILE(ECX<256){
EAX=9;
$INT 0x40
IF(_p_info.ID == EDX) return ECX;
ECX++;
}
return 0;
}
 
 
void fastcall DrawImage(dword EBX, EDX)
{
$PUSHAD
EAX = 65;
EBP = 0;
EDI = DSDWORD[EBX+20];
ESI = DSDWORD[EBX+24];
$ROR EDX,16
EDX += DSDWORD[EBX];
$ROR EDX,16
ECX = DSDWORD[EBX+4];
$ROR ECX,16
EBX = DSDWORD[EBX+16];
$INT 0x40
$POPAD
}
 
 
/programs/fs/Eolite/trunk/lib/file_system.h--
0,0 → 1,197
struct f70{
dword func;
dword param1;
dword param2;
dword param3;
dword param4;
char rezerv;
dword name;
};
 
 
///////////////////////////
// Çàïóñê ïðîãðàììû //
///////////////////////////
f70 run_file_70;
void RunProgram(dword run_path, run_param)
{
run_file_70.func = 7;
run_file_70.param1 =
run_file_70.param3 =
run_file_70.param4 =
run_file_70.rezerv = 0;
run_file_70.param2 = run_param;
run_file_70.name = run_path;
$mov eax,70
$mov ebx,#run_file_70.func
$int 0x40
}
 
///////////////////////////
// Ñîçäàíèå ïàïêè //
///////////////////////////
f70 create_dir_70;
void CreateFolder(dword new_folder_path)
{
create_dir_70.func = 9;
create_dir_70.param1 =
create_dir_70.param2 =
create_dir_70.param3 =
create_dir_70.param4 =
create_dir_70.rezerv = 0;
create_dir_70.name = new_folder_path;
$mov eax,70
$mov ebx,#create_dir_70.func
$int 0x40
}
 
////////////////////////////
// Óäàëåíèå ôàéëà/ïàïêè //
////////////////////////////
f70 del_file_70;
void DeleleFile(dword del_file_path)
{
del_file_70.func = 8;
del_file_70.param1 =
del_file_70.param2 =
del_file_70.param3 =
del_file_70.param4 =
del_file_70.rezerv = 0;
del_file_70.name = del_file_path;
$mov eax,70
$mov ebx,#del_file_70.func
$int 0x40
}
 
///////////////////////////
// Ïðî÷èòàòü ïàïêó //
///////////////////////////
f70 read_dir_70;
void ReadDir(dword file_count, read_buffer, read_dir_path)
{
read_dir_70.func = 1;
read_dir_70.param1 =
read_dir_70.param2 =
read_dir_70.rezerv = 0;
read_dir_70.param3 = file_count;
read_dir_70.param4 = read_buffer;
read_dir_70.name = read_dir_path;
$mov eax,70
$mov ebx,#read_dir_70.func
$int 0x40
}
 
///////////////////////////
// Ñêîïèðîâàòü ôàéë //
///////////////////////////
f70 CopyFile_f;
inline fastcall dword CopyFile(dword EBX,ECX)
{
BDVK CopyFile_atr;
dword s=EBX, d=ECX, cBufer=0;
CopyFile_f.func = 5;
CopyFile_f.param1 = 0;
CopyFile_f.param2 = 0;
CopyFile_f.param3 = 0;
CopyFile_f.param4 = #CopyFile_atr;
CopyFile_f.rezerv = 0;
CopyFile_f.name = s;
$mov eax, 70
$mov ebx, #CopyFile_f
$int 0x40
if (!EAX)
{
cBufer = malloc(CopyFile_atr.sizelo);
CopyFile_f.func = 0;
CopyFile_f.param1 = 0;
CopyFile_f.param2 = 0;
CopyFile_f.param3 = CopyFile_atr.sizelo;
CopyFile_f.param4 = cBufer;
CopyFile_f.rezerv = 0;
CopyFile_f.name = s;
$mov eax, 70
$mov ebx, #CopyFile_f
$int 0x40
IF (!EAX)
{
CopyFile_f.func = 2;
CopyFile_f.param1 = 0;
CopyFile_f.param2 = 0;
CopyFile_f.param3 = CopyFile_atr.sizelo;
CopyFile_f.param4 = cBufer;
CopyFile_f.rezerv = 0;
CopyFile_f.name = d;
$mov eax, 70
$mov ebx, #CopyFile_f
$int 0x40
}
}
 
}
 
/*char *extension[25]={".skn",".avi",".htm","html",".3ds",".lif",".cvs",".mp3",
".wav",".mid","midi",".rtf",".txt",".inc",".ini",".dat",".asm",".gif",".bmp",
".tga",".pcx",".png",".jpg","jpeg", 0}; //ìàññèâ óêàçàòåëåé
char *prog_path[25]={"desktop","/sys/kvid","/sys/network/HTMLv","/sys/network/HTMLv",
"/sys/demos/3d/view3ds","/sys/demos/life2","graph","AC97SND","AC97SND","MIDAMP",
"MIDAMP","RtfRead","TinyPad","TinyPad","TinyPad","TinyPad","TinyPad","MV","MV",
"MV","MV","@rcher","JpegView","JpegView", 0};
 
 
void Run_File(dword fpath)
{
byte i;
dword file_ext[4]=fpath+strlen(fpath)-4;
FOR(i=0; extension[i]!=0; i++) IF (strcmp(file_ext,extension[i])==0)
{
Run_Program(prog_path[i], fpath);
return;
}
Run_Program(fpath, "");
}*/
 
 
void Run_File(dword fpath)
{
dword extension[4], fparam[256];
copystr(fpath,#fparam); //ïî-óìîë÷àíèþ ïðîãà è ïàðàìåòð ðàâíû, åñëè îêàæåòñÿ ÷òî ýòî ôàéë, ïàðàì - ñáðîñèì
copystr(fpath+strlen(fpath)-4,#extension); //óçíà¸ì ðàñøèðåíèå ôàéëà ñ êàêèì ðàáîòàåì
//òóò ìû ýòî ðàñøèðåíèå ñðàâíèìàåì, è, åñëè îíî àñîöèèðóåòñÿ ñ ïðîãîé, ïðîãà - ýòî fpath
IF (!strcmp(#extension,".skn")) copystr("desktop",fpath);
IF (!strcmp(#extension,".avi")) copystr("/sys/kvid",fpath);
IF (!strcmp(#extension,".mpg")) copystr("/sys/kvid",fpath);
IF (!strcmp(#extension,".htm")) copystr("/sys/network/HTMLv",fpath);
IF (!strcmp(#extension,"html")) copystr("/sys/network/HTMLv",fpath);
//IF (strcmp(#extension,".htm")==0) || (strcmp(#extension,"html")==0) copystr("/hd0/2/Programs/QIP/Users/419114984/RcvdFiles/313257308_Veliant/browser/HTMLv",fpath);
IF (!strcmp(#extension,".3ds")) copystr("/sys/demos/3d/view3ds",fpath);
IF (!strcmp(#extension,".lif")) copystr("/sys/demos/life2",fpath);
IF (!strcmp(#extension,".cvs")) copystr("graph",fpath);
IF (!strcmp(#extension,".nes")) copystr("/sys/games/fce",fpath);
//audio
IF (!strcmp(#extension,".mp3")) copystr("AC97SND",fpath);
IF (!strcmp(#extension,".wav")) copystr("AC97SND",fpath);
IF (!strcmp(#extension,".mid")) copystr("MIDAMP",fpath);
IF (!strcmp(#extension,"midi")) copystr("MIDAMP",fpath);
//text
IF (!strcmp(#extension,".rtf")) copystr("RtfRead",fpath);
IF (!strcmp(#extension,".txt")) copystr("TinyPad",fpath);
IF (!strcmp(#extension,".inc")) copystr("TinyPad",fpath);
IF (!strcmp(#extension,".ini")) copystr("TinyPad",fpath);
IF (!strcmp(#extension,".dat")) copystr("TinyPad",fpath);
IF (!strcmp(#extension,".asm")) copystr("TinyPad",fpath);
IF (!strcmp(#extension,".cpp")) copystr("TinyPad",fpath);
//èçîáðàæåíèÿ
IF (!strcmp(#extension,".gif")) copystr("MV",fpath); //GifView,MenuAnimage
IF (!strcmp(#extension,".bmp")) copystr("MV",fpath); //BmpMenu1,MenuAnimage
IF (!strcmp(#extension,".tga")) copystr("MV",fpath);
IF (!strcmp(#extension,".pcx")) copystr("MV",fpath);
IF (!strcmp(#extension,".cur")) copystr("MV",fpath);
IF (!strcmp(#extension,".ico")) copystr("MV",fpath);
IF (!strcmp(#extension,".png")) copystr("pngview",fpath);
IF (!strcmp(#extension,".jpg")) copystr("JpegView",fpath);
IF (!strcmp(#extension,"jpeg")) copystr("JpegView",fpath);
IF (!strcmp(fpath,#fparam)) fparam=''; //åñëè fpath íå èçìåíèëñÿ, òî ýòî òàêè, íàâåðíîå, ïðîãà, ïàðàìåòðîâ íåò.
RunProgram(fpath, #fparam); //çàïóñê!
}