diff --git a/programs/games/c4/trunk/ai.inc b/programs/games/c4/trunk/ai.inc index 8ede9f138a..517bb23281 100644 --- a/programs/games/c4/trunk/ai.inc +++ b/programs/games/c4/trunk/ai.inc @@ -34,8 +34,8 @@ INFTY equ 1000000000 moveorder dd 1,7,2,6,3,5,4 ; table used for static evaluation. -; this table is taken from 4st attack: it is ways better -; than the table i used before =) +; this table is taken from 4st attack: it is much better +; than the table I used before =) evaltable: dd 0, 0, 0, 0, 0, 0, 0, 0, 0 dd 0, 3, 4, 5, 7, 5, 4, 3, 0 dd 0, 4, 6, 8,10, 8, 6, 4, 0 @@ -74,14 +74,14 @@ aiGetMove: mov [cpulevel],eax mov dword [bestval],-INFTY mov dword [nbestmoves],0 - + ; try every move mov ecx,6 .evalmoves: ; get move to make from move order table mov eax,[moveorder+ecx*4] - + ; if this is an invalid move, continue with next move BOARDISVALIDMOVE eax jz .nextmove @@ -89,7 +89,7 @@ aiGetMove: ; make move for current player mov ebx,[currentplayer] call boardMakeMove - + ; evaluate move push eax ; save move # push ecx ; save loop counter @@ -100,14 +100,14 @@ aiGetMove: push dword -INFTY ; alpha push dword INFTY ; beta call alphabeta - neg eax ; damn, how could i forget this ??? + neg eax ; How could I forget this ??? mov ebx,eax ; save result for later pop ecx ; restore loop counter pop eax ; restore move # - + ; undo move (eax = move #) call boardUndoMove - + ; let's see wether we have a new best move cmp ebx,[bestval] ; new best value found ? jle .nonewbestval @@ -127,7 +127,7 @@ aiGetMove: js .done jmp .evalmoves .done: - + ; randomly pick one of the best moves call rand ; rand() % nbestmoves xor edx,edx @@ -156,7 +156,7 @@ alphabeta: %define beta (ebp+ 8) enter 0,0 - + ; win for other player -> end search mov eax,[player] BOARDGETOTHERPLAYER eax @@ -180,7 +180,7 @@ alphabeta: ; max search depth reached -> do static evaluation cmp dword [ply],0 je .staticeval - + ; for each move mov ecx,6 @@ -193,15 +193,15 @@ alphabeta: ; pick move from move order table mov eax,[moveorder+ecx*4] - + ; invalid move ? if so, continue with next move BOARDISVALIDMOVE eax jz .nextmove - + ; make move for current player mov ebx,[player] call boardMakeMove - + ; evaluate move push eax push ecx @@ -219,27 +219,27 @@ alphabeta: push edx call alphabeta neg eax - + ; new alpha ? cmp eax,[alpha] jle .nonewalpha mov [alpha],eax ; yes -> save it -.nonewalpha: +.nonewalpha: pop ecx pop eax - + ; undo move call boardUndoMove .nextmove: ; evaluate next move dec ecx jns .evalmoves - + .done: mov eax,[alpha] leave ret 4*4 - + ; static evaluation .staticeval: xor eax,eax @@ -255,7 +255,7 @@ alphabeta: je .empty ; nope -> go on sub eax,[evaltable+esi*4] ; yes -> sub stone value from eax .empty: - + .next: ; next stone dec esi jns .l @@ -267,4 +267,4 @@ alphabeta: %undef alpha %undef beta -%endif \ No newline at end of file +%endif diff --git a/programs/games/megamaze/trunk/wriggle.inc b/programs/games/megamaze/trunk/wriggle.inc index 0fe7c355ed..a48de5aa87 100644 --- a/programs/games/megamaze/trunk/wriggle.inc +++ b/programs/games/megamaze/trunk/wriggle.inc @@ -1,251 +1,251 @@ -; level format -; [fx|fy]..[field cells x2]..[worm_count]..[worm_len][start cell #][body dirs x2] - -; internal format -; [stepptr]= worms # -; area: [worm_len][start_cell #][end_cell #]..[dirs].. -; [cur_step]: dragged worm pointer -; [finish]: 0 - if head dragged, 1- if tail -WG_levelp: - mcall 40,100111b - inc [drag_flag] - call get_xy_sf - sub esi,2 - call LP_levelp.bit2 - cmp edx,4 - jne .ok - dec esi - .ok: - movzx ecx,byte[esi] - mov [stepptr],ecx - inc esi - xor eax,eax - mov edi,area - .lp1: - push ecx - movzx ecx,byte[esi] - inc esi - mov [edi],cl - inc edi - lodsb - dec ecx - movzx ebx,al - stosb - push edi - inc edi - mov edx,8/2 - lodsb - .lp: - rol al,2 - push ecx - mov cl,al - and ecx,11b - add ebx,[dirs+ecx*4] - mov [edi],cl - pop ecx - inc edi - dec edx - test edx,edx - jnz .nxt - mov edx,8/2 - lodsb - .nxt: - loop .lp - cmp edx,4 - jne .ok2 - dec esi - .ok2: - pop ecx - mov [ecx],bl - pop ecx - loop .lp1 - mov esi,[stepptr] - ret - -WG_key: - cmp eax,0 - jl WG_mouse - ret - -WG_drawm: - mov [win_flag],1 - mov ecx,[cell_count] -; mov [sq_size],3 - .lp: - push ecx - movzx ebx,byte[field+ecx-1] - and byte[field+ecx-1],11000000b - shr ebx,6 - test ebx,ebx - jz .no - dec ebx - lea eax,[ecx-1] - call get_xy - add [lx],5-2 shl 16 - add [ly],5-2 shl 16 - mov edx,[f_colors+ebx*4] - mcall 13,[lx],[ly] - .no: - pop ecx - loop .lp - - add [sq_size],3 - - mov ecx,[stepptr] - xor eax,eax - mov esi,area - push ebp - mov edi,w_colors - mov dword[player],1 - .lp2: - push ecx - movzx ecx,byte[esi] - inc esi - xor eax,eax - lodsb - mov ebp,esi - .lp1: - inc esi - push ecx eax - call get_xy - mcall 13,[lx],[ly],[edi] - pop eax - mov ecx,[player] - mov bl,[field+eax] - shr bl,6 - add [field+eax],cl - cmp bl,cl - je .match - and [win_flag],0 - .match: - pop ecx - push esi edi - movzx ebx,byte[esi] - mov esi,eax - mov [ebp],al - add eax,[dirs+ebx*4] - - cmp ecx,1 - je .skip - mov edi,eax - call getline - call bold_line - .skip: - pop edi esi - loop .lp1 - pop ecx - add edi,4 - inc dword[player] - loop .lp2 - pop ebp - sub [sq_size],3 - - ret - -WG_mouse: - cmp [win_flag],1 - je .ex - mov [jump],still - mov edx,eax - call get_last_mclick - cmp edx,-2 - jne .no1st - test eax,eax - jz .ex - .noempty: - -; First Click at ebx cell -; dpd ebx - mov [cur_step],0 - mov dword[finish],0 - mov esi,area - mov ecx,[stepptr] - .fndlp: - movzx edx,byte[esi] - cmp bl,[esi+1] - je .fnd - cmp bl,[esi+2] - jne .nxt - inc dword[finish] - .fnd: - mov [cur_step],esi - mov [jump],drw;red - jmp .ex - .nxt: - lea esi,[esi+edx+2] - loop .fndlp - jmp .ex - - .no1st: - test eax,eax - jz .ex -; While dragging - mov esi,[cur_step] - test esi,esi - jz .ex - lea edi,[esi+1] - add edi,[finish] - movzx eax,byte[edi] - cmp eax,ebx - je .ex - push ebx - cmp dword[finish],0 - jne .noswap - xchg eax,ebx - .noswap: - call get_offset - cmp ebx,1 - pop ebx - jne .ex - cmp eax,-1 - je .ex - test byte[field+ebx],11b - jnz .ex - movzx ecx,byte[esi] - cmp dword[finish],0 - jne .tail - mov [esi+1],bl - mov [esi+2],al - add esi,ecx - std - lea edi,[esi+1] - rep movsb - jmp .redex - - .tail: - mov [esi+2],bl - movzx ebx,byte[esi+3] - movzx edx,byte[esi+1] - add edx,[dirs+ebx*4] - mov [esi+1],dl - add esi,3 - lea edi,[esi-1] - rep movsb - mov [edi-1],al -; ud2 - .redex: - cld - mov [jump],drw;red - mov esi,area - .ex: - ret - -WG_level: -file 'wriggle.bin' - -if lang eq ru - WG_help mstr \ - 'Ваша задача - тянуть червяков за голову или',\ - 'хвост, пока каждый из них не покроет клетки',\ - 'своего цвета, оставив незакрытыми белые квадраты.',\ - 'Червяки не могут перекрывать и пересекать друг',\ - 'друга.','',\ - 'http://www.clickmazes.com' -else - WG_help mstr \ - 'Your aim is to drag the wriggley worms by head or',\ - 'tail until each worm covers the squares of its',\ - 'own colour leaving only white squares exposed.',\ - 'Worms cannot cross or overlap.','',\ - 'http://www.clickmazes.com' -end if +; level format +; [fx|fy]..[field cells x2]..[worm_count]..[worm_len][start cell #][body dirs x2] + +; internal format +; [stepptr]= worms # +; area: [worm_len][start_cell #][end_cell #]..[dirs].. +; [cur_step]: dragged worm pointer +; [finish]: 0 - if head dragged, 1- if tail +WG_levelp: + mcall 40,100111b + inc [drag_flag] + call get_xy_sf + sub esi,2 + call LP_levelp.bit2 + cmp edx,4 + jne .ok + dec esi + .ok: + movzx ecx,byte[esi] + mov [stepptr],ecx + inc esi + xor eax,eax + mov edi,area + .lp1: + push ecx + movzx ecx,byte[esi] + inc esi + mov [edi],cl + inc edi + lodsb + dec ecx + movzx ebx,al + stosb + push edi + inc edi + mov edx,8/2 + lodsb + .lp: + rol al,2 + push ecx + mov cl,al + and ecx,11b + add ebx,[dirs+ecx*4] + mov [edi],cl + pop ecx + inc edi + dec edx + test edx,edx + jnz .nxt + mov edx,8/2 + lodsb + .nxt: + loop .lp + cmp edx,4 + jne .ok2 + dec esi + .ok2: + pop ecx + mov [ecx],bl + pop ecx + loop .lp1 + mov esi,[stepptr] + ret + +WG_key: + cmp eax,0 + jl WG_mouse + ret + +WG_drawm: + mov [win_flag],1 + mov ecx,[cell_count] +; mov [sq_size],3 + .lp: + push ecx + movzx ebx,byte[field+ecx-1] + and byte[field+ecx-1],11000000b + shr ebx,6 + test ebx,ebx + jz .no + dec ebx + lea eax,[ecx-1] + call get_xy + add [lx],5-2 shl 16 + add [ly],5-2 shl 16 + mov edx,[f_colors+ebx*4] + mcall 13,[lx],[ly] + .no: + pop ecx + loop .lp + + add [sq_size],3 + + mov ecx,[stepptr] + xor eax,eax + mov esi,area + push ebp + mov edi,w_colors + mov dword[player],1 + .lp2: + push ecx + movzx ecx,byte[esi] + inc esi + xor eax,eax + lodsb + mov ebp,esi + .lp1: + inc esi + push ecx eax + call get_xy + mcall 13,[lx],[ly],[edi] + pop eax + mov ecx,[player] + mov bl,[field+eax] + shr bl,6 + add [field+eax],cl + cmp bl,cl + je .match + and [win_flag],0 + .match: + pop ecx + push esi edi + movzx ebx,byte[esi] + mov esi,eax + mov [ebp],al + add eax,[dirs+ebx*4] + + cmp ecx,1 + je .skip + mov edi,eax + call getline + call bold_line + .skip: + pop edi esi + loop .lp1 + pop ecx + add edi,4 + inc dword[player] + loop .lp2 + pop ebp + sub [sq_size],3 + + ret + +WG_mouse: + cmp [win_flag],1 + je .ex + mov [jump],still + mov edx,eax + call get_last_mclick + cmp edx,-2 + jne .no1st + test eax,eax + jz .ex + .noempty: + +; First Click at ebx cell +; dpd ebx + mov [cur_step],0 + mov dword[finish],0 + mov esi,area + mov ecx,[stepptr] + .fndlp: + movzx edx,byte[esi] + cmp bl,[esi+1] + je .fnd + cmp bl,[esi+2] + jne .nxt + inc dword[finish] + .fnd: + mov [cur_step],esi + mov [jump],drw;red + jmp .ex + .nxt: + lea esi,[esi+edx+2] + loop .fndlp + jmp .ex + + .no1st: + test eax,eax + jz .ex +; While dragging + mov esi,[cur_step] + test esi,esi + jz .ex + lea edi,[esi+1] + add edi,[finish] + movzx eax,byte[edi] + cmp eax,ebx + je .ex + push ebx + cmp dword[finish],0 + jne .noswap + xchg eax,ebx + .noswap: + call get_offset + cmp ebx,1 + pop ebx + jne .ex + cmp eax,-1 + je .ex + test byte[field+ebx],11b + jnz .ex + movzx ecx,byte[esi] + cmp dword[finish],0 + jne .tail + mov [esi+1],bl + mov [esi+2],al + add esi,ecx + std + lea edi,[esi+1] + rep movsb + jmp .redex + + .tail: + mov [esi+2],bl + movzx ebx,byte[esi+3] + movzx edx,byte[esi+1] + add edx,[dirs+ebx*4] + mov [esi+1],dl + add esi,3 + lea edi,[esi-1] + rep movsb + mov [edi-1],al +; ud2 + .redex: + cld + mov [jump],drw;red + mov esi,area + .ex: + ret + +WG_level: +file 'wriggle.bin' + +if lang eq ru + WG_help mstr \ + 'Ваша задача - тянуть червяков за голову или',\ + 'хвост, пока каждый из них не покроет клетки',\ + 'своего цвета, оставив незакрытыми белые квадраты.',\ + 'Червяки не могут перекрывать и пересекать друг',\ + 'друга.','',\ + 'http://www.clickmazes.com' +else + WG_help mstr \ + 'Your aim is to drag the wriggley worms by head or',\ + 'tail until each worm covers the squares of its',\ + 'own color leaving only white squares exposed.',\ + 'Worms cannot cross or overlap.','',\ + 'http://www.clickmazes.com' +end if diff --git a/programs/games/solitaire/solitaire.cpp b/programs/games/solitaire/solitaire.cpp index f550dd5b7c..fa9673a536 100644 --- a/programs/games/solitaire/solitaire.cpp +++ b/programs/games/solitaire/solitaire.cpp @@ -23,7 +23,7 @@ struct List{ List_Node *foundation_head;//points first foundation list List_Node *board_head;//points first board list FILE *fptr; - + void create();// Includes create toplist, boardlists and foundlists void create_toplist(); void create_boardlists(); @@ -97,7 +97,7 @@ int main() if(!islem.top_head)// checking top list empty or not islem.istopempty = true; - + List_Node *traverse; traverse = islem.board_head; int counter = 0; @@ -121,7 +121,7 @@ int main() break; } } - + return 0; } @@ -156,21 +156,21 @@ void List::create_toplist(){ fscanf(fptr, " %c %s %s ", &tempsuit, tempvalue, tempisup); newnode->suit = tempsuit; - + /*Changing type of value char array to integer*/ if(tempvalue[0] == 'A') newnode->value = 1; else if(tempvalue[0] == 'J')newnode->value = 11; else if(tempvalue[0] == 'Q')newnode->value = 12; else if(tempvalue[0] == 'K')newnode->value = 13; - else + else sscanf(tempvalue, "%d", &newnode->value); - + /*Changing type of isup char array to boolean*/ if(strcmp(tempisup, "Up") == 0) newnode->isup = true; if(strcmp(tempisup, "Down") == 0) newnode->isup = false; - + if(top_head == NULL){//add first node to empty top list top_head = newnode; final = top_head; @@ -188,7 +188,7 @@ void List::create_boardlists(){ char tempcolor, tempsuit, tempvalue[4], tempisup[8], garbage[10]; int index = 1;// This index represents nth board list - + newboardlist = new List_Node;// creating first boardlist node board_head = newboardlist; boardlist_final = newboardlist; @@ -219,7 +219,7 @@ void List::create_boardlists(){ else if(tempvalue[0] == 'J')newnode->value = 11; else if(tempvalue[0] == 'Q')newnode->value = 12; else if(tempvalue[0] == 'K')newnode->value = 13; - else + else sscanf(tempvalue, "%d", &newnode->value); if(strcmp(tempisup, "Up") == 0) @@ -281,7 +281,7 @@ void List::printkart(Card_Node *kart){//prints datas of kart node void List::printlists(){ clear_screen(); Card_Node *ct[7];// Board List Card Node Traverser; ct[0] for 1.list, ct[1] for 2.list .... - Card_Node *foundct[4];//Found List Card Node Traverser, foundct[0] = Spades, foundct[1] = Hearts, foundct[2] = Diamonds, foundct[3] = Clubs + Card_Node *foundct[4];//Found List Card Node Traverser, foundct[0] = Spades, foundct[1] = Hearts, foundct[2] = Diamonds, foundct[3] = Clubs Card_Node *topct;// TopList Card Traverser List_Node *listtraverse;// List Node Traverser @@ -306,7 +306,7 @@ void List::printlists(){ } /*Printing Board List's Cards*/ - for(int i = 0; i < 19; i++){//this for loop traverses lists and goes 19 times down, a list can include cards up to 19 (6 down cards + 13 up cards) + for(int i = 0; i < 19; i++){//this for loop traverses lists and goes 19 times down, a list can include cards up to 19 (6 down cards + 13 up cards) for(int j = 0; j < 7; j++) { if(ct[j]){// if ct[j] is not null, print it and go to next node @@ -317,7 +317,7 @@ void List::printlists(){ else// if ct[j] is null, print a tab printf("\t"); } - if(ct[0] || ct[1] || ct[2] || ct[3] || ct[4] || ct[5] || ct[6])// After printing a line; + if(ct[0] || ct[1] || ct[2] || ct[3] || ct[4] || ct[5] || ct[6])// After printing a line; printf("\n");//if at least one card is not null: go new line else break;// if all cards in line are null: break outer for loop @@ -343,7 +343,7 @@ void List::printlists(){ else// if foundct[j] is null, print a tab printf("\t"); } - if(foundct[0] || foundct[1] || foundct[2] || foundct[3])// After printing a line; + if(foundct[0] || foundct[1] || foundct[2] || foundct[3])// After printing a line; printf("\n");//if at least one card is not null: go new line else break;// if all cards in line are null: break outer for loop @@ -458,7 +458,7 @@ void List::goster_TopToFoundation(){// wants input from use else if(tempvalue[0] == 'J')Symbol_of_numbers = 11; else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12; else if(tempvalue[0] == 'K')Symbol_of_numbers = 13; - else + else sscanf(tempvalue, "%d", &Symbol_of_numbers); TopToFoundation(Symbol_of_colors, Symbol_of_suits, Symbol_of_numbers); @@ -472,7 +472,7 @@ void List::TopToFoundation(char s_color, char s_suit, int s_value){ cout << "Top list is empty, you cannot make this move." << endl; return; } - + cardtraverse = top_head; cardtail = top_head; @@ -527,7 +527,7 @@ void List::goster_TopToBoard(){// wants input from user for moving card top list else if(tempvalue[0] == 'J')Symbol_of_numbers = 11; else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12; else if(tempvalue[0] == 'K')Symbol_of_numbers = 13; - else + else sscanf(tempvalue, "%d", &Symbol_of_numbers); cout << "Select the number of the destination Board List:"; @@ -544,7 +544,7 @@ void List::TopToBoard(int listindex, char s_color, char s_suit, int s_value){ cout << "Top list is empty, you cannot make this move." << endl; return; } - + cardtraverse = top_head; cardtail = top_head; @@ -600,7 +600,7 @@ void List::goster_BoardToBoard(){ else if(tempvalue[0] == 'J')Symbol_of_numbers = 11; else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12; else if(tempvalue[0] == 'K')Symbol_of_numbers = 13; - else + else sscanf(tempvalue, "%d", &Symbol_of_numbers); BoardToBoard(source, destination, Symbol_of_colors, Symbol_of_suits, Symbol_of_numbers); } @@ -614,10 +614,10 @@ void List::BoardToBoard(int fromwhere, int towhere, char s_color, char s_suit, i temp_head = sourcelisttraverse->cards; cardtraverse = temp_head; cardtail = temp_head; - + while(cardtraverse){ - if(cardtraverse->isup)// Dont move cards if the entered card is down + if(cardtraverse->isup)// Don't move cards if the entered card is down if(cardtraverse->color == s_color && cardtraverse->suit == s_suit && cardtraverse->value == s_value){ willbemoved = cardtraverse; break; @@ -651,7 +651,7 @@ void List::BoardToBoard(int fromwhere, int towhere, char s_color, char s_suit, i cardtail->next = willbemoved; cout << "Wrong Movement!" << endl; } - + } void List::goster_BoardToFoundation(){ @@ -754,7 +754,6 @@ void List::close(){//Deletes all linked lists and linkedlists's all nodes foundation_head = foundation_head->next; delete listtraverse; } - + fclose(fptr);//Closing reading txt file } - diff --git a/programs/other/calc/trunk/calc.asm b/programs/other/calc/trunk/calc.asm index 7c30ccd020..6e167db34b 100644 --- a/programs/other/calc/trunk/calc.asm +++ b/programs/other/calc/trunk/calc.asm @@ -1,7 +1,7 @@ ;; Calculator for MenuetOS (c) Ville Turjanmaa -;; +;; ;; Compile with FASM -;; +;; ;; Pavel Rymovski (Heavyiron) - version for KolibriOS ;; ;; What's new: @@ -12,7 +12,7 @@ ;; Calc 1.2 ;; 1) added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2 ;; Calc 1.31 -;; 1) optimised program +;; 1) optimized program ;; 2) new type of window (you need kernel 114 revision or higher) ;; Calc 1.32 ;; 1) fixed arccos @@ -44,13 +44,13 @@ butid: db 12, 13, 14, 19, 20, 21, 26, 27, 28, 34, 15, 39, 39, 22, 36, 29, 35, 3 START: red: call draw_window -still: +still: mcall 10 dec eax jz red - dec eax - jz key + dec eax + jz key button: mcall 17 ; get button id @@ -76,7 +76,7 @@ testbut: cmp eax, 1 ; button 1 -- exit jne noexit mcall -1 - + noexit: cmp eax, 2 jne no_reset @@ -206,7 +206,7 @@ no_int: fdiv [trans1] jmp show_result -no_1x: +no_1x: cmp eax, 24 jne no_cos fld [trans1] @@ -226,14 +226,14 @@ no_cos: fpatan jmp show_result -no_acos: +no_acos: cmp eax, 30 jne no_x2 fld [trans1] fmul st, st0 jmp show_result -no_x2: +no_x2: cmp eax, 31 jne no_tan fld [trans1] @@ -279,7 +279,7 @@ no_add: mov [calc], '-' call print_display jmp still - + no_sub: cmp eax, 29 jne no_div @@ -450,7 +450,7 @@ new_entry: ret -ftoa: ; fpu st0 -> [integer],[decimal] +ftoa: ; fpu st0 -> [integer],[decimal] pusha fst [tmp2] fstcw [controlWord] ; set truncate integer mode @@ -559,7 +559,7 @@ atof: .error: mov bh, 1 ; Set error code. -; fstp st0 ; Pop top of fpu stack. +; fstp st0 ; Pop top of fpu stack. .exit: pop di @@ -661,12 +661,12 @@ draw_window: mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT mov ecx, 200 shl 16 + 210 - add ecx, eax ; add skin height to window height + add ecx, eax ; add skin height to window height mov edx, [sc.work] or edx, 0x34000000 mov edi, title mcall 0, <250, 317> - + mov eax, SF_DEFINE_BUTTON mov ebx, 19 shl 16 + 36 mov ecx, 55 shl 16 + 22 @@ -719,7 +719,7 @@ next_button: DrawRectangle DISPLAY_X,DISPLAY_Y,DISPLAY_W,DISPLAY_H, [sc.work_graph] mcall 38, < DISPLAY_X+1, DISPLAY_W+DISPLAY_X-1>, , 0xE0E0E0 ; internal shadow mcall , < DISPLAY_X+1, DISPLAY_X+1>, , ; internal shadow - + call print_display mcall 12, 2 @@ -729,11 +729,11 @@ print_display: pusha mcall 13, < DISPLAY_X+2, DISPLAY_W-2>, , 0xFFFfff ; background mcall 8, <236,53>, , 3, [sc.work] ; 'dec-bin-hex' - + mov ecx, [sc.work_text] or ecx, 0x40000000 mcall 4, <135,6>,,calc,1,[sc.work] - + mov edx, [display_type] shl edx, 2 add edx, display_type_text @@ -746,7 +746,7 @@ print_display: je positive mcall , <23, 26>, 0, dsign, 1 -positive: +positive: cmp [display_type], 0 jne no_display_decimal cmp [decimal], 0 diff --git a/programs/other/outdated/clip/trunk/clip.inc b/programs/other/outdated/clip/trunk/clip.inc index b698483573..42df9b010b 100644 --- a/programs/other/outdated/clip/trunk/clip.inc +++ b/programs/other/outdated/clip/trunk/clip.inc @@ -24,8 +24,8 @@ _ipc_send: xchg edx, esi .send_again: mov eax, 5 - mov ebx, SEND_DELAY - int 0x40 + mov ebx, SEND_DELAY + int 0x40 mov eax, 60 mov ebx, 2 @@ -65,7 +65,7 @@ _ipc_recv: push ecx mov dword [esi + 4], 0 ; unlock buffer - mov dword [esi + 8], 0 ; + mov dword [esi + 8], 0 ; push edx mov eax, 60 ; register buffer @@ -89,7 +89,7 @@ _ipc_recv: cmp eax, 7 jnz .err - mov eax, [clipboard_init.clipserv_pid] ; not message from + mov eax, [clipboard_init.clipserv_pid] ; not message from cmp eax, [esi + 4] ; daemon, so ignore jnz .wait @@ -136,13 +136,13 @@ clipboard_init: ; mov [.IPC_buffer], ecx push ebp - mov ebp, 1 + mov ebp, 1 .next_process: mov eax, 9 mov ebx, .process_info mov ecx, ebp int 0x40 - mov ecx, eax + mov ecx, eax mov ebx, .process_info + 10 mov eax, [ebx] cmp eax, '@CLI' @@ -153,19 +153,19 @@ clipboard_init: jmp .similar ; mov edx, .clipserv_name -;.compare: +;.compare: ; mov al, [edx] ; cmp al, 0 ; jz .similar ; cmp al, [ebx] -; jnz .differ -; inc edx +; jnz .differ +; inc edx ; inc ebx ; jmp .compare .differ: inc ebp cmp ebp, ecx - jae .err ; process not found + jae .err ; process not found jmp .next_process .similar: ;print "found server" @@ -185,7 +185,7 @@ clipboard_init: ret .clipserv_pid dd 0 .process_info db 1024 dup(0) -;;.clipserv_name db '@clip',0 +;;.clipserv_name db '@clip',0 ;.IPC_buffer dd .IPC_real_buffer ; sorry ;.IPC_real_buffer db IPC_buffer_size dup(0) @@ -231,7 +231,7 @@ print "write failed" pop edi pop edx pop ecx - ret + ret .msg_set_size dw 1 dw 1 @@ -240,8 +240,8 @@ print "write failed" clipboard_read: ; esi -> CLIP_buffer, ax = format id -; edx - маска событий по умолчанию -; result: eax = 1 - success, 0 - general failure, +; edx - ╨╝╨░╤Б╨║╨░ ╤Б╨╛╨▒╤Л╤В╨╕╨╣ ╨┐╨╛ ╤Г╨╝╨╛╨╗╤З╨░╨╜╨╕╤О +; result: eax = 1 - success, 0 - general failure, ; -1 - buffer too small ; edx = size of data @@ -262,7 +262,7 @@ clipboard_read: mov [.msg_get_buf + 2], ax mov edx, 8 call _ipc_send - or eax, eax + or eax, eax jz .err ;;mov edx, DEFAULT_MASK @@ -291,7 +291,7 @@ pregs or eax, eax jz .err -;print "send fuck" +;print "send DEBUG!" mov edx, ebp mov esi, edi @@ -304,8 +304,7 @@ print "read get data" mov edx, ebx mov eax, 1 print "read ok" - jmp .exit ; i'm an idiot. Never will I code at night again - ; i put jz instead of jmp. + jmp .exit. .size: print "buffer small" @@ -347,7 +346,7 @@ clipboard_delete: mov [esi + 2], ax mov edx, 8 - call _ipc_send + call _ipc_send pop esi pop edx @@ -356,4 +355,3 @@ clipboard_delete: .msg_del dw 0 dw 1 dd 0 - diff --git a/programs/other/outdated/iconedit/trunk/iconedit.asm b/programs/other/outdated/iconedit/trunk/iconedit.asm index 309698088a..0bc1a95c4a 100644 --- a/programs/other/outdated/iconedit/trunk/iconedit.asm +++ b/programs/other/outdated/iconedit/trunk/iconedit.asm @@ -115,7 +115,7 @@ no_lit: button_4: cmp ah,4 ; was it button 4 - LOAD jne button_5 ; no then try button 5 - mov byte [editstate],0 ; dont want to be in edit mode + mov byte [editstate],0 ; don't want to be in edit mode call draw_filename ; update filename call load_file ; load the file call draw_icon ; update icon screen @@ -124,16 +124,16 @@ no_lit: button_5: cmp ah,5 ; was it button 5 - SAVE jne button_6 ; no then try button 6 - mov byte [editstate],0 ; dont want to be in edit mode + mov byte [editstate],0 ; don't want to be in edit mode call draw_filename ; update filename call save_file ; save the file jmp check_mouse ; start loop again button_6: cmp ah,6 ; was it button 6 - CLEAR ICON jne button_7 ; no then try button 7 - mov byte [editstate],0 ; dont want to be in edit mode + mov byte [editstate],0 ; don't want to be in edit mode call draw_filename ; update filename - call clear_graph_icon ; clear the icon and edit screens + call clear_graph_icon ; clear the icon and edit screens jmp check_mouse button_7: @@ -179,7 +179,7 @@ draw_window: mov edx,0x14ffffff ; color of work area 0x00RRGGBB mov edi,title ; WINDOW LABEL mcall - + mov eax,13 ; function 13 : draw bar mov ebx,5*65536+window_x_size-9 ; [x start] *65536 + [x size] mov ecx,(window_y_size-20)*65536+16 ; [y start] *65536 + [y size] @@ -400,7 +400,7 @@ next_b_w_inner: jne next_b_w_outer cmp [first_run],0 ; is it the first window draw - jne dont_load ; no then dont reload the file + jne dont_load ; no then don't reload the file call load_file ; load initial file mov [first_run],1 ; first window draw done dont_load: diff --git a/programs/other/outdated/sb/trunk/sb.asm b/programs/other/outdated/sb/trunk/sb.asm index 70b396c5bc..b21572be53 100644 --- a/programs/other/outdated/sb/trunk/sb.asm +++ b/programs/other/outdated/sb/trunk/sb.asm @@ -851,7 +851,7 @@ draw_window: mov edi,title ; WINDOW LABEL mcall - + mov eax,8 ; START/STOP - id 2 mov ebx,24*65536+77 mov ecx,80*65536+16 @@ -977,7 +977,7 @@ text: db ' ' db ' ' db ' START/STOP << >> REPEAT:OFF ' - db 'x <- END MARKER, DONT DELETE ' + db 'x <- END MARKER, DON'T DELETE ' now_playing: db ' ' db 'xx ' diff --git a/programs/other/table/hello.cpp b/programs/other/table/hello.cpp index f94be98fcd..601c88b4ce 100644 --- a/programs/other/table/hello.cpp +++ b/programs/other/table/hello.cpp @@ -355,14 +355,14 @@ void draw_grid() // column headers + vertical lines cell_x[0] = 0; - x = cell_w[0]; + x = cell_w[0]; nx = 1; for (i = 1; i < col_count && x-x0 < grid.w; i++) { cell_x[i] = -1; if (i >= grid.firstx) { - { + { //if (!sel_moved || (is_x_changed(i))) { if (is_between(i,sel_x,sel_end_x)) bg_color = HEADER_CELL_COLOR_ACTIVE; else bg_color = HEADER_CELL_COLOR; kos_DrawBar(x-x0, 0, 1, grid.h, GRID_COLOR); @@ -404,7 +404,7 @@ void draw_grid() y += cell_h[i]; ny++; } - + // cells itself y = cell_h[0]; for (i = grid.firsty; i < ny; i++) @@ -449,7 +449,7 @@ void draw_grid() else if (error) kos_DrawRegion(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0xff0000, 0); } x += cell_w[j]; - } + } y += cell_h[i]; } DrawScrolls(); @@ -464,7 +464,7 @@ void draw_size_grid() { int x, x0, i; - x = cell_w[0]; + x = cell_w[0]; x0 = 0; for (i = 1; i < col_count && x - x0 + cell_w[i] < grid.w - 10; i++) { @@ -483,7 +483,7 @@ void draw_size_grid() { int y, y0, i; - y = cell_h[0]; + y = cell_h[0]; y0 = 0; for (i = 1; i < col_count && y - y0 + cell_h[i] < grid.h - 10; i++) { @@ -516,7 +516,7 @@ void draw_drag() DWORD x0 = cell_x[k0] - 1; DWORD x1 = cell_x[k1] + cell_w[k1] + 1; - DWORD y0 = cell_y[n0] - 1; + DWORD y0 = cell_y[n0] - 1; DWORD y1 = cell_y[n1] + cell_h[n1] + 1; if (x0 > grid.w - 1) x0 = grid.w - 1; if (x1 > grid.w - 1) x1 = grid.w - 1; @@ -536,7 +536,7 @@ void draw_window() { kos_WindowRedrawStatus(1); kos_DefineAndDrawWindow(110,40,WND_W,WND_H,0x73,0x40FFFFFF,0,0,(Dword)"Table v" TABLE_VERSION); - kos_WindowRedrawStatus(2); + kos_WindowRedrawStatus(2); kos_GetSystemColors(&sc); @@ -560,8 +560,8 @@ void draw_window() int panel_y = cHeight - MENU_PANEL_HEIGHT + 1; kos_DrawBar(0, panel_y, cWidth, MENU_PANEL_HEIGHT-1, sc.work); - kos_WriteTextToWindow(3 + 1, panel_y + 14, 0x90, sc.work_text, (char*)sFilename, 0); - + kos_WriteTextToWindow(3 + 1, panel_y + 14, 0x90, sc.work_text, (char*)sFilename, 0); + file_box.top = panel_y + 10; file_box.width = cWidth - 265; int BTX = cWidth - 190; @@ -589,7 +589,7 @@ void process_mouse() Dword mouse_btn, ckeys, shift, ctrl; int vert, hor; - kos_GetScrollInfo(vert, hor); + kos_GetScrollInfo(vert, hor); if (vert != 0) { stop_edit(); @@ -628,7 +628,7 @@ void process_mouse() mouse_x -= 5; mouse_y -= kos_GetSkinHeight(); - if (is_edit && mouse_x>=cell_box.left && mouse_x<=cell_box.left+cell_box.width + if (is_edit && mouse_x>=cell_box.left && mouse_x<=cell_box.left+cell_box.width && mouse_y>=cell_box.top && mouse_y<=cell_box.top+22) return; mouse_btn &= 0x0001; @@ -644,7 +644,7 @@ void process_mouse() if (!size_state && !mouse_btn) return; - if (mouse_btn && !size_state) // LMB down + if (mouse_btn && !size_state) // LMB down { //rtlDebugOutString("lmb down and not resize"); @@ -707,7 +707,7 @@ void process_mouse() } if (kx != -1 && ky != -1) { - if (!shift) + if (!shift) { move_selection(kx, ky); //return; @@ -795,13 +795,13 @@ void process_mouse() } } draw_drag(); - } + } size_mouse_x = mouse_x; - size_mouse_y = mouse_y; + size_mouse_y = mouse_y; } -void shift_selection(int dx, int dy, Dword shift) +void shift_selection(int dx, int dy, Dword shift) { if (dx != 0) { @@ -874,13 +874,13 @@ void process_key() dword key_editbox; Byte key_ascii, key_scancode; - // key pressed, read it + // key pressed, read it ckeys = kos_GetSpecialKeyState(); shift = ckeys & 0x3; ctrl = ckeys & 0x0c; sel_moved = 0; sel_end_move = 0; - + kos_GetKeys(key_editbox, key_ascii, key_scancode); if (cell_box.flags & ed_focus) { @@ -896,7 +896,7 @@ void process_key() { mov eax, key_editbox } - edit_box_key((dword)&cell_box); + edit_box_key((dword)&cell_box); } } else if (file_box.flags & ed_focus) { @@ -961,7 +961,7 @@ void process_key() //sprintf(debuf, "%U %U %U %U", buf_col, buf_row, x0, y0); //rtlDebugOutString(debuf); - + buffer = (char***)allocmem(buf_col * sizeof(char**)); for (i = 0; i < buf_col; i++) { @@ -985,7 +985,7 @@ void process_key() buffer[i][j] = NULL; } } - if (key_ascii == 24) ///////WTF???? + if (key_ascii == 24) ///////Unexpected!???? calculate_values(); draw_grid(); break; @@ -1149,7 +1149,7 @@ void kos_Main() file_box.size = file_box.pos = strlen(fname); EventLoadFile(); } - kos_SetMaskForEvents(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); + kos_SetMaskForEvents(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); for (;;) { switch (kos_WaitForEvent()) @@ -1165,7 +1165,7 @@ void kos_Main() case EM_BUTTON_CLICK: process_button(); break; - + case EM_WINDOW_REDRAW: draw_window(); break; diff --git a/programs/other/tte/tte.c b/programs/other/tte/tte.c index 099000f79b..ec6d2b8f02 100644 --- a/programs/other/tte/tte.c +++ b/programs/other/tte/tte.c @@ -27,6 +27,7 @@ // warnings. See // https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html // for more info. + #define _DEFAULT_SOURCE #define _BSD_SOURCE #define _GNU_SOURCE @@ -77,11 +78,11 @@ void notify(char *text); /*** Data section ***/ -// Kolibri defaults +// KolibriOS defaults int con_def_wnd_width = 80; int con_def_wnd_height = 25; /// winFile support -int fileIsOd0a; +int fileIsOd0a; typedef struct editor_row { int idx; // Row own index within the file. @@ -137,7 +138,7 @@ struct editor_config { // Having a dynamic buffer will allow us to write only one // time once the screen is refreshing, instead of doing -// a lot of write's. +// a lot of writes. struct a_buf { char* buf; int len; @@ -465,7 +466,7 @@ void enableRawMode() { /// die("Failed to set raw mode"); } -/// by Siemargl rewritten, still Ctrl+ combination works only in english locale, so need analyze scancode +/// by Siemargl rewritten, still Ctrl+ combination works only in English locale, so need analyze scancode int editorReadKey() { int key = con_getch2(); if (key == 0) @@ -485,13 +486,13 @@ int editorReadKey() { case 9: // TAB return key; - + case 22: // Ctrl+V return CTRL_KEY('v'); - + case 3: // Ctrl+C return CTRL_KEY('c'); - + case 12: // Ctrl+L return CTRL_KEY('l'); @@ -516,7 +517,7 @@ int editorReadKey() { */ case 24: // Ctrl+X return CTRL_KEY('x'); - + default: return key; @@ -529,7 +530,7 @@ int editorReadKey() { case 75: // Left return ARROW_LEFT; - + case 77: // Right return ARROW_RIGHT; @@ -541,16 +542,16 @@ int editorReadKey() { case 81: // PgDn return PAGE_DOWN; - + case 73: // PgUp return PAGE_UP; - + case 71: // Home return HOME_KEY; - + case 79: // End return END_KEY; - + default: return 0; } @@ -844,7 +845,7 @@ void editorSelectSyntaxHighlight() { int editorRowCursorXToRenderX(editor_row* row, int cursor_x) { int render_x = 0; int j; - // For each character, if its a tab we use rx % TTE_TAB_STOP + // For each character, if it's a tab we use rx % TTE_TAB_STOP // to find out how many columns we are to the right of the last // tab stop, and then subtract that from TTE_TAB_STOP - 1 to // find out how many columns we are to the left of the next tab @@ -1100,7 +1101,7 @@ char* editorRowsToString(int* buf_len) { // to each one for the newline character we'll add to // the end of each line. for (j = 0; j < ec.num_rows; j++) { - total_len += ec.row[j].size + 1 + total_len += ec.row[j].size + 1 + (fileIsOd0a ? 1:0); /// winFile suppor } *buf_len = total_len; @@ -1187,7 +1188,7 @@ void editorSave() { } free(buf); - editorSetStatusMessage("Cant's save file. Error occurred: %s", strerror(errno)); + editorSetStatusMessage("Can't save file. Error occurred: %s", strerror(errno)); } /*** Search section ***/ @@ -1361,11 +1362,11 @@ void editorDrawStatusBar(struct a_buf* ab) { void editorDrawMessageBar(struct a_buf *ab) { // Clearing the message bar. -/// abufAppend(ab, "\x1b[K", 3); /// not work in Kolibri +/// abufAppend(ab, "\x1b[K", 3); /// not work in KolibriOS int msg_len = strlen(ec.status_msg); if (msg_len > ec.screen_cols) msg_len = ec.screen_cols; - // We only show the message if its less than 5 secons old, but + // We only show the message if it's less than 5 seconds old, but // remember the screen is only being refreshed after each keypress. if (msg_len && time(NULL) - ec.status_msg_time < 5) abufAppend(ab, ec.status_msg, msg_len); @@ -1730,7 +1731,7 @@ void initEditor() { } void printHelp() { -/* +/* printf("Usage: tte [OPTIONS] [FILE]\n\n"); printf("\nKEYBINDINGS\n-----------\n\n"); printf("Keybinding\t\tAction\n\n"); @@ -1751,9 +1752,9 @@ void printHelp() { printf("\n\nFor now, usage of ISO 8859-1 is recommended.\n"); */ - - /// NOTIFY HOTKEYS - char* __help__ = + + /// NOTIFY HOTKEYS + char* __help__ = "'Hotkeys: \n\ ^Q, ^Z Exit \n\ Ctrl-S Save \n\ @@ -1765,9 +1766,9 @@ Ctrl-C Copy line \n\ Ctrl-X Cut line \n\ Ctrl-V Paste line' -t -I"; notify(__help__); - + /// NOTIFY OPTIONS - __help__ = + __help__ = "'Options:\n\ -h, --help Prints the help \n\ -v, --version Prints the version of tte \n\ @@ -1798,7 +1799,7 @@ int handleArgs(int argc, char* argv[]) { } int main(int argc, char* argv[]) { - + #ifdef TCC_BUILD con_init_console_dll_param(con_def_wnd_width, con_def_wnd_height, con_def_wnd_width, con_def_wnd_height, "TinyTextEditor"); #endif @@ -1806,19 +1807,19 @@ int main(int argc, char* argv[]) { load_console(); con_init(con_def_wnd_width, con_def_wnd_height, con_def_wnd_width, con_def_wnd_height, "TinyTextEditor"); #endif - + initEditor(); int arg_response = handleArgs(argc, argv); if (arg_response == 1) { char* filename = argv[1]; // tolower for (int i = 0; i < strlen(filename); i++) filename[i] = tolower(filename[i]); - + editorOpen(filename); char* title = argv[1]; strcat(title, " - TinyTextEditor"); con_set_title(title); - } + } else if (arg_response == -1) return 0; enableRawMode(); diff --git a/programs/testing/pcidev/trunk/PCIDEV.ASM b/programs/testing/pcidev/trunk/PCIDEV.ASM index 9a5ea46a47..1047c968db 100644 --- a/programs/testing/pcidev/trunk/PCIDEV.ASM +++ b/programs/testing/pcidev/trunk/PCIDEV.ASM @@ -1,919 +1,919 @@ -;*************************************************************** -; project name: PCI Device Enumeration -; target platform: KolibriOS -; compiler: flat assembler 1.68 -; version: 2.3 -; last update: Jule 2011 -; maintained by: Jason Delozier -; Sergey Kuzmin -; Mihailov Ilia -; Marat Zakiyanov -; Artem Jerdev -; Evgeny Grechnikov (diamond) -; Veronica (CleverMouse) -; old project site: http://www.coolthemes.narod.ru/pcidev.html -; new project site: http://board.kolibrios.org/viewtopic.php?f=42&t=73 -;*************************************************************** -;Summary: This program will attempt to scan the PCI Bus -; and display basic information about each device -; connected to the PCI Bus. -;*************************************************************** - use32 - org 0x0 - db 'MENUET01' ; 8 byte id - dd 0x01 ; header version - dd START ; start of code - dd IM_END ; size of image - dd I_END ; memory for app - dd stacktop ; esp - dd file_name ; I_Param - dd path ; APPLICATION PATH -;----------------------------------------------------------------------------- -include 'lang.inc' ;language support -include '../../../KOSfuncs.inc' -include '../../../macros.inc' -include '../../../load_lib.mac' -;----------------------------------------------------------------------------- -@use_library ; load_lib macro -;----------------------------------------------------------------------------- -START: - mcall SF_SYS_MISC,SSF_HEAP_INIT - mcall SF_KEYBOARD,SSF_SET_INPUT_MODE,1 -;----------------------------------------------------------------------------- -load_libraries l_libs_start,end_l_libs -;----------------------------------------------------------------------------- -;OpenDialog initialisation - push dword OpenDialog_data - call [OpenDialog_Init] - - mov edi,filename_area - mov esi,start_temp_file_name - call copy_file_name_path -;----------------------------------------------------------------------------- - mcall SF_SYS_MISC,SSF_MEM_ALLOC,4096*4 ; 16 Kb - I hope this will be enough for store of data - mov [store_text_area_start],eax -;----------------------------------------------------------------------------- - call draw_window -align 4 -still: - mcall SF_WAIT_EVENT - dec eax ; redraw request ? - jz red - dec eax ; key in buffer ? - jz key - dec eax ; button in buffer ? - jz button - jmp still -;----------------------------------------------------------------------------- -align 4 -red: ; redraw - call get_window_param - mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure - mov [Form + 2], ax ; x start position - mov eax, [Proc_Info.box.top]; - mov [Form + 6], ax ; ystart position - mov eax, [Proc_Info.box.width] ; - mov [Form], ax ; window width - mov eax, [Proc_Info.box.height] ; - mov [Form + 4] ,ax ; window height - call draw_window ; go redraw window now - jmp still -;----------------------------------------------------------------------------- -align 4 -key: ; key - mcall SF_GET_KEY - cmp [extended_key],1 - je .extended_key - test al, al - jnz still - cmp ah, 0xE0 - jne @f - mov [extended_key],1 - jmp still -@@: - cmp ah,129 ; Esc - je button.exit - cmp ah,159 - je call_OpenDialog - jmp still -.extended_key: - mov [extended_key],0 - cmp ah,129 ; Esc - je button.exit - cmp ah,159 - je call_OpenDialog - jmp still -;----------------------------------------------------------------------------- -align 4 -button: ; button - mcall SF_GET_BUTTON - cmp ah,2 - je call_OpenDialog - cmp ah, 1 ; button id = 1 ? - jne still -.exit: - mcall SF_TERMINATE_PROCESS -;----------------------------------------------------------------------------- -call_OpenDialog: - mov [OpenDialog_data.type],1 ; Save - - push dword OpenDialog_data - call [OpenDialog_Start] - - cmp [OpenDialog_data.status],2 ; OpenDialog does not start - je .save_file_default_path - - cmp [OpenDialog_data.status],1 - jne still - - call store_data - jmp still -;---------------------------------------- -.save_file_default_path: - mov edi,file_name - mov esi,file_default_path - call copy_file_name_path - call store_data - jmp still -;---------------------------------------- -copy_file_name_path: - xor eax,eax - cld -@@: - lodsb - stosb - test eax,eax - jnz @r - ret -;----------------------------------------------------------------------------- -prepare_text_area: - mov edi,[store_text_area_start] - - push edi - mov ecx,4096 ; 16 Kb - I hope this will be enough for store of data - mov eax,dword ' ' - cld - rep stosd - pop edi - - mov esi,PCIWin - xor ecx,ecx -@@: - mov cl,[esi] - inc esi - rep movsb - mov al,0Ah ; CR - carriage return - stosb - cmp [esi],byte 0xFF - jne @r - - mov [store_text_area_end],edi - - xor edi,edi - ret -;----------------------------------------------------------------------------- -get_window_param: - mcall SF_THREAD_INFO, Proc_Info, -1 ; window redraw requested so get - ; new window coordinates and size - ret -;----------------------------------------------------------------------------- -align 4 -draw_window: - call prepare_text_area - - mov byte [total], 0 - mcall SF_REDRAW, SSF_BEGIN_DRAW - ; DRAW WINDOW - mcall SF_CREATE_WINDOW,dword [Form],dword [Form + 4],0x13ffffff,0x805080d0,title - - call get_window_param - - mov eax,[Proc_Info+70] ;status of window - test eax,100b - jne .end - - mcall SF_DEFINE_BUTTON,<450,100>,<25,25>,2,0xC0C0C0 - shr ecx,16 - mov bx,cx - add ebx,13 shl 16+4 - mcall SF_DRAW_TEXT,,0x80000000,text_save_button - add bx,11 - mcall ,,,text_save_button.1 - ; Insert horizontal bars in list area - mov eax, 13 ; draw bar system function - mov ebx, 18 ; set Xstart position of bar - shl ebx, 16 ; - mov bx, word [Form] ; get width of window - sub bx, 32 ; bar is 32 pixels shorter then window width - mov ecx, 119 * 65536 + 10 ; set Ystart(109) and Height(10) of bar 109 - mov edx, 0xC0C0C0 ; set color of bar -.again: ;begin draw bar loop - mcall ; draw bar to window area - shr ecx, 16 ; move the Ystart position to working area - add ecx, 34 ; add 34 pixels to Y Start (moves bar down) - cmp cx, word [Form + 4] ; is the Ystart position outside of window area - jae .nomo ; if so stop drawing bars - sub ecx, 14 ; if not, we only need 20 pixels between bar tops - shl ecx, 16 ; set that values as Ystart - add ecx, 10 ; Bar Height is always 10 pixels - jmp .again ; draw another bar -;----------------------------------------------------------------------------- -.nomo: ;done drawing bars here - ; start PCI stuff - call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device - - ; Window inteface - mov cx, [PCI_Version] - add ch, '0' - mov [PCIWin + 85], ch ; 0xBADCODE but it works ! - mov ch, cl - shr cl, 4 - and ch, 0x0f - add cx, '00' - mov [PCIWin + 87], cx -; mov cl, [PCI_LastBus] ; will only work if [PCI_LastBus] < 10 -; add cl, '0' -; mov [PCIWin + 106], cl - - mov edx, PCIWin - mov ebx, 20 * 65536 + 25 ; x start, ystart of text - mov ecx, 0x224466 ; color of text - mov eax, 4 -@@: - movzx esi, byte[edx] - inc edx - mcall - add ebx, 10 - add edx, esi - cmp byte[edx], -1 - jne @b - ; Quantity of devices... - movzx ecx, byte [total] ; number to draw - mcall SF_DRAW_NUMBER, 0x00020000,,150 * 65536 + 65, 0x224466 - movzx ecx, byte [PCI_LastBus] ; number to draw - mcall SF_DRAW_NUMBER, 0x00020000,,<236, 45>, 0x224466 - - - mov ebx,ecx - mov ecx,2 - mov edi,[store_text_area_start] - add edi,157 - push edi - call binary_to_hex_string - pop edi - mov [edi+2],byte 'h' - - mov ah, [MMIO_allowed] - or ah, ah - jz @f - mov ah, [MMIO_Bus] ; =255 if MMIO disabled / not found - and ah, 0x7f - inc ah - jo @f - call Try_MMIO -@@: -.end: - mcall SF_REDRAW, SSF_END_DRAW - ret -;----------------------------------------------------------------------------- -store_data: - mov eax,[store_text_area_start] - mov [fileinfo.return],eax - mov ebx,[store_text_area_end] - sub ebx,eax - inc ebx - mov [fileinfo.size],ebx - mcall SF_FILE,fileinfo - ret -;----------------------------------------------------------------------------- -;* Gets the PCI Version and Last Bus -Get_PCI_Info: - mcall SF_PCI, 0 - mov word [PCI_Version], ax - mcall SF_PCI, 1 - mov byte [PCI_LastBus], al - ;---------------------------------------------------------- - ;* Get all devices on PCI Bus - cmp al, 0xff ; 0xFF means no pci bus found - jne Pci_Exists ; - ret ; if no bus then leave -;----------------------------------------------------------------------------- -Pci_Exists: - mov byte [V_Bus], 0 ; reset varibles - mov byte [V_Dev], 0 ; - mov edx, 20 * 65536 + 110 ; set start write position -Start_Enum: - mov bl, 6 ; get a dword - mov bh, byte [V_Bus] ; bus of pci device - mov ch, byte [V_Dev] ; device number/function - mov cl, 0 ; offset to device/vendor id - mcall SF_PCI ; get ID's - - cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF - je nextDev ; check next device if nothing exists here - - cmp ax, 0xffff ; - je nextDev ; - - mov word [PCI_Vendor], ax ; There is a device here, save the ID's - shr eax, 16 ; - mov word [PCI_Device], ax ; - mov bl, 4 ; Read config byte - mov bh, byte [V_Bus] ; Bus # - mov ch, byte [V_Dev] ; Device # on bus - mov cl, 0x08 ; Register to read (Get Revision) - mcall SF_PCI ; Read it - - mov byte [PCI_Rev], al ; Save it - mov cl, 0x0b ; Register to read (Get class) - mcall SF_PCI ; Read it - - mov byte [PCI_Class], al ; Save it - mov cl, 0x0a ; Register to read (Get Subclass) - mcall SF_PCI ; Read it - mov byte [PCI_SubClass], al; Save it -; by Mario79 august 2006 - mov cl, 0x09 ; Register to read (Get Interface) - mcall SF_PCI ; Read it - - mov [PCI_Interface], al ; Save it -; -; by Ghost april 2007 - mov cl, 0x3c ; Register to read (Get IRQ) -@@: - mcall SF_PCI ; Read it - - mov [PCI_IRQ], al ; Save it -; by CleverMouse juny 2011 - mov cl, 0x0e - mcall SF_PCI - - push eax - inc byte [total] ; one more device found - call Print_New_Device ; print device info to screen -; don't scan for nonzero functions if zero function says "not multifunction device" - pop eax - test al, al - js nextDev - - test byte [V_Dev], 7 - jnz nextDev - - or byte [V_Dev], 7 -nextDev: - inc byte [V_Dev] ; next device on this bus - jnz Start_Enum ; jump until we reach zero - ;(used to be JNO which caused bug!!! 30-4-2006, JMD) - mov byte [V_Dev], 0 ; reset device number - inc byte [V_Bus] ; next bus - mov al, byte [PCI_LastBus] ; get last bus - cmp byte [V_Bus], al ; was it last bus - jbe Start_Enum ; if not jump to keep searching - ret -;----------------------------------------------------------------------------- -no_ummio_allowed: - xor al,al - mov [MMIO_allowed],al ; re-enter the subroutine -;------------------------------------------------------------------ -;* Print device info to screen - -Print_New_Device: - xor esi, esi ; default text color - mov cl, [MMIO_allowed] - or cl,cl - jz no_ummio_here - mov ch, byte [V_Bus] - mov cl, byte [V_Dev] - mcall SF_PCI, 11 ; detect uMMIO - - and ax,0x7fff - inc ax ; -1 returned? - jo no_ummio_allowed - - inc ax ; -2 returned? - jo no_ummio_here - - inc ax ; -3 returned? - jo no_ummio_here - - mov esi, 0x990033 ; highlighted text color - mov bh, byte [V_Bus] - mov bl, byte [V_Dev] - mov byte [MMIO_Bus], bh - mov byte [MMIO_Dev], bl - add bh,'0' - mov [PCIWin + 129], bh ; uMMIO bus - mov al, bl - shr al, 1 - shr al, 1 - shr al, 1 - add al,'0' - mov [PCIWin + 131], al ; uMMIO device - and bl, 7 - add bl, '0' - mov [PCIWin + 133], bl ; uMMIO function - -no_ummio_here: - movzx ecx,word [PCI_Vendor] ; Pointer to number to be written - mcall SF_DRAW_NUMBER, 0x00040100 ; Write Vendor ID - - call store_4_digits - - and edx, 0xFFFF ;***************************************** - or edx, 54 * 65536 ; X start becomes 54 - movzx ecx, word [PCI_Device] ; get Vendor ID - mcall ; Draw Vendor ID to Window - - call store_4_digits - - and edx, 0xFFFF ;***************************************** - or edx, 98 * 65536 ; X start becomes 98 - movzx ecx, byte [V_Bus] ; get bus number - mcall ,0x00020100 ; draw bus number to screen - - call store_2_digits - - and edx, 0xFFFF ;***************************************** - or edx, 128 * 65536 ; X start becomes 128 - movzx ecx, byte [V_Dev] ; get device number - shr ecx, 3 ; device number is bits 3-7 - mcall ; Draw device Number To Window - - call store_2_digits - - and edx, 0xFFFF ;***************************************** - or edx, 155 * 65536 ; X start becomes 155 - movzx ecx, byte [V_Dev] ; get Function number - and ecx, 7 ; function is first 3 bits - mcall ; Draw Function Number To Window - - call store_2_digits - - and edx, 0xFFFF ;***************************************** - or edx, 179 * 65536 ; X start becomes 179 - movzx ecx, byte [PCI_Rev] ; get revision number - mcall ; Draw Revision to screen - - call store_2_digits - - and edx, 0xFFFF ;***************************************** - or edx, 215*65536 ; X start becomes 215 - movzx ecx, byte [PCI_Class] ; get PCI_Class - mcall ; Draw Class to screen - - call store_2_digits - - and edx, 0xFFFF ;***************************************** - or edx, 250*65536 ; X start becomes 250 - movzx ecx, byte [PCI_SubClass]; get sub class - mcall ; Draw Sub Class to screen - - call store_2_digits - -; from Mario79 august 2006 - and edx, 0xFFFF ;***************************************** - or edx, 280 * 65536 ; X start becomes 280 - movzx ecx, [PCI_Interface] ; get Interface - mcall - - call store_2_digits - -; -; from Ghost april 2007 ;***************************************** - and edx, 0xFFFF - or edx, 310 * 65536 ; X start becomes 310 - movzx ecx, [PCI_IRQ] ; get Interface - cmp cl, 63 ; IRQ between 0..63 - ja @f - - mcall - - call store_2_digits - jmp .PCI_Vendor -@@: - call store_NA -.PCI_Vendor: - ;Write Names - movzx ebx, dx ; Set y position - or ebx, 340 * 65536 ; set Xposition to 340 - -;------------------------------------------------------------------ -; Prints the Vendor's Name based on Vendor ID -; -; Modified on ??-04-2007 by Ghost for size -;------------------------------------------------------------------ - mov edx, VendorsTab - mov cx, word[PCI_Vendor] - -.fn: - mov ax, [edx] - add edx, 6 - test ax, ax - jz .find - - cmp ax, cx - jne .fn - -.find: - mov edx, [edx - 4] - mcall SF_DRAW_TEXT,, 0x80000000 ; lets print the vendor Name - - mov [store_text_size],42 - call store_text -;------------------------------------------------------------------ -; Get description based on Class/Subclass -; -; Modified on ??-04-2007 by Ghost for size -;------------------------------------------------------------------ - mov eax, dword [PCI_Class] - and eax, 0xffffff - xor edx, edx - xor esi, esi -.fnc: - inc esi - mov ecx, [Classes + esi * 8 - 8] - cmp cx, 0xffff - je .endfc - - cmp cx, ax - jne .fnc - - test ecx, 0xff000000 - jz @f - - mov edx, [Classes + esi * 8 - 4] - jmp .fnc -@@: - cmp eax, ecx - jne .fnc - - xor edx, edx -.endfc: - test edx, edx - jnz @f - - mov edx, [Classes + esi * 8 - 4] -@@: - and ebx, 0x0000FFFF ; clear X position - or ebx, 0x24E0000 ; set X position to 590 pixels - mcall SF_DRAW_TEXT,, 0x80000000,, 32 ; draw the text - - mov [store_text_size],0 - call store_text - call store_CR - - movzx edx, bx ; get y coordinate - add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20 - mov [gr_pos], edx - ret -;------------------------------------------------------------------ -; Get the user-MMIO related info -; -; Added on ??-12-2009 by art_zh -;------------------------------------------------------------------ -Try_MMIO: - xor ebx, ebx - mov edx, ebx - mov bh, [MMIO_BAR] - or bx, 12 ; function 12 - mov ecx, 4096 ; =1 page to map - mcall SF_PCI - - mov [MMIO_Map], eax ; store MMIO lin.addr. - mov ecx, 0x80990022 ; print color : red - add bh, '0' - cmp eax, -3 - jne @f - - mov [bar_um+3], bh - mov ebx, [gr_pos] - mov edx, bar_um - mcall SF_DRAW_TEXT - - jmp mmio_next_bar -@@: - cmp eax, -4 - jne @f - mov [bar_io+3], bh - mov ebx, [gr_pos] - mov edx, bar_io - mcall SF_DRAW_TEXT - - jmp mmio_next_bar -@@: - cmp bh, '6' ; expansion ROM ? - je @f - mov [bar_ram+3], bh - mov ebx, [gr_pos] - mov edx, bar_ram - mcall SF_DRAW_TEXT - - jmp mmio_dump -;----------------------------------------------------------------------------- -@@: - mov ebx, [gr_pos] - mov edx, bar_rom - mcall SF_DRAW_TEXT - -mmio_dump: - mov edx, [MMIO_Map] - mov esi, 64 - mov ecx, 0x099 ; dump color : blue - add ebx, 10 - mov [gr_pos], ebx - mcall SF_DRAW_TEXT - - mov ecx, [MMIO_Map] ; release the tried page - mcall SF_PCI,13 - -mmio_next_bar: - mov bh, [MMIO_BAR] - inc bh - cmp bh,7 - je @f - - mov [MMIO_BAR], bh - add [gr_pos], 10 - jmp Try_MMIO -;----------------------------------------------------------------------------- -@@: - xor bh,bh - mov [MMIO_BAR], bh - ret -;----------------------------------------------------------------------------- -store_CR: - pusha - mov edi,[store_text_area_end] - mov [edi],word 0A20h ; CR (carriage return) + SPACE - add dword [store_text_area_end],2 - popa - ret -;----------------------------------------------------------------------------- -store_text: - pusha - inc dword [store_text_area_end] - mov esi,edx - mov edi,[store_text_area_end] - push edi - xor eax,eax - cld -@@: - lodsb - test eax,eax - jz @f - stosb - inc dword [store_text_area_end] - jmp @r -@@: - pop esi - mov eax,[store_text_size] - test eax,eax - jz @f - sub edi,esi - sub eax,edi - add [store_text_area_end],eax -@@: - popa - ret -;----------------------------------------------------------------------------- -store_NA: - pusha - mov ebx,edx - mcall SF_DRAW_TEXT,,0x80000000,text_NA - mov edi,[store_text_area_end] - mov ax,[edx] - mov [edi+1],ax - add [store_text_area_end],dword 5 - popa - ret -;----------------------------------------------------------------------------- -store_2_digits: - pusha - inc [store_text_area_end] - mov ebx,ecx - mov ecx,2 - mov edi,[store_text_area_end] - call binary_to_hex_string - add [store_text_area_end],dword 4 - popa - ret -;----------------------------------------------------------------------------- -store_4_digits: - pusha - mov ebx,ecx - mov ecx,4 - mov edi,[store_text_area_end] - call binary_to_hex_string - add [store_text_area_end],dword 6 - popa - ret -;----------------------------------------------------------------------------- -; ebx - value -; ecx - digits -; edi - output string -binary_to_hex_string: - add edi,ecx - dec edi - std -.1: - mov al,bl - and al,0xf - shr ebx,4 - cmp al,9 - jbe @f - - add al,0x27 -@@: - add al,0x30 - stosb - dec ecx - jnz .1 - cld - ret -;----------------------------------------------------------------------------- -include 'vendors.inc' -;----------------------------------------------------------------------------- -; DATA AREA -DATA - -Form: dw 800 ; window width (no more, special for 800x600) - dw 100 ; window x start - dw 748 ; window height - dw 20 ; window y start - -title db 'PCI Device Enumerator v 2.3', 0 - -if lang eq it -PCIWin mls \ - ' Don`t forget to enable PCI Access to Applications in Setup Menu.',\ - '',\ - 'Versione PCI = x.xx; Ultimo Bus PCI = ',\ - 'User MMIO channel = 0F.F:F ',\ - 'Numbero di unit├а PCI = ',\ - '',\ - 'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ IRQ Compania Descrizzione',\ - ' Interfaccia',\ - '----- ----- ---- ---- --- --- ----- --------- --- ------------------------------------------ --------------------------------' - -bar_ram db 'BARx: MMIO block', 0 -bar_io db 'BARx: porte IO',0 -bar_um db 'BARx: unmapped',0 -bar_rom db 'BAR6: Expansion ROM', 0 - -text_save_button: - db 'Salva lista PCI',0 -.1: db '(Premere S)',0 -else -PCIWin mls \ - ' Don`t forget to enable PCI Access to Applications in Setup Menu.',\ - '',\ - 'PCI Version = x.xx; Last PCI Bus = ',\ - 'User MMIO channel = 0F.F:F ',\ - 'Number of PCI units = ',\ - '',\ - 'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ IRQ Company Description',\ - ' Interface',\ - '----- ----- ---- ---- --- --- ----- --------- --- ------------------------------------------ --------------------------------' - -bar_ram db 'BARx: MMIO block', 0 -bar_io db 'BARx: IO ports',0 -bar_um db 'BARx: unmapped',0 -bar_rom db 'BAR6: Expansion ROM', 0 - -text_save_button: - db 'Save PCI list',0 -.1: db '(Press S key)',0 -end if - -text_NA: - db '--',0 -;--------------------------------------------------------------------- -system_dir_ProcLib db '/sys/lib/proc_lib.obj',0 - -;--------------------------------------------------------------------- -l_libs_start: - -library02 l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, ProcLib_import - -end_l_libs: -;--------------------------------------------------------------------- -align 4 -ProcLib_import: -OpenDialog_Init dd aOpenDialog_Init -OpenDialog_Start dd aOpenDialog_Start -;OpenDialog__Version dd aOpenDialog_Version - dd 0 - dd 0 -aOpenDialog_Init db 'OpenDialog_init',0 -aOpenDialog_Start db 'OpenDialog_start',0 -;aOpenDialog_Version db 'Version_OpenDialog',0 -;--------------------------------------------------------------------- -align 4 -OpenDialog_data: -.type dd 0 -.procinfo dd Proc_Info ;+4 -.com_area_name dd communication_area_name ;+8 -.com_area dd 0 ;+12 -.opendir_pach dd temp_dir_pach ;+16 -.dir_default_pach dd communication_area_default_pach ;+20 -.start_path dd open_dialog_path ;+24 -.draw_window dd draw_window ;+28 -.status dd 0 ;+32 -.openfile_pach dd file_name ;+36 -.filename_area dd filename_area ;+40 -.filter_area dd Filter -.x: -.x_size dw 420 ;+48 ; Window X size -.x_start dw 10 ;+50 ; Window X position -.y: -.y_size dw 320 ;+52 ; Window y size -.y_start dw 10 ;+54 ; Window Y position - -communication_area_name: - db 'FFFFFFFF_open_dialog',0 -open_dialog_path: - db '/sys/File Managers/opendial',0 -communication_area_default_pach: - db '/sys',0 -Filter: -dd Filter.end - Filter.1 -.1: -db 'TXT',0 -db 'LOG',0 -.end: -dd 0 - -file_default_path: - db '/sys/' -start_temp_file_name: - db 'pcidev.txt',0 -;--------------------------------------------------------------------- -align 4 -fileinfo: -.subfunction dd 2 -.Offset dd 0 -.Offset_1 dd 0 -.size dd 4096 -.return dd 0 - db 0 -.name: dd file_name -;----------------------------------------------------------------------------- - -; UNINITIALIZED DATA AREA -IM_END: -total db ? -V_Bus db ? -V_Dev db ? -PCI_Version dw ? -PCI_LastBus db ? -PCI_Device dw ? -PCI_Vendor dw ? -PCI_Bus db ? -PCI_Dev db ? -PCI_Rev db ? -; don`t change order!!! -PCI_Class db ? -PCI_SubClass db ? -PCI_Interface db ? -PCI_IRQ db ? - -align 4 -MMIO_Bus db 255 -MMIO_Dev db 255 -MMIO_BAR db 0 -MMIO_allowed db 1 -MMIO_Map rd 8 - -gr_pos dd ? - -store_text_area_start dd ? -store_text_area_end dd ? -store_text_size dd ? - -extended_key rb 1 -;--------------------------------------------------------------------- -library_path: - rb 4096 -;--------------------------------------------------------------------- -path: - rb 4096 -;--------------------------------------------------------------------- -temp_dir_pach: - rb 4096 -;--------------------------------------------------------------------- -file_name: - rb 4096 -;--------------------------------------------------------------------- -file_name_1: - rb 4096 -;--------------------------------------------------------------------- -filename_area: - rb 256 -;--------------------------------------------------------------------- - rb 4096 -stacktop: -;--------------------------------------------------------------------- -Proc_Info process_information -;--------------------------------------------------------------------- -I_END: -;----------------------------------------------------------------------------- +;*************************************************************** +; project name: PCI Device Enumeration +; target platform: KolibriOS +; compiler: flat assembler 1.68 +; version: 2.3 +; last update: Jule 2011 +; maintained by: Jason Delozier +; Sergey Kuzmin +; Mihailov Ilia +; Marat Zakiyanov +; Artem Jerdev +; Evgeny Grechnikov (diamond) +; Veronica (CleverMouse) +; old project site: http://www.coolthemes.narod.ru/pcidev.html +; new project site: http://board.kolibrios.org/viewtopic.php?f=42&t=73 +;*************************************************************** +;Summary: This program will attempt to scan the PCI Bus +; and display basic information about each device +; connected to the PCI Bus. +;*************************************************************** + use32 + org 0x0 + db 'MENUET01' ; 8 byte id + dd 0x01 ; header version + dd START ; start of code + dd IM_END ; size of image + dd I_END ; memory for app + dd stacktop ; esp + dd file_name ; I_Param + dd path ; APPLICATION PATH +;----------------------------------------------------------------------------- +include 'lang.inc' ;language support +include '../../../KOSfuncs.inc' +include '../../../macros.inc' +include '../../../load_lib.mac' +;----------------------------------------------------------------------------- +@use_library ; load_lib macro +;----------------------------------------------------------------------------- +START: + mcall SF_SYS_MISC,SSF_HEAP_INIT + mcall SF_KEYBOARD,SSF_SET_INPUT_MODE,1 +;----------------------------------------------------------------------------- +load_libraries l_libs_start,end_l_libs +;----------------------------------------------------------------------------- +;OpenDialog initialisation + push dword OpenDialog_data + call [OpenDialog_Init] + + mov edi,filename_area + mov esi,start_temp_file_name + call copy_file_name_path +;----------------------------------------------------------------------------- + mcall SF_SYS_MISC,SSF_MEM_ALLOC,4096*4 ; 16 Kb - I hope this will be enough for store of data + mov [store_text_area_start],eax +;----------------------------------------------------------------------------- + call draw_window +align 4 +still: + mcall SF_WAIT_EVENT + dec eax ; redraw request ? + jz red + dec eax ; key in buffer ? + jz key + dec eax ; button in buffer ? + jz button + jmp still +;----------------------------------------------------------------------------- +align 4 +red: ; redraw + call get_window_param + mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure + mov [Form + 2], ax ; x start position + mov eax, [Proc_Info.box.top]; + mov [Form + 6], ax ; ystart position + mov eax, [Proc_Info.box.width] ; + mov [Form], ax ; window width + mov eax, [Proc_Info.box.height] ; + mov [Form + 4] ,ax ; window height + call draw_window ; go redraw window now + jmp still +;----------------------------------------------------------------------------- +align 4 +key: ; key + mcall SF_GET_KEY + cmp [extended_key],1 + je .extended_key + test al, al + jnz still + cmp ah, 0xE0 + jne @f + mov [extended_key],1 + jmp still +@@: + cmp ah,129 ; Esc + je button.exit + cmp ah,159 + je call_OpenDialog + jmp still +.extended_key: + mov [extended_key],0 + cmp ah,129 ; Esc + je button.exit + cmp ah,159 + je call_OpenDialog + jmp still +;----------------------------------------------------------------------------- +align 4 +button: ; button + mcall SF_GET_BUTTON + cmp ah,2 + je call_OpenDialog + cmp ah, 1 ; button id = 1 ? + jne still +.exit: + mcall SF_TERMINATE_PROCESS +;----------------------------------------------------------------------------- +call_OpenDialog: + mov [OpenDialog_data.type],1 ; Save + + push dword OpenDialog_data + call [OpenDialog_Start] + + cmp [OpenDialog_data.status],2 ; OpenDialog does not start + je .save_file_default_path + + cmp [OpenDialog_data.status],1 + jne still + + call store_data + jmp still +;---------------------------------------- +.save_file_default_path: + mov edi,file_name + mov esi,file_default_path + call copy_file_name_path + call store_data + jmp still +;---------------------------------------- +copy_file_name_path: + xor eax,eax + cld +@@: + lodsb + stosb + test eax,eax + jnz @r + ret +;----------------------------------------------------------------------------- +prepare_text_area: + mov edi,[store_text_area_start] + + push edi + mov ecx,4096 ; 16 Kb - I hope this will be enough for store of data + mov eax,dword ' ' + cld + rep stosd + pop edi + + mov esi,PCIWin + xor ecx,ecx +@@: + mov cl,[esi] + inc esi + rep movsb + mov al,0Ah ; CR - carriage return + stosb + cmp [esi],byte 0xFF + jne @r + + mov [store_text_area_end],edi + + xor edi,edi + ret +;----------------------------------------------------------------------------- +get_window_param: + mcall SF_THREAD_INFO, Proc_Info, -1 ; window redraw requested so get + ; new window coordinates and size + ret +;----------------------------------------------------------------------------- +align 4 +draw_window: + call prepare_text_area + + mov byte [total], 0 + mcall SF_REDRAW, SSF_BEGIN_DRAW + ; DRAW WINDOW + mcall SF_CREATE_WINDOW,dword [Form],dword [Form + 4],0x13ffffff,0x805080d0,title + + call get_window_param + + mov eax,[Proc_Info+70] ;status of window + test eax,100b + jne .end + + mcall SF_DEFINE_BUTTON,<450,100>,<25,25>,2,0xC0C0C0 + shr ecx,16 + mov bx,cx + add ebx,13 shl 16+4 + mcall SF_DRAW_TEXT,,0x80000000,text_save_button + add bx,11 + mcall ,,,text_save_button.1 + ; Insert horizontal bars in list area + mov eax, 13 ; draw bar system function + mov ebx, 18 ; set Xstart position of bar + shl ebx, 16 ; + mov bx, word [Form] ; get width of window + sub bx, 32 ; bar is 32 pixels shorter then window width + mov ecx, 119 * 65536 + 10 ; set Ystart(109) and Height(10) of bar 109 + mov edx, 0xC0C0C0 ; set color of bar +.again: ;begin draw bar loop + mcall ; draw bar to window area + shr ecx, 16 ; move the Ystart position to working area + add ecx, 34 ; add 34 pixels to Y Start (moves bar down) + cmp cx, word [Form + 4] ; is the Ystart position outside of window area + jae .nomo ; if so stop drawing bars + sub ecx, 14 ; if not, we only need 20 pixels between bar tops + shl ecx, 16 ; set that values as Ystart + add ecx, 10 ; Bar Height is always 10 pixels + jmp .again ; draw another bar +;----------------------------------------------------------------------------- +.nomo: ;done drawing bars here + ; start PCI stuff + call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device + + ; Window inteface + mov cx, [PCI_Version] + add ch, '0' + mov [PCIWin + 85], ch ; 0xBADCODE but it works ! + mov ch, cl + shr cl, 4 + and ch, 0x0f + add cx, '00' + mov [PCIWin + 87], cx +; mov cl, [PCI_LastBus] ; will only work if [PCI_LastBus] < 10 +; add cl, '0' +; mov [PCIWin + 106], cl + + mov edx, PCIWin + mov ebx, 20 * 65536 + 25 ; x start, ystart of text + mov ecx, 0x224466 ; color of text + mov eax, 4 +@@: + movzx esi, byte[edx] + inc edx + mcall + add ebx, 10 + add edx, esi + cmp byte[edx], -1 + jne @b + ; Quantity of devices... + movzx ecx, byte [total] ; number to draw + mcall SF_DRAW_NUMBER, 0x00020000,,150 * 65536 + 65, 0x224466 + movzx ecx, byte [PCI_LastBus] ; number to draw + mcall SF_DRAW_NUMBER, 0x00020000,,<236, 45>, 0x224466 + + + mov ebx,ecx + mov ecx,2 + mov edi,[store_text_area_start] + add edi,157 + push edi + call binary_to_hex_string + pop edi + mov [edi+2],byte 'h' + + mov ah, [MMIO_allowed] + or ah, ah + jz @f + mov ah, [MMIO_Bus] ; =255 if MMIO disabled / not found + and ah, 0x7f + inc ah + jo @f + call Try_MMIO +@@: +.end: + mcall SF_REDRAW, SSF_END_DRAW + ret +;----------------------------------------------------------------------------- +store_data: + mov eax,[store_text_area_start] + mov [fileinfo.return],eax + mov ebx,[store_text_area_end] + sub ebx,eax + inc ebx + mov [fileinfo.size],ebx + mcall SF_FILE,fileinfo + ret +;----------------------------------------------------------------------------- +;* Gets the PCI Version and Last Bus +Get_PCI_Info: + mcall SF_PCI, 0 + mov word [PCI_Version], ax + mcall SF_PCI, 1 + mov byte [PCI_LastBus], al + ;---------------------------------------------------------- + ;* Get all devices on PCI Bus + cmp al, 0xff ; 0xFF means no pci bus found + jne Pci_Exists ; + ret ; if no bus then leave +;----------------------------------------------------------------------------- +Pci_Exists: + mov byte [V_Bus], 0 ; reset varibles + mov byte [V_Dev], 0 ; + mov edx, 20 * 65536 + 110 ; set start write position +Start_Enum: + mov bl, 6 ; get a dword + mov bh, byte [V_Bus] ; bus of pci device + mov ch, byte [V_Dev] ; device number/function + mov cl, 0 ; offset to device/vendor id + mcall SF_PCI ; get ID's + + cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF + je nextDev ; check next device if nothing exists here + + cmp ax, 0xffff ; + je nextDev ; + + mov word [PCI_Vendor], ax ; There is a device here, save the ID's + shr eax, 16 ; + mov word [PCI_Device], ax ; + mov bl, 4 ; Read config byte + mov bh, byte [V_Bus] ; Bus # + mov ch, byte [V_Dev] ; Device # on bus + mov cl, 0x08 ; Register to read (Get Revision) + mcall SF_PCI ; Read it + + mov byte [PCI_Rev], al ; Save it + mov cl, 0x0b ; Register to read (Get class) + mcall SF_PCI ; Read it + + mov byte [PCI_Class], al ; Save it + mov cl, 0x0a ; Register to read (Get Subclass) + mcall SF_PCI ; Read it + mov byte [PCI_SubClass], al; Save it +; by Mario79 august 2006 + mov cl, 0x09 ; Register to read (Get Interface) + mcall SF_PCI ; Read it + + mov [PCI_Interface], al ; Save it +; +; by Ghost april 2007 + mov cl, 0x3c ; Register to read (Get IRQ) +@@: + mcall SF_PCI ; Read it + + mov [PCI_IRQ], al ; Save it +; by CleverMouse juny 2011 + mov cl, 0x0e + mcall SF_PCI + + push eax + inc byte [total] ; one more device found + call Print_New_Device ; print device info to screen +; don't scan for nonzero functions if zero function says "not multifunction device" + pop eax + test al, al + js nextDev + + test byte [V_Dev], 7 + jnz nextDev + + or byte [V_Dev], 7 +nextDev: + inc byte [V_Dev] ; next device on this bus + jnz Start_Enum ; jump until we reach zero + ;(used to be JNO which caused bug!!! 30-4-2006, JMD) + mov byte [V_Dev], 0 ; reset device number + inc byte [V_Bus] ; next bus + mov al, byte [PCI_LastBus] ; get last bus + cmp byte [V_Bus], al ; was it last bus + jbe Start_Enum ; if not jump to keep searching + ret +;----------------------------------------------------------------------------- +no_ummio_allowed: + xor al,al + mov [MMIO_allowed],al ; re-enter the subroutine +;------------------------------------------------------------------ +;* Print device info to screen + +Print_New_Device: + xor esi, esi ; default text color + mov cl, [MMIO_allowed] + or cl,cl + jz no_ummio_here + mov ch, byte [V_Bus] + mov cl, byte [V_Dev] + mcall SF_PCI, 11 ; detect uMMIO + + and ax,0x7fff + inc ax ; -1 returned? + jo no_ummio_allowed + + inc ax ; -2 returned? + jo no_ummio_here + + inc ax ; -3 returned? + jo no_ummio_here + + mov esi, 0x990033 ; highlighted text color + mov bh, byte [V_Bus] + mov bl, byte [V_Dev] + mov byte [MMIO_Bus], bh + mov byte [MMIO_Dev], bl + add bh,'0' + mov [PCIWin + 129], bh ; uMMIO bus + mov al, bl + shr al, 1 + shr al, 1 + shr al, 1 + add al,'0' + mov [PCIWin + 131], al ; uMMIO device + and bl, 7 + add bl, '0' + mov [PCIWin + 133], bl ; uMMIO function + +no_ummio_here: + movzx ecx,word [PCI_Vendor] ; Pointer to number to be written + mcall SF_DRAW_NUMBER, 0x00040100 ; Write Vendor ID + + call store_4_digits + + and edx, 0xFFFF ;***************************************** + or edx, 54 * 65536 ; X start becomes 54 + movzx ecx, word [PCI_Device] ; get Vendor ID + mcall ; Draw Vendor ID to Window + + call store_4_digits + + and edx, 0xFFFF ;***************************************** + or edx, 98 * 65536 ; X start becomes 98 + movzx ecx, byte [V_Bus] ; get bus number + mcall ,0x00020100 ; draw bus number to screen + + call store_2_digits + + and edx, 0xFFFF ;***************************************** + or edx, 128 * 65536 ; X start becomes 128 + movzx ecx, byte [V_Dev] ; get device number + shr ecx, 3 ; device number is bits 3-7 + mcall ; Draw device Number To Window + + call store_2_digits + + and edx, 0xFFFF ;***************************************** + or edx, 155 * 65536 ; X start becomes 155 + movzx ecx, byte [V_Dev] ; get Function number + and ecx, 7 ; function is first 3 bits + mcall ; Draw Function Number To Window + + call store_2_digits + + and edx, 0xFFFF ;***************************************** + or edx, 179 * 65536 ; X start becomes 179 + movzx ecx, byte [PCI_Rev] ; get revision number + mcall ; Draw Revision to screen + + call store_2_digits + + and edx, 0xFFFF ;***************************************** + or edx, 215*65536 ; X start becomes 215 + movzx ecx, byte [PCI_Class] ; get PCI_Class + mcall ; Draw Class to screen + + call store_2_digits + + and edx, 0xFFFF ;***************************************** + or edx, 250*65536 ; X start becomes 250 + movzx ecx, byte [PCI_SubClass]; get sub class + mcall ; Draw Sub Class to screen + + call store_2_digits + +; from Mario79 august 2006 + and edx, 0xFFFF ;***************************************** + or edx, 280 * 65536 ; X start becomes 280 + movzx ecx, [PCI_Interface] ; get Interface + mcall + + call store_2_digits + +; +; from Ghost april 2007 ;***************************************** + and edx, 0xFFFF + or edx, 310 * 65536 ; X start becomes 310 + movzx ecx, [PCI_IRQ] ; get Interface + cmp cl, 63 ; IRQ between 0..63 + ja @f + + mcall + + call store_2_digits + jmp .PCI_Vendor +@@: + call store_NA +.PCI_Vendor: + ;Write Names + movzx ebx, dx ; Set y position + or ebx, 340 * 65536 ; set Xposition to 340 + +;------------------------------------------------------------------ +; Prints the Vendor's Name based on Vendor ID +; +; Modified on ??-04-2007 by Ghost for size +;------------------------------------------------------------------ + mov edx, VendorsTab + mov cx, word[PCI_Vendor] + +.fn: + mov ax, [edx] + add edx, 6 + test ax, ax + jz .find + + cmp ax, cx + jne .fn + +.find: + mov edx, [edx - 4] + mcall SF_DRAW_TEXT,, 0x80000000 ; let's print the vendor Name + + mov [store_text_size],42 + call store_text +;------------------------------------------------------------------ +; Get description based on Class/Subclass +; +; Modified on ??-04-2007 by Ghost for size +;------------------------------------------------------------------ + mov eax, dword [PCI_Class] + and eax, 0xffffff + xor edx, edx + xor esi, esi +.fnc: + inc esi + mov ecx, [Classes + esi * 8 - 8] + cmp cx, 0xffff + je .endfc + + cmp cx, ax + jne .fnc + + test ecx, 0xff000000 + jz @f + + mov edx, [Classes + esi * 8 - 4] + jmp .fnc +@@: + cmp eax, ecx + jne .fnc + + xor edx, edx +.endfc: + test edx, edx + jnz @f + + mov edx, [Classes + esi * 8 - 4] +@@: + and ebx, 0x0000FFFF ; clear X position + or ebx, 0x24E0000 ; set X position to 590 pixels + mcall SF_DRAW_TEXT,, 0x80000000,, 32 ; draw the text + + mov [store_text_size],0 + call store_text + call store_CR + + movzx edx, bx ; get y coordinate + add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20 + mov [gr_pos], edx + ret +;------------------------------------------------------------------ +; Get the user-MMIO related info +; +; Added on ??-12-2009 by art_zh +;------------------------------------------------------------------ +Try_MMIO: + xor ebx, ebx + mov edx, ebx + mov bh, [MMIO_BAR] + or bx, 12 ; function 12 + mov ecx, 4096 ; =1 page to map + mcall SF_PCI + + mov [MMIO_Map], eax ; store MMIO lin.addr. + mov ecx, 0x80990022 ; print color : red + add bh, '0' + cmp eax, -3 + jne @f + + mov [bar_um+3], bh + mov ebx, [gr_pos] + mov edx, bar_um + mcall SF_DRAW_TEXT + + jmp mmio_next_bar +@@: + cmp eax, -4 + jne @f + mov [bar_io+3], bh + mov ebx, [gr_pos] + mov edx, bar_io + mcall SF_DRAW_TEXT + + jmp mmio_next_bar +@@: + cmp bh, '6' ; expansion ROM ? + je @f + mov [bar_ram+3], bh + mov ebx, [gr_pos] + mov edx, bar_ram + mcall SF_DRAW_TEXT + + jmp mmio_dump +;----------------------------------------------------------------------------- +@@: + mov ebx, [gr_pos] + mov edx, bar_rom + mcall SF_DRAW_TEXT + +mmio_dump: + mov edx, [MMIO_Map] + mov esi, 64 + mov ecx, 0x099 ; dump color : blue + add ebx, 10 + mov [gr_pos], ebx + mcall SF_DRAW_TEXT + + mov ecx, [MMIO_Map] ; release the tried page + mcall SF_PCI,13 + +mmio_next_bar: + mov bh, [MMIO_BAR] + inc bh + cmp bh,7 + je @f + + mov [MMIO_BAR], bh + add [gr_pos], 10 + jmp Try_MMIO +;----------------------------------------------------------------------------- +@@: + xor bh,bh + mov [MMIO_BAR], bh + ret +;----------------------------------------------------------------------------- +store_CR: + pusha + mov edi,[store_text_area_end] + mov [edi],word 0A20h ; CR (carriage return) + SPACE + add dword [store_text_area_end],2 + popa + ret +;----------------------------------------------------------------------------- +store_text: + pusha + inc dword [store_text_area_end] + mov esi,edx + mov edi,[store_text_area_end] + push edi + xor eax,eax + cld +@@: + lodsb + test eax,eax + jz @f + stosb + inc dword [store_text_area_end] + jmp @r +@@: + pop esi + mov eax,[store_text_size] + test eax,eax + jz @f + sub edi,esi + sub eax,edi + add [store_text_area_end],eax +@@: + popa + ret +;----------------------------------------------------------------------------- +store_NA: + pusha + mov ebx,edx + mcall SF_DRAW_TEXT,,0x80000000,text_NA + mov edi,[store_text_area_end] + mov ax,[edx] + mov [edi+1],ax + add [store_text_area_end],dword 5 + popa + ret +;----------------------------------------------------------------------------- +store_2_digits: + pusha + inc [store_text_area_end] + mov ebx,ecx + mov ecx,2 + mov edi,[store_text_area_end] + call binary_to_hex_string + add [store_text_area_end],dword 4 + popa + ret +;----------------------------------------------------------------------------- +store_4_digits: + pusha + mov ebx,ecx + mov ecx,4 + mov edi,[store_text_area_end] + call binary_to_hex_string + add [store_text_area_end],dword 6 + popa + ret +;----------------------------------------------------------------------------- +; ebx - value +; ecx - digits +; edi - output string +binary_to_hex_string: + add edi,ecx + dec edi + std +.1: + mov al,bl + and al,0xf + shr ebx,4 + cmp al,9 + jbe @f + + add al,0x27 +@@: + add al,0x30 + stosb + dec ecx + jnz .1 + cld + ret +;----------------------------------------------------------------------------- +include 'vendors.inc' +;----------------------------------------------------------------------------- +; DATA AREA +DATA + +Form: dw 800 ; window width (no more, special for 800x600) + dw 100 ; window x start + dw 748 ; window height + dw 20 ; window y start + +title db 'PCI Device Enumerator v 2.3', 0 + +if lang eq it +PCIWin mls \ + ' Don`t forget to enable PCI Access to Applications in Setup Menu.',\ + '',\ + 'Versione PCI = x.xx; Ultimo Bus PCI = ',\ + 'User MMIO channel = 0F.F:F ',\ + 'Numbero di unit├а PCI = ',\ + '',\ + 'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ IRQ Compania Descrizzione',\ + ' Interfaccia',\ + '----- ----- ---- ---- --- --- ----- --------- --- ------------------------------------------ --------------------------------' + +bar_ram db 'BARx: MMIO block', 0 +bar_io db 'BARx: porte IO',0 +bar_um db 'BARx: unmapped',0 +bar_rom db 'BAR6: Expansion ROM', 0 + +text_save_button: + db 'Salva lista PCI',0 +.1: db '(Premere S)',0 +else +PCIWin mls \ + ' Don`t forget to enable PCI Access to Applications in Setup Menu.',\ + '',\ + 'PCI Version = x.xx; Last PCI Bus = ',\ + 'User MMIO channel = 0F.F:F ',\ + 'Number of PCI units = ',\ + '',\ + 'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ IRQ Company Description',\ + ' Interface',\ + '----- ----- ---- ---- --- --- ----- --------- --- ------------------------------------------ --------------------------------' + +bar_ram db 'BARx: MMIO block', 0 +bar_io db 'BARx: IO ports',0 +bar_um db 'BARx: unmapped',0 +bar_rom db 'BAR6: Expansion ROM', 0 + +text_save_button: + db 'Save PCI list',0 +.1: db '(Press S key)',0 +end if + +text_NA: + db '--',0 +;--------------------------------------------------------------------- +system_dir_ProcLib db '/sys/lib/proc_lib.obj',0 + +;--------------------------------------------------------------------- +l_libs_start: + +library02 l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, ProcLib_import + +end_l_libs: +;--------------------------------------------------------------------- +align 4 +ProcLib_import: +OpenDialog_Init dd aOpenDialog_Init +OpenDialog_Start dd aOpenDialog_Start +;OpenDialog__Version dd aOpenDialog_Version + dd 0 + dd 0 +aOpenDialog_Init db 'OpenDialog_init',0 +aOpenDialog_Start db 'OpenDialog_start',0 +;aOpenDialog_Version db 'Version_OpenDialog',0 +;--------------------------------------------------------------------- +align 4 +OpenDialog_data: +.type dd 0 +.procinfo dd Proc_Info ;+4 +.com_area_name dd communication_area_name ;+8 +.com_area dd 0 ;+12 +.opendir_pach dd temp_dir_pach ;+16 +.dir_default_pach dd communication_area_default_pach ;+20 +.start_path dd open_dialog_path ;+24 +.draw_window dd draw_window ;+28 +.status dd 0 ;+32 +.openfile_pach dd file_name ;+36 +.filename_area dd filename_area ;+40 +.filter_area dd Filter +.x: +.x_size dw 420 ;+48 ; Window X size +.x_start dw 10 ;+50 ; Window X position +.y: +.y_size dw 320 ;+52 ; Window y size +.y_start dw 10 ;+54 ; Window Y position + +communication_area_name: + db 'FFFFFFFF_open_dialog',0 +open_dialog_path: + db '/sys/File Managers/opendial',0 +communication_area_default_pach: + db '/sys',0 +Filter: +dd Filter.end - Filter.1 +.1: +db 'TXT',0 +db 'LOG',0 +.end: +dd 0 + +file_default_path: + db '/sys/' +start_temp_file_name: + db 'pcidev.txt',0 +;--------------------------------------------------------------------- +align 4 +fileinfo: +.subfunction dd 2 +.Offset dd 0 +.Offset_1 dd 0 +.size dd 4096 +.return dd 0 + db 0 +.name: dd file_name +;----------------------------------------------------------------------------- + +; UNINITIALIZED DATA AREA +IM_END: +total db ? +V_Bus db ? +V_Dev db ? +PCI_Version dw ? +PCI_LastBus db ? +PCI_Device dw ? +PCI_Vendor dw ? +PCI_Bus db ? +PCI_Dev db ? +PCI_Rev db ? +; don`t change order!!! +PCI_Class db ? +PCI_SubClass db ? +PCI_Interface db ? +PCI_IRQ db ? + +align 4 +MMIO_Bus db 255 +MMIO_Dev db 255 +MMIO_BAR db 0 +MMIO_allowed db 1 +MMIO_Map rd 8 + +gr_pos dd ? + +store_text_area_start dd ? +store_text_area_end dd ? +store_text_size dd ? + +extended_key rb 1 +;--------------------------------------------------------------------- +library_path: + rb 4096 +;--------------------------------------------------------------------- +path: + rb 4096 +;--------------------------------------------------------------------- +temp_dir_pach: + rb 4096 +;--------------------------------------------------------------------- +file_name: + rb 4096 +;--------------------------------------------------------------------- +file_name_1: + rb 4096 +;--------------------------------------------------------------------- +filename_area: + rb 256 +;--------------------------------------------------------------------- + rb 4096 +stacktop: +;--------------------------------------------------------------------- +Proc_Info process_information +;--------------------------------------------------------------------- +I_END: +;-----------------------------------------------------------------------------