Fix EN typos
- Corrections for en_US language. - Some whitespace sanitation. git-svn-id: svn://kolibrios.org@10064 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
bb2607b7d8
commit
a53bea545e
@ -34,8 +34,8 @@ INFTY equ 1000000000
|
|||||||
moveorder dd 1,7,2,6,3,5,4
|
moveorder dd 1,7,2,6,3,5,4
|
||||||
|
|
||||||
; table used for static evaluation.
|
; table used for static evaluation.
|
||||||
; this table is taken from 4st attack: it is ways better
|
; this table is taken from 4st attack: it is much better
|
||||||
; than the table i used before =)
|
; than the table I used before =)
|
||||||
evaltable: dd 0, 0, 0, 0, 0, 0, 0, 0, 0
|
evaltable: dd 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
dd 0, 3, 4, 5, 7, 5, 4, 3, 0
|
dd 0, 3, 4, 5, 7, 5, 4, 3, 0
|
||||||
dd 0, 4, 6, 8,10, 8, 6, 4, 0
|
dd 0, 4, 6, 8,10, 8, 6, 4, 0
|
||||||
@ -74,14 +74,14 @@ aiGetMove:
|
|||||||
mov [cpulevel],eax
|
mov [cpulevel],eax
|
||||||
mov dword [bestval],-INFTY
|
mov dword [bestval],-INFTY
|
||||||
mov dword [nbestmoves],0
|
mov dword [nbestmoves],0
|
||||||
|
|
||||||
; try every move
|
; try every move
|
||||||
mov ecx,6
|
mov ecx,6
|
||||||
.evalmoves:
|
.evalmoves:
|
||||||
|
|
||||||
; get move to make from move order table
|
; get move to make from move order table
|
||||||
mov eax,[moveorder+ecx*4]
|
mov eax,[moveorder+ecx*4]
|
||||||
|
|
||||||
; if this is an invalid move, continue with next move
|
; if this is an invalid move, continue with next move
|
||||||
BOARDISVALIDMOVE eax
|
BOARDISVALIDMOVE eax
|
||||||
jz .nextmove
|
jz .nextmove
|
||||||
@ -89,7 +89,7 @@ aiGetMove:
|
|||||||
; make move for current player
|
; make move for current player
|
||||||
mov ebx,[currentplayer]
|
mov ebx,[currentplayer]
|
||||||
call boardMakeMove
|
call boardMakeMove
|
||||||
|
|
||||||
; evaluate move
|
; evaluate move
|
||||||
push eax ; save move #
|
push eax ; save move #
|
||||||
push ecx ; save loop counter
|
push ecx ; save loop counter
|
||||||
@ -100,14 +100,14 @@ aiGetMove:
|
|||||||
push dword -INFTY ; alpha
|
push dword -INFTY ; alpha
|
||||||
push dword INFTY ; beta
|
push dword INFTY ; beta
|
||||||
call alphabeta
|
call alphabeta
|
||||||
neg eax ; damn, how could i forget this ???
|
neg eax ; How could I forget this ???
|
||||||
mov ebx,eax ; save result for later
|
mov ebx,eax ; save result for later
|
||||||
pop ecx ; restore loop counter
|
pop ecx ; restore loop counter
|
||||||
pop eax ; restore move #
|
pop eax ; restore move #
|
||||||
|
|
||||||
; undo move (eax = move #)
|
; undo move (eax = move #)
|
||||||
call boardUndoMove
|
call boardUndoMove
|
||||||
|
|
||||||
; let's see wether we have a new best move
|
; let's see wether we have a new best move
|
||||||
cmp ebx,[bestval] ; new best value found ?
|
cmp ebx,[bestval] ; new best value found ?
|
||||||
jle .nonewbestval
|
jle .nonewbestval
|
||||||
@ -127,7 +127,7 @@ aiGetMove:
|
|||||||
js .done
|
js .done
|
||||||
jmp .evalmoves
|
jmp .evalmoves
|
||||||
.done:
|
.done:
|
||||||
|
|
||||||
; randomly pick one of the best moves
|
; randomly pick one of the best moves
|
||||||
call rand ; rand() % nbestmoves
|
call rand ; rand() % nbestmoves
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
@ -156,7 +156,7 @@ alphabeta:
|
|||||||
%define beta (ebp+ 8)
|
%define beta (ebp+ 8)
|
||||||
|
|
||||||
enter 0,0
|
enter 0,0
|
||||||
|
|
||||||
; win for other player -> end search
|
; win for other player -> end search
|
||||||
mov eax,[player]
|
mov eax,[player]
|
||||||
BOARDGETOTHERPLAYER eax
|
BOARDGETOTHERPLAYER eax
|
||||||
@ -180,7 +180,7 @@ alphabeta:
|
|||||||
; max search depth reached -> do static evaluation
|
; max search depth reached -> do static evaluation
|
||||||
cmp dword [ply],0
|
cmp dword [ply],0
|
||||||
je .staticeval
|
je .staticeval
|
||||||
|
|
||||||
|
|
||||||
; for each move
|
; for each move
|
||||||
mov ecx,6
|
mov ecx,6
|
||||||
@ -193,15 +193,15 @@ alphabeta:
|
|||||||
|
|
||||||
; pick move from move order table
|
; pick move from move order table
|
||||||
mov eax,[moveorder+ecx*4]
|
mov eax,[moveorder+ecx*4]
|
||||||
|
|
||||||
; invalid move ? if so, continue with next move
|
; invalid move ? if so, continue with next move
|
||||||
BOARDISVALIDMOVE eax
|
BOARDISVALIDMOVE eax
|
||||||
jz .nextmove
|
jz .nextmove
|
||||||
|
|
||||||
; make move for current player
|
; make move for current player
|
||||||
mov ebx,[player]
|
mov ebx,[player]
|
||||||
call boardMakeMove
|
call boardMakeMove
|
||||||
|
|
||||||
; evaluate move
|
; evaluate move
|
||||||
push eax
|
push eax
|
||||||
push ecx
|
push ecx
|
||||||
@ -219,27 +219,27 @@ alphabeta:
|
|||||||
push edx
|
push edx
|
||||||
call alphabeta
|
call alphabeta
|
||||||
neg eax
|
neg eax
|
||||||
|
|
||||||
; new alpha ?
|
; new alpha ?
|
||||||
cmp eax,[alpha]
|
cmp eax,[alpha]
|
||||||
jle .nonewalpha
|
jle .nonewalpha
|
||||||
mov [alpha],eax ; yes -> save it
|
mov [alpha],eax ; yes -> save it
|
||||||
.nonewalpha:
|
.nonewalpha:
|
||||||
pop ecx
|
pop ecx
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
; undo move
|
; undo move
|
||||||
call boardUndoMove
|
call boardUndoMove
|
||||||
|
|
||||||
.nextmove: ; evaluate next move
|
.nextmove: ; evaluate next move
|
||||||
dec ecx
|
dec ecx
|
||||||
jns .evalmoves
|
jns .evalmoves
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
mov eax,[alpha]
|
mov eax,[alpha]
|
||||||
leave
|
leave
|
||||||
ret 4*4
|
ret 4*4
|
||||||
|
|
||||||
; static evaluation
|
; static evaluation
|
||||||
.staticeval:
|
.staticeval:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
@ -255,7 +255,7 @@ alphabeta:
|
|||||||
je .empty ; nope -> go on
|
je .empty ; nope -> go on
|
||||||
sub eax,[evaltable+esi*4] ; yes -> sub stone value from eax
|
sub eax,[evaltable+esi*4] ; yes -> sub stone value from eax
|
||||||
.empty:
|
.empty:
|
||||||
|
|
||||||
.next: ; next stone
|
.next: ; next stone
|
||||||
dec esi
|
dec esi
|
||||||
jns .l
|
jns .l
|
||||||
@ -267,4 +267,4 @@ alphabeta:
|
|||||||
%undef alpha
|
%undef alpha
|
||||||
%undef beta
|
%undef beta
|
||||||
|
|
||||||
%endif
|
%endif
|
||||||
|
@ -1,251 +1,251 @@
|
|||||||
; level format
|
; level format
|
||||||
; [fx|fy]..[field cells x2]..[worm_count]..[worm_len][start cell #][body dirs x2]
|
; [fx|fy]..[field cells x2]..[worm_count]..[worm_len][start cell #][body dirs x2]
|
||||||
|
|
||||||
; internal format
|
; internal format
|
||||||
; [stepptr]= worms #
|
; [stepptr]= worms #
|
||||||
; area: [worm_len][start_cell #][end_cell #]..[dirs]..
|
; area: [worm_len][start_cell #][end_cell #]..[dirs]..
|
||||||
; [cur_step]: dragged worm pointer
|
; [cur_step]: dragged worm pointer
|
||||||
; [finish]: 0 - if head dragged, 1- if tail
|
; [finish]: 0 - if head dragged, 1- if tail
|
||||||
WG_levelp:
|
WG_levelp:
|
||||||
mcall 40,100111b
|
mcall 40,100111b
|
||||||
inc [drag_flag]
|
inc [drag_flag]
|
||||||
call get_xy_sf
|
call get_xy_sf
|
||||||
sub esi,2
|
sub esi,2
|
||||||
call LP_levelp.bit2
|
call LP_levelp.bit2
|
||||||
cmp edx,4
|
cmp edx,4
|
||||||
jne .ok
|
jne .ok
|
||||||
dec esi
|
dec esi
|
||||||
.ok:
|
.ok:
|
||||||
movzx ecx,byte[esi]
|
movzx ecx,byte[esi]
|
||||||
mov [stepptr],ecx
|
mov [stepptr],ecx
|
||||||
inc esi
|
inc esi
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov edi,area
|
mov edi,area
|
||||||
.lp1:
|
.lp1:
|
||||||
push ecx
|
push ecx
|
||||||
movzx ecx,byte[esi]
|
movzx ecx,byte[esi]
|
||||||
inc esi
|
inc esi
|
||||||
mov [edi],cl
|
mov [edi],cl
|
||||||
inc edi
|
inc edi
|
||||||
lodsb
|
lodsb
|
||||||
dec ecx
|
dec ecx
|
||||||
movzx ebx,al
|
movzx ebx,al
|
||||||
stosb
|
stosb
|
||||||
push edi
|
push edi
|
||||||
inc edi
|
inc edi
|
||||||
mov edx,8/2
|
mov edx,8/2
|
||||||
lodsb
|
lodsb
|
||||||
.lp:
|
.lp:
|
||||||
rol al,2
|
rol al,2
|
||||||
push ecx
|
push ecx
|
||||||
mov cl,al
|
mov cl,al
|
||||||
and ecx,11b
|
and ecx,11b
|
||||||
add ebx,[dirs+ecx*4]
|
add ebx,[dirs+ecx*4]
|
||||||
mov [edi],cl
|
mov [edi],cl
|
||||||
pop ecx
|
pop ecx
|
||||||
inc edi
|
inc edi
|
||||||
dec edx
|
dec edx
|
||||||
test edx,edx
|
test edx,edx
|
||||||
jnz .nxt
|
jnz .nxt
|
||||||
mov edx,8/2
|
mov edx,8/2
|
||||||
lodsb
|
lodsb
|
||||||
.nxt:
|
.nxt:
|
||||||
loop .lp
|
loop .lp
|
||||||
cmp edx,4
|
cmp edx,4
|
||||||
jne .ok2
|
jne .ok2
|
||||||
dec esi
|
dec esi
|
||||||
.ok2:
|
.ok2:
|
||||||
pop ecx
|
pop ecx
|
||||||
mov [ecx],bl
|
mov [ecx],bl
|
||||||
pop ecx
|
pop ecx
|
||||||
loop .lp1
|
loop .lp1
|
||||||
mov esi,[stepptr]
|
mov esi,[stepptr]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
WG_key:
|
WG_key:
|
||||||
cmp eax,0
|
cmp eax,0
|
||||||
jl WG_mouse
|
jl WG_mouse
|
||||||
ret
|
ret
|
||||||
|
|
||||||
WG_drawm:
|
WG_drawm:
|
||||||
mov [win_flag],1
|
mov [win_flag],1
|
||||||
mov ecx,[cell_count]
|
mov ecx,[cell_count]
|
||||||
; mov [sq_size],3
|
; mov [sq_size],3
|
||||||
.lp:
|
.lp:
|
||||||
push ecx
|
push ecx
|
||||||
movzx ebx,byte[field+ecx-1]
|
movzx ebx,byte[field+ecx-1]
|
||||||
and byte[field+ecx-1],11000000b
|
and byte[field+ecx-1],11000000b
|
||||||
shr ebx,6
|
shr ebx,6
|
||||||
test ebx,ebx
|
test ebx,ebx
|
||||||
jz .no
|
jz .no
|
||||||
dec ebx
|
dec ebx
|
||||||
lea eax,[ecx-1]
|
lea eax,[ecx-1]
|
||||||
call get_xy
|
call get_xy
|
||||||
add [lx],5-2 shl 16
|
add [lx],5-2 shl 16
|
||||||
add [ly],5-2 shl 16
|
add [ly],5-2 shl 16
|
||||||
mov edx,[f_colors+ebx*4]
|
mov edx,[f_colors+ebx*4]
|
||||||
mcall 13,[lx],[ly]
|
mcall 13,[lx],[ly]
|
||||||
.no:
|
.no:
|
||||||
pop ecx
|
pop ecx
|
||||||
loop .lp
|
loop .lp
|
||||||
|
|
||||||
add [sq_size],3
|
add [sq_size],3
|
||||||
|
|
||||||
mov ecx,[stepptr]
|
mov ecx,[stepptr]
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov esi,area
|
mov esi,area
|
||||||
push ebp
|
push ebp
|
||||||
mov edi,w_colors
|
mov edi,w_colors
|
||||||
mov dword[player],1
|
mov dword[player],1
|
||||||
.lp2:
|
.lp2:
|
||||||
push ecx
|
push ecx
|
||||||
movzx ecx,byte[esi]
|
movzx ecx,byte[esi]
|
||||||
inc esi
|
inc esi
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
lodsb
|
lodsb
|
||||||
mov ebp,esi
|
mov ebp,esi
|
||||||
.lp1:
|
.lp1:
|
||||||
inc esi
|
inc esi
|
||||||
push ecx eax
|
push ecx eax
|
||||||
call get_xy
|
call get_xy
|
||||||
mcall 13,[lx],[ly],[edi]
|
mcall 13,[lx],[ly],[edi]
|
||||||
pop eax
|
pop eax
|
||||||
mov ecx,[player]
|
mov ecx,[player]
|
||||||
mov bl,[field+eax]
|
mov bl,[field+eax]
|
||||||
shr bl,6
|
shr bl,6
|
||||||
add [field+eax],cl
|
add [field+eax],cl
|
||||||
cmp bl,cl
|
cmp bl,cl
|
||||||
je .match
|
je .match
|
||||||
and [win_flag],0
|
and [win_flag],0
|
||||||
.match:
|
.match:
|
||||||
pop ecx
|
pop ecx
|
||||||
push esi edi
|
push esi edi
|
||||||
movzx ebx,byte[esi]
|
movzx ebx,byte[esi]
|
||||||
mov esi,eax
|
mov esi,eax
|
||||||
mov [ebp],al
|
mov [ebp],al
|
||||||
add eax,[dirs+ebx*4]
|
add eax,[dirs+ebx*4]
|
||||||
|
|
||||||
cmp ecx,1
|
cmp ecx,1
|
||||||
je .skip
|
je .skip
|
||||||
mov edi,eax
|
mov edi,eax
|
||||||
call getline
|
call getline
|
||||||
call bold_line
|
call bold_line
|
||||||
.skip:
|
.skip:
|
||||||
pop edi esi
|
pop edi esi
|
||||||
loop .lp1
|
loop .lp1
|
||||||
pop ecx
|
pop ecx
|
||||||
add edi,4
|
add edi,4
|
||||||
inc dword[player]
|
inc dword[player]
|
||||||
loop .lp2
|
loop .lp2
|
||||||
pop ebp
|
pop ebp
|
||||||
sub [sq_size],3
|
sub [sq_size],3
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
WG_mouse:
|
WG_mouse:
|
||||||
cmp [win_flag],1
|
cmp [win_flag],1
|
||||||
je .ex
|
je .ex
|
||||||
mov [jump],still
|
mov [jump],still
|
||||||
mov edx,eax
|
mov edx,eax
|
||||||
call get_last_mclick
|
call get_last_mclick
|
||||||
cmp edx,-2
|
cmp edx,-2
|
||||||
jne .no1st
|
jne .no1st
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jz .ex
|
jz .ex
|
||||||
.noempty:
|
.noempty:
|
||||||
|
|
||||||
; First Click at ebx cell
|
; First Click at ebx cell
|
||||||
; dpd ebx
|
; dpd ebx
|
||||||
mov [cur_step],0
|
mov [cur_step],0
|
||||||
mov dword[finish],0
|
mov dword[finish],0
|
||||||
mov esi,area
|
mov esi,area
|
||||||
mov ecx,[stepptr]
|
mov ecx,[stepptr]
|
||||||
.fndlp:
|
.fndlp:
|
||||||
movzx edx,byte[esi]
|
movzx edx,byte[esi]
|
||||||
cmp bl,[esi+1]
|
cmp bl,[esi+1]
|
||||||
je .fnd
|
je .fnd
|
||||||
cmp bl,[esi+2]
|
cmp bl,[esi+2]
|
||||||
jne .nxt
|
jne .nxt
|
||||||
inc dword[finish]
|
inc dword[finish]
|
||||||
.fnd:
|
.fnd:
|
||||||
mov [cur_step],esi
|
mov [cur_step],esi
|
||||||
mov [jump],drw;red
|
mov [jump],drw;red
|
||||||
jmp .ex
|
jmp .ex
|
||||||
.nxt:
|
.nxt:
|
||||||
lea esi,[esi+edx+2]
|
lea esi,[esi+edx+2]
|
||||||
loop .fndlp
|
loop .fndlp
|
||||||
jmp .ex
|
jmp .ex
|
||||||
|
|
||||||
.no1st:
|
.no1st:
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jz .ex
|
jz .ex
|
||||||
; While dragging
|
; While dragging
|
||||||
mov esi,[cur_step]
|
mov esi,[cur_step]
|
||||||
test esi,esi
|
test esi,esi
|
||||||
jz .ex
|
jz .ex
|
||||||
lea edi,[esi+1]
|
lea edi,[esi+1]
|
||||||
add edi,[finish]
|
add edi,[finish]
|
||||||
movzx eax,byte[edi]
|
movzx eax,byte[edi]
|
||||||
cmp eax,ebx
|
cmp eax,ebx
|
||||||
je .ex
|
je .ex
|
||||||
push ebx
|
push ebx
|
||||||
cmp dword[finish],0
|
cmp dword[finish],0
|
||||||
jne .noswap
|
jne .noswap
|
||||||
xchg eax,ebx
|
xchg eax,ebx
|
||||||
.noswap:
|
.noswap:
|
||||||
call get_offset
|
call get_offset
|
||||||
cmp ebx,1
|
cmp ebx,1
|
||||||
pop ebx
|
pop ebx
|
||||||
jne .ex
|
jne .ex
|
||||||
cmp eax,-1
|
cmp eax,-1
|
||||||
je .ex
|
je .ex
|
||||||
test byte[field+ebx],11b
|
test byte[field+ebx],11b
|
||||||
jnz .ex
|
jnz .ex
|
||||||
movzx ecx,byte[esi]
|
movzx ecx,byte[esi]
|
||||||
cmp dword[finish],0
|
cmp dword[finish],0
|
||||||
jne .tail
|
jne .tail
|
||||||
mov [esi+1],bl
|
mov [esi+1],bl
|
||||||
mov [esi+2],al
|
mov [esi+2],al
|
||||||
add esi,ecx
|
add esi,ecx
|
||||||
std
|
std
|
||||||
lea edi,[esi+1]
|
lea edi,[esi+1]
|
||||||
rep movsb
|
rep movsb
|
||||||
jmp .redex
|
jmp .redex
|
||||||
|
|
||||||
.tail:
|
.tail:
|
||||||
mov [esi+2],bl
|
mov [esi+2],bl
|
||||||
movzx ebx,byte[esi+3]
|
movzx ebx,byte[esi+3]
|
||||||
movzx edx,byte[esi+1]
|
movzx edx,byte[esi+1]
|
||||||
add edx,[dirs+ebx*4]
|
add edx,[dirs+ebx*4]
|
||||||
mov [esi+1],dl
|
mov [esi+1],dl
|
||||||
add esi,3
|
add esi,3
|
||||||
lea edi,[esi-1]
|
lea edi,[esi-1]
|
||||||
rep movsb
|
rep movsb
|
||||||
mov [edi-1],al
|
mov [edi-1],al
|
||||||
; ud2
|
; ud2
|
||||||
.redex:
|
.redex:
|
||||||
cld
|
cld
|
||||||
mov [jump],drw;red
|
mov [jump],drw;red
|
||||||
mov esi,area
|
mov esi,area
|
||||||
.ex:
|
.ex:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
WG_level:
|
WG_level:
|
||||||
file 'wriggle.bin'
|
file 'wriggle.bin'
|
||||||
|
|
||||||
if lang eq ru
|
if lang eq ru
|
||||||
WG_help mstr \
|
WG_help mstr \
|
||||||
'‚ è § ¤ ç - âïãâì ç¥à¢ïª®¢ § £®«®¢ã ¨«¨',\
|
'‚ è § ¤ ç - âïãâì ç¥à¢ïª®¢ § £®«®¢ã ¨«¨',\
|
||||||
'墮áâ, ¯®ª ª ¦¤ë© ¨§ ¨å ¥ ¯®ªà®¥â ª«¥âª¨',\
|
'墮áâ, ¯®ª ª ¦¤ë© ¨§ ¨å ¥ ¯®ªà®¥â ª«¥âª¨',\
|
||||||
'᢮¥£® 梥â , ®áâ ¢¨¢ ¥§ ªàëâ묨 ¡¥«ë¥ ª¢ ¤à âë.',\
|
'᢮¥£® 梥â , ®áâ ¢¨¢ ¥§ ªàëâ묨 ¡¥«ë¥ ª¢ ¤à âë.',\
|
||||||
'—¥à¢ïª¨ ¥ ¬®£ãâ ¯¥à¥ªàë¢ âì ¨ ¯¥à¥á¥ª âì ¤àã£',\
|
'—¥à¢ïª¨ ¥ ¬®£ãâ ¯¥à¥ªàë¢ âì ¨ ¯¥à¥á¥ª âì ¤àã£',\
|
||||||
'¤à㣠.','',\
|
'¤à㣠.','',\
|
||||||
'http://www.clickmazes.com'
|
'http://www.clickmazes.com'
|
||||||
else
|
else
|
||||||
WG_help mstr \
|
WG_help mstr \
|
||||||
'Your aim is to drag the wriggley worms by head or',\
|
'Your aim is to drag the wriggley worms by head or',\
|
||||||
'tail until each worm covers the squares of its',\
|
'tail until each worm covers the squares of its',\
|
||||||
'own colour leaving only white squares exposed.',\
|
'own color leaving only white squares exposed.',\
|
||||||
'Worms cannot cross or overlap.','',\
|
'Worms cannot cross or overlap.','',\
|
||||||
'http://www.clickmazes.com'
|
'http://www.clickmazes.com'
|
||||||
end if
|
end if
|
||||||
|
@ -23,7 +23,7 @@ struct List{
|
|||||||
List_Node *foundation_head;//points first foundation list
|
List_Node *foundation_head;//points first foundation list
|
||||||
List_Node *board_head;//points first board list
|
List_Node *board_head;//points first board list
|
||||||
FILE *fptr;
|
FILE *fptr;
|
||||||
|
|
||||||
void create();// Includes create toplist, boardlists and foundlists
|
void create();// Includes create toplist, boardlists and foundlists
|
||||||
void create_toplist();
|
void create_toplist();
|
||||||
void create_boardlists();
|
void create_boardlists();
|
||||||
@ -97,7 +97,7 @@ int main()
|
|||||||
|
|
||||||
if(!islem.top_head)// checking top list empty or not
|
if(!islem.top_head)// checking top list empty or not
|
||||||
islem.istopempty = true;
|
islem.istopempty = true;
|
||||||
|
|
||||||
List_Node *traverse;
|
List_Node *traverse;
|
||||||
traverse = islem.board_head;
|
traverse = islem.board_head;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
@ -121,7 +121,7 @@ int main()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,21 +156,21 @@ void List::create_toplist(){
|
|||||||
|
|
||||||
fscanf(fptr, " %c %s %s ", &tempsuit, tempvalue, tempisup);
|
fscanf(fptr, " %c %s %s ", &tempsuit, tempvalue, tempisup);
|
||||||
newnode->suit = tempsuit;
|
newnode->suit = tempsuit;
|
||||||
|
|
||||||
/*Changing type of value char array to integer*/
|
/*Changing type of value char array to integer*/
|
||||||
if(tempvalue[0] == 'A') newnode->value = 1;
|
if(tempvalue[0] == 'A') newnode->value = 1;
|
||||||
else if(tempvalue[0] == 'J')newnode->value = 11;
|
else if(tempvalue[0] == 'J')newnode->value = 11;
|
||||||
else if(tempvalue[0] == 'Q')newnode->value = 12;
|
else if(tempvalue[0] == 'Q')newnode->value = 12;
|
||||||
else if(tempvalue[0] == 'K')newnode->value = 13;
|
else if(tempvalue[0] == 'K')newnode->value = 13;
|
||||||
else
|
else
|
||||||
sscanf(tempvalue, "%d", &newnode->value);
|
sscanf(tempvalue, "%d", &newnode->value);
|
||||||
|
|
||||||
/*Changing type of isup char array to boolean*/
|
/*Changing type of isup char array to boolean*/
|
||||||
if(strcmp(tempisup, "Up") == 0)
|
if(strcmp(tempisup, "Up") == 0)
|
||||||
newnode->isup = true;
|
newnode->isup = true;
|
||||||
if(strcmp(tempisup, "Down") == 0)
|
if(strcmp(tempisup, "Down") == 0)
|
||||||
newnode->isup = false;
|
newnode->isup = false;
|
||||||
|
|
||||||
if(top_head == NULL){//add first node to empty top list
|
if(top_head == NULL){//add first node to empty top list
|
||||||
top_head = newnode;
|
top_head = newnode;
|
||||||
final = top_head;
|
final = top_head;
|
||||||
@ -188,7 +188,7 @@ void List::create_boardlists(){
|
|||||||
char tempcolor, tempsuit, tempvalue[4], tempisup[8], garbage[10];
|
char tempcolor, tempsuit, tempvalue[4], tempisup[8], garbage[10];
|
||||||
|
|
||||||
int index = 1;// This index represents nth board list
|
int index = 1;// This index represents nth board list
|
||||||
|
|
||||||
newboardlist = new List_Node;// creating first boardlist node
|
newboardlist = new List_Node;// creating first boardlist node
|
||||||
board_head = newboardlist;
|
board_head = newboardlist;
|
||||||
boardlist_final = newboardlist;
|
boardlist_final = newboardlist;
|
||||||
@ -219,7 +219,7 @@ void List::create_boardlists(){
|
|||||||
else if(tempvalue[0] == 'J')newnode->value = 11;
|
else if(tempvalue[0] == 'J')newnode->value = 11;
|
||||||
else if(tempvalue[0] == 'Q')newnode->value = 12;
|
else if(tempvalue[0] == 'Q')newnode->value = 12;
|
||||||
else if(tempvalue[0] == 'K')newnode->value = 13;
|
else if(tempvalue[0] == 'K')newnode->value = 13;
|
||||||
else
|
else
|
||||||
sscanf(tempvalue, "%d", &newnode->value);
|
sscanf(tempvalue, "%d", &newnode->value);
|
||||||
|
|
||||||
if(strcmp(tempisup, "Up") == 0)
|
if(strcmp(tempisup, "Up") == 0)
|
||||||
@ -281,7 +281,7 @@ void List::printkart(Card_Node *kart){//prints datas of kart node
|
|||||||
void List::printlists(){
|
void List::printlists(){
|
||||||
clear_screen();
|
clear_screen();
|
||||||
Card_Node *ct[7];// Board List Card Node Traverser; ct[0] for 1.list, ct[1] for 2.list ....
|
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
|
Card_Node *topct;// TopList Card Traverser
|
||||||
List_Node *listtraverse;// List Node Traverser
|
List_Node *listtraverse;// List Node Traverser
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ void List::printlists(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Printing Board List's Cards*/
|
/*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++)
|
for(int j = 0; j < 7; j++)
|
||||||
{
|
{
|
||||||
if(ct[j]){// if ct[j] is not null, print it and go to next node
|
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
|
else// if ct[j] is null, print a tab
|
||||||
printf("\t");
|
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
|
printf("\n");//if at least one card is not null: go new line
|
||||||
else
|
else
|
||||||
break;// if all cards in line are null: break outer for loop
|
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
|
else// if foundct[j] is null, print a tab
|
||||||
printf("\t");
|
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
|
printf("\n");//if at least one card is not null: go new line
|
||||||
else
|
else
|
||||||
break;// if all cards in line are null: break outer for loop
|
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] == 'J')Symbol_of_numbers = 11;
|
||||||
else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12;
|
else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12;
|
||||||
else if(tempvalue[0] == 'K')Symbol_of_numbers = 13;
|
else if(tempvalue[0] == 'K')Symbol_of_numbers = 13;
|
||||||
else
|
else
|
||||||
sscanf(tempvalue, "%d", &Symbol_of_numbers);
|
sscanf(tempvalue, "%d", &Symbol_of_numbers);
|
||||||
|
|
||||||
TopToFoundation(Symbol_of_colors, Symbol_of_suits, 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;
|
cout << "Top list is empty, you cannot make this move." << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cardtraverse = top_head;
|
cardtraverse = top_head;
|
||||||
cardtail = 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] == 'J')Symbol_of_numbers = 11;
|
||||||
else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12;
|
else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12;
|
||||||
else if(tempvalue[0] == 'K')Symbol_of_numbers = 13;
|
else if(tempvalue[0] == 'K')Symbol_of_numbers = 13;
|
||||||
else
|
else
|
||||||
sscanf(tempvalue, "%d", &Symbol_of_numbers);
|
sscanf(tempvalue, "%d", &Symbol_of_numbers);
|
||||||
|
|
||||||
cout << "Select the number of the destination Board List:";
|
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;
|
cout << "Top list is empty, you cannot make this move." << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cardtraverse = top_head;
|
cardtraverse = top_head;
|
||||||
cardtail = 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] == 'J')Symbol_of_numbers = 11;
|
||||||
else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12;
|
else if(tempvalue[0] == 'Q')Symbol_of_numbers = 12;
|
||||||
else if(tempvalue[0] == 'K')Symbol_of_numbers = 13;
|
else if(tempvalue[0] == 'K')Symbol_of_numbers = 13;
|
||||||
else
|
else
|
||||||
sscanf(tempvalue, "%d", &Symbol_of_numbers);
|
sscanf(tempvalue, "%d", &Symbol_of_numbers);
|
||||||
BoardToBoard(source, destination, Symbol_of_colors, Symbol_of_suits, 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;
|
temp_head = sourcelisttraverse->cards;
|
||||||
cardtraverse = temp_head;
|
cardtraverse = temp_head;
|
||||||
cardtail = temp_head;
|
cardtail = temp_head;
|
||||||
|
|
||||||
|
|
||||||
while(cardtraverse){
|
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){
|
if(cardtraverse->color == s_color && cardtraverse->suit == s_suit && cardtraverse->value == s_value){
|
||||||
willbemoved = cardtraverse;
|
willbemoved = cardtraverse;
|
||||||
break;
|
break;
|
||||||
@ -651,7 +651,7 @@ void List::BoardToBoard(int fromwhere, int towhere, char s_color, char s_suit, i
|
|||||||
cardtail->next = willbemoved;
|
cardtail->next = willbemoved;
|
||||||
cout << "Wrong Movement!" << endl;
|
cout << "Wrong Movement!" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void List::goster_BoardToFoundation(){
|
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;
|
foundation_head = foundation_head->next;
|
||||||
delete listtraverse;
|
delete listtraverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fptr);//Closing reading txt file
|
fclose(fptr);//Closing reading txt file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
;; Calculator for MenuetOS (c) Ville Turjanmaa
|
;; Calculator for MenuetOS (c) Ville Turjanmaa
|
||||||
;;
|
;;
|
||||||
;; Compile with FASM
|
;; Compile with FASM
|
||||||
;;
|
;;
|
||||||
;; Pavel Rymovski (Heavyiron) - version for KolibriOS
|
;; Pavel Rymovski (Heavyiron) - version for KolibriOS
|
||||||
;;
|
;;
|
||||||
;; What's new:
|
;; What's new:
|
||||||
@ -12,7 +12,7 @@
|
|||||||
;; Calc 1.2
|
;; Calc 1.2
|
||||||
;; 1) added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
|
;; 1) added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
|
||||||
;; Calc 1.31
|
;; Calc 1.31
|
||||||
;; 1) optimised program
|
;; 1) optimized program
|
||||||
;; 2) new type of window (you need kernel 114 revision or higher)
|
;; 2) new type of window (you need kernel 114 revision or higher)
|
||||||
;; Calc 1.32
|
;; Calc 1.32
|
||||||
;; 1) fixed arccos
|
;; 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:
|
START:
|
||||||
red:
|
red:
|
||||||
call draw_window
|
call draw_window
|
||||||
still:
|
still:
|
||||||
mcall 10
|
mcall 10
|
||||||
|
|
||||||
dec eax
|
dec eax
|
||||||
jz red
|
jz red
|
||||||
dec eax
|
dec eax
|
||||||
jz key
|
jz key
|
||||||
|
|
||||||
button:
|
button:
|
||||||
mcall 17 ; get button id
|
mcall 17 ; get button id
|
||||||
@ -76,7 +76,7 @@ testbut:
|
|||||||
cmp eax, 1 ; button 1 -- exit
|
cmp eax, 1 ; button 1 -- exit
|
||||||
jne noexit
|
jne noexit
|
||||||
mcall -1
|
mcall -1
|
||||||
|
|
||||||
noexit:
|
noexit:
|
||||||
cmp eax, 2
|
cmp eax, 2
|
||||||
jne no_reset
|
jne no_reset
|
||||||
@ -206,7 +206,7 @@ no_int:
|
|||||||
fdiv [trans1]
|
fdiv [trans1]
|
||||||
jmp show_result
|
jmp show_result
|
||||||
|
|
||||||
no_1x:
|
no_1x:
|
||||||
cmp eax, 24
|
cmp eax, 24
|
||||||
jne no_cos
|
jne no_cos
|
||||||
fld [trans1]
|
fld [trans1]
|
||||||
@ -226,14 +226,14 @@ no_cos:
|
|||||||
fpatan
|
fpatan
|
||||||
jmp show_result
|
jmp show_result
|
||||||
|
|
||||||
no_acos:
|
no_acos:
|
||||||
cmp eax, 30
|
cmp eax, 30
|
||||||
jne no_x2
|
jne no_x2
|
||||||
fld [trans1]
|
fld [trans1]
|
||||||
fmul st, st0
|
fmul st, st0
|
||||||
jmp show_result
|
jmp show_result
|
||||||
|
|
||||||
no_x2:
|
no_x2:
|
||||||
cmp eax, 31
|
cmp eax, 31
|
||||||
jne no_tan
|
jne no_tan
|
||||||
fld [trans1]
|
fld [trans1]
|
||||||
@ -279,7 +279,7 @@ no_add:
|
|||||||
mov [calc], '-'
|
mov [calc], '-'
|
||||||
call print_display
|
call print_display
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
no_sub:
|
no_sub:
|
||||||
cmp eax, 29
|
cmp eax, 29
|
||||||
jne no_div
|
jne no_div
|
||||||
@ -450,7 +450,7 @@ new_entry:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
ftoa: ; fpu st0 -> [integer],[decimal]
|
ftoa: ; fpu st0 -> [integer],[decimal]
|
||||||
pusha
|
pusha
|
||||||
fst [tmp2]
|
fst [tmp2]
|
||||||
fstcw [controlWord] ; set truncate integer mode
|
fstcw [controlWord] ; set truncate integer mode
|
||||||
@ -559,7 +559,7 @@ atof:
|
|||||||
|
|
||||||
.error:
|
.error:
|
||||||
mov bh, 1 ; Set error code.
|
mov bh, 1 ; Set error code.
|
||||||
; fstp st0 ; Pop top of fpu stack.
|
; fstp st0 ; Pop top of fpu stack.
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
pop di
|
pop di
|
||||||
@ -661,12 +661,12 @@ draw_window:
|
|||||||
mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
|
mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
|
||||||
|
|
||||||
mov ecx, 200 shl 16 + 210
|
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]
|
mov edx, [sc.work]
|
||||||
or edx, 0x34000000
|
or edx, 0x34000000
|
||||||
mov edi, title
|
mov edi, title
|
||||||
mcall 0, <250, 317>
|
mcall 0, <250, 317>
|
||||||
|
|
||||||
mov eax, SF_DEFINE_BUTTON
|
mov eax, SF_DEFINE_BUTTON
|
||||||
mov ebx, 19 shl 16 + 36
|
mov ebx, 19 shl 16 + 36
|
||||||
mov ecx, 55 shl 16 + 22
|
mov ecx, 55 shl 16 + 22
|
||||||
@ -719,7 +719,7 @@ next_button:
|
|||||||
DrawRectangle DISPLAY_X,DISPLAY_Y,DISPLAY_W,DISPLAY_H, [sc.work_graph]
|
DrawRectangle DISPLAY_X,DISPLAY_Y,DISPLAY_W,DISPLAY_H, [sc.work_graph]
|
||||||
mcall 38, < DISPLAY_X+1, DISPLAY_W+DISPLAY_X-1>, <DISPLAY_Y+1, DISPLAY_Y+1>, 0xE0E0E0 ; internal shadow
|
mcall 38, < DISPLAY_X+1, DISPLAY_W+DISPLAY_X-1>, <DISPLAY_Y+1, DISPLAY_Y+1>, 0xE0E0E0 ; internal shadow
|
||||||
mcall , < DISPLAY_X+1, DISPLAY_X+1>, <DISPLAY_Y+2, DISPLAY_Y+DISPLAY_H-1>, ; internal shadow
|
mcall , < DISPLAY_X+1, DISPLAY_X+1>, <DISPLAY_Y+2, DISPLAY_Y+DISPLAY_H-1>, ; internal shadow
|
||||||
|
|
||||||
call print_display
|
call print_display
|
||||||
|
|
||||||
mcall 12, 2
|
mcall 12, 2
|
||||||
@ -729,11 +729,11 @@ print_display:
|
|||||||
pusha
|
pusha
|
||||||
mcall 13, < DISPLAY_X+2, DISPLAY_W-2>, <DISPLAY_Y+2, DISPLAY_H-2>, 0xFFFfff ; background
|
mcall 13, < DISPLAY_X+2, DISPLAY_W-2>, <DISPLAY_Y+2, DISPLAY_H-2>, 0xFFFfff ; background
|
||||||
mcall 8, <236,53>, <DISPLAY_Y,DISPLAY_H>, 3, [sc.work] ; 'dec-bin-hex'
|
mcall 8, <236,53>, <DISPLAY_Y,DISPLAY_H>, 3, [sc.work] ; 'dec-bin-hex'
|
||||||
|
|
||||||
mov ecx, [sc.work_text]
|
mov ecx, [sc.work_text]
|
||||||
or ecx, 0x40000000
|
or ecx, 0x40000000
|
||||||
mcall 4, <135,6>,,calc,1,[sc.work]
|
mcall 4, <135,6>,,calc,1,[sc.work]
|
||||||
|
|
||||||
mov edx, [display_type]
|
mov edx, [display_type]
|
||||||
shl edx, 2
|
shl edx, 2
|
||||||
add edx, display_type_text
|
add edx, display_type_text
|
||||||
@ -746,7 +746,7 @@ print_display:
|
|||||||
je positive
|
je positive
|
||||||
mcall , <23, 26>, 0, dsign, 1
|
mcall , <23, 26>, 0, dsign, 1
|
||||||
|
|
||||||
positive:
|
positive:
|
||||||
cmp [display_type], 0
|
cmp [display_type], 0
|
||||||
jne no_display_decimal
|
jne no_display_decimal
|
||||||
cmp [decimal], 0
|
cmp [decimal], 0
|
||||||
|
@ -24,8 +24,8 @@ _ipc_send:
|
|||||||
xchg edx, esi
|
xchg edx, esi
|
||||||
.send_again:
|
.send_again:
|
||||||
mov eax, 5
|
mov eax, 5
|
||||||
mov ebx, SEND_DELAY
|
mov ebx, SEND_DELAY
|
||||||
int 0x40
|
int 0x40
|
||||||
|
|
||||||
mov eax, 60
|
mov eax, 60
|
||||||
mov ebx, 2
|
mov ebx, 2
|
||||||
@ -65,7 +65,7 @@ _ipc_recv:
|
|||||||
push ecx
|
push ecx
|
||||||
|
|
||||||
mov dword [esi + 4], 0 ; unlock buffer
|
mov dword [esi + 4], 0 ; unlock buffer
|
||||||
mov dword [esi + 8], 0 ;
|
mov dword [esi + 8], 0 ;
|
||||||
|
|
||||||
push edx
|
push edx
|
||||||
mov eax, 60 ; register buffer
|
mov eax, 60 ; register buffer
|
||||||
@ -89,7 +89,7 @@ _ipc_recv:
|
|||||||
cmp eax, 7
|
cmp eax, 7
|
||||||
jnz .err
|
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
|
cmp eax, [esi + 4] ; daemon, so ignore
|
||||||
jnz .wait
|
jnz .wait
|
||||||
|
|
||||||
@ -136,13 +136,13 @@ clipboard_init:
|
|||||||
; mov [.IPC_buffer], ecx
|
; mov [.IPC_buffer], ecx
|
||||||
|
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, 1
|
mov ebp, 1
|
||||||
.next_process:
|
.next_process:
|
||||||
mov eax, 9
|
mov eax, 9
|
||||||
mov ebx, .process_info
|
mov ebx, .process_info
|
||||||
mov ecx, ebp
|
mov ecx, ebp
|
||||||
int 0x40
|
int 0x40
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
mov ebx, .process_info + 10
|
mov ebx, .process_info + 10
|
||||||
mov eax, [ebx]
|
mov eax, [ebx]
|
||||||
cmp eax, '@CLI'
|
cmp eax, '@CLI'
|
||||||
@ -153,19 +153,19 @@ clipboard_init:
|
|||||||
jmp .similar
|
jmp .similar
|
||||||
|
|
||||||
; mov edx, .clipserv_name
|
; mov edx, .clipserv_name
|
||||||
;.compare:
|
;.compare:
|
||||||
; mov al, [edx]
|
; mov al, [edx]
|
||||||
; cmp al, 0
|
; cmp al, 0
|
||||||
; jz .similar
|
; jz .similar
|
||||||
; cmp al, [ebx]
|
; cmp al, [ebx]
|
||||||
; jnz .differ
|
; jnz .differ
|
||||||
; inc edx
|
; inc edx
|
||||||
; inc ebx
|
; inc ebx
|
||||||
; jmp .compare
|
; jmp .compare
|
||||||
.differ:
|
.differ:
|
||||||
inc ebp
|
inc ebp
|
||||||
cmp ebp, ecx
|
cmp ebp, ecx
|
||||||
jae .err ; process not found
|
jae .err ; process not found
|
||||||
jmp .next_process
|
jmp .next_process
|
||||||
.similar:
|
.similar:
|
||||||
;print "found server"
|
;print "found server"
|
||||||
@ -185,7 +185,7 @@ clipboard_init:
|
|||||||
ret
|
ret
|
||||||
.clipserv_pid dd 0
|
.clipserv_pid dd 0
|
||||||
.process_info db 1024 dup(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_buffer dd .IPC_real_buffer ; sorry
|
||||||
;.IPC_real_buffer db IPC_buffer_size dup(0)
|
;.IPC_real_buffer db IPC_buffer_size dup(0)
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ print "write failed"
|
|||||||
pop edi
|
pop edi
|
||||||
pop edx
|
pop edx
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.msg_set_size dw 1
|
.msg_set_size dw 1
|
||||||
dw 1
|
dw 1
|
||||||
@ -240,8 +240,8 @@ print "write failed"
|
|||||||
|
|
||||||
clipboard_read:
|
clipboard_read:
|
||||||
; esi -> CLIP_buffer, ax = format id
|
; esi -> CLIP_buffer, ax = format id
|
||||||
; edx - ¬ ᪠ᮡë⨩ ¯® 㬮«ç ¨î
|
; edx - маска событий по умолчанию
|
||||||
; result: eax = 1 - success, 0 - general failure,
|
; result: eax = 1 - success, 0 - general failure,
|
||||||
; -1 - buffer too small
|
; -1 - buffer too small
|
||||||
; edx = size of data
|
; edx = size of data
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ clipboard_read:
|
|||||||
mov [.msg_get_buf + 2], ax
|
mov [.msg_get_buf + 2], ax
|
||||||
mov edx, 8
|
mov edx, 8
|
||||||
call _ipc_send
|
call _ipc_send
|
||||||
or eax, eax
|
or eax, eax
|
||||||
jz .err
|
jz .err
|
||||||
|
|
||||||
;;mov edx, DEFAULT_MASK
|
;;mov edx, DEFAULT_MASK
|
||||||
@ -291,7 +291,7 @@ pregs
|
|||||||
or eax, eax
|
or eax, eax
|
||||||
jz .err
|
jz .err
|
||||||
|
|
||||||
;print "send fuck"
|
;print "send DEBUG!"
|
||||||
|
|
||||||
mov edx, ebp
|
mov edx, ebp
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
@ -304,8 +304,7 @@ print "read get data"
|
|||||||
mov edx, ebx
|
mov edx, ebx
|
||||||
mov eax, 1
|
mov eax, 1
|
||||||
print "read ok"
|
print "read ok"
|
||||||
jmp .exit ; i'm an idiot. Never will I code at night again
|
jmp .exit.
|
||||||
; i put jz instead of jmp.
|
|
||||||
|
|
||||||
.size:
|
.size:
|
||||||
print "buffer small"
|
print "buffer small"
|
||||||
@ -347,7 +346,7 @@ clipboard_delete:
|
|||||||
mov [esi + 2], ax
|
mov [esi + 2], ax
|
||||||
mov edx, 8
|
mov edx, 8
|
||||||
|
|
||||||
call _ipc_send
|
call _ipc_send
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
pop edx
|
pop edx
|
||||||
@ -356,4 +355,3 @@ clipboard_delete:
|
|||||||
.msg_del dw 0
|
.msg_del dw 0
|
||||||
dw 1
|
dw 1
|
||||||
dd 0
|
dd 0
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ no_lit:
|
|||||||
button_4:
|
button_4:
|
||||||
cmp ah,4 ; was it button 4 - LOAD
|
cmp ah,4 ; was it button 4 - LOAD
|
||||||
jne button_5 ; no then try button 5
|
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 draw_filename ; update filename
|
||||||
call load_file ; load the file
|
call load_file ; load the file
|
||||||
call draw_icon ; update icon screen
|
call draw_icon ; update icon screen
|
||||||
@ -124,16 +124,16 @@ no_lit:
|
|||||||
button_5:
|
button_5:
|
||||||
cmp ah,5 ; was it button 5 - SAVE
|
cmp ah,5 ; was it button 5 - SAVE
|
||||||
jne button_6 ; no then try button 6
|
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 draw_filename ; update filename
|
||||||
call save_file ; save the file
|
call save_file ; save the file
|
||||||
jmp check_mouse ; start loop again
|
jmp check_mouse ; start loop again
|
||||||
button_6:
|
button_6:
|
||||||
cmp ah,6 ; was it button 6 - CLEAR ICON
|
cmp ah,6 ; was it button 6 - CLEAR ICON
|
||||||
jne button_7 ; no then try button 7
|
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 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
|
jmp check_mouse
|
||||||
|
|
||||||
button_7:
|
button_7:
|
||||||
@ -179,7 +179,7 @@ draw_window:
|
|||||||
mov edx,0x14ffffff ; color of work area 0x00RRGGBB
|
mov edx,0x14ffffff ; color of work area 0x00RRGGBB
|
||||||
mov edi,title ; WINDOW LABEL
|
mov edi,title ; WINDOW LABEL
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov eax,13 ; function 13 : draw bar
|
mov eax,13 ; function 13 : draw bar
|
||||||
mov ebx,5*65536+window_x_size-9 ; [x start] *65536 + [x size]
|
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]
|
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
|
jne next_b_w_outer
|
||||||
|
|
||||||
cmp [first_run],0 ; is it the first window draw
|
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
|
call load_file ; load initial file
|
||||||
mov [first_run],1 ; first window draw done
|
mov [first_run],1 ; first window draw done
|
||||||
dont_load:
|
dont_load:
|
||||||
|
@ -851,7 +851,7 @@ draw_window:
|
|||||||
mov edi,title ; WINDOW LABEL
|
mov edi,title ; WINDOW LABEL
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
|
|
||||||
mov eax,8 ; START/STOP - id 2
|
mov eax,8 ; START/STOP - id 2
|
||||||
mov ebx,24*65536+77
|
mov ebx,24*65536+77
|
||||||
mov ecx,80*65536+16
|
mov ecx,80*65536+16
|
||||||
@ -977,7 +977,7 @@ text:
|
|||||||
db ' '
|
db ' '
|
||||||
db ' '
|
db ' '
|
||||||
db ' START/STOP << >> REPEAT:OFF '
|
db ' START/STOP << >> REPEAT:OFF '
|
||||||
db 'x <- END MARKER, DONT DELETE '
|
db 'x <- END MARKER, DON'T DELETE '
|
||||||
now_playing:
|
now_playing:
|
||||||
db ' '
|
db ' '
|
||||||
db 'xx '
|
db 'xx '
|
||||||
|
@ -355,14 +355,14 @@ void draw_grid()
|
|||||||
|
|
||||||
// column headers + vertical lines
|
// column headers + vertical lines
|
||||||
cell_x[0] = 0;
|
cell_x[0] = 0;
|
||||||
x = cell_w[0];
|
x = cell_w[0];
|
||||||
nx = 1;
|
nx = 1;
|
||||||
for (i = 1; i < col_count && x-x0 < grid.w; i++)
|
for (i = 1; i < col_count && x-x0 < grid.w; i++)
|
||||||
{
|
{
|
||||||
cell_x[i] = -1;
|
cell_x[i] = -1;
|
||||||
if (i >= grid.firstx)
|
if (i >= grid.firstx)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
//if (!sel_moved || (is_x_changed(i))) {
|
//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;
|
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);
|
kos_DrawBar(x-x0, 0, 1, grid.h, GRID_COLOR);
|
||||||
@ -404,7 +404,7 @@ void draw_grid()
|
|||||||
y += cell_h[i];
|
y += cell_h[i];
|
||||||
ny++;
|
ny++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cells itself
|
// cells itself
|
||||||
y = cell_h[0];
|
y = cell_h[0];
|
||||||
for (i = grid.firsty; i < ny; i++)
|
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);
|
else if (error) kos_DrawRegion(x+1, y+1, cell_w[j]-1, cell_h[i]-1, 0xff0000, 0);
|
||||||
}
|
}
|
||||||
x += cell_w[j];
|
x += cell_w[j];
|
||||||
}
|
}
|
||||||
y += cell_h[i];
|
y += cell_h[i];
|
||||||
}
|
}
|
||||||
DrawScrolls();
|
DrawScrolls();
|
||||||
@ -464,7 +464,7 @@ void draw_size_grid()
|
|||||||
{
|
{
|
||||||
int x, x0, i;
|
int x, x0, i;
|
||||||
|
|
||||||
x = cell_w[0];
|
x = cell_w[0];
|
||||||
x0 = 0;
|
x0 = 0;
|
||||||
for (i = 1; i < col_count && x - x0 + cell_w[i] < grid.w - 10; i++)
|
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;
|
int y, y0, i;
|
||||||
|
|
||||||
y = cell_h[0];
|
y = cell_h[0];
|
||||||
y0 = 0;
|
y0 = 0;
|
||||||
for (i = 1; i < col_count && y - y0 + cell_h[i] < grid.h - 10; i++)
|
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 x0 = cell_x[k0] - 1;
|
||||||
DWORD x1 = cell_x[k1] + cell_w[k1] + 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;
|
DWORD y1 = cell_y[n1] + cell_h[n1] + 1;
|
||||||
if (x0 > grid.w - 1) x0 = grid.w - 1;
|
if (x0 > grid.w - 1) x0 = grid.w - 1;
|
||||||
if (x1 > grid.w - 1) x1 = grid.w - 1;
|
if (x1 > grid.w - 1) x1 = grid.w - 1;
|
||||||
@ -536,7 +536,7 @@ void draw_window()
|
|||||||
{
|
{
|
||||||
kos_WindowRedrawStatus(1);
|
kos_WindowRedrawStatus(1);
|
||||||
kos_DefineAndDrawWindow(110,40,WND_W,WND_H,0x73,0x40FFFFFF,0,0,(Dword)"Table v" TABLE_VERSION);
|
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);
|
kos_GetSystemColors(&sc);
|
||||||
|
|
||||||
@ -560,8 +560,8 @@ void draw_window()
|
|||||||
|
|
||||||
int panel_y = cHeight - MENU_PANEL_HEIGHT + 1;
|
int panel_y = cHeight - MENU_PANEL_HEIGHT + 1;
|
||||||
kos_DrawBar(0, panel_y, cWidth, MENU_PANEL_HEIGHT-1, sc.work);
|
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.top = panel_y + 10;
|
||||||
file_box.width = cWidth - 265;
|
file_box.width = cWidth - 265;
|
||||||
int BTX = cWidth - 190;
|
int BTX = cWidth - 190;
|
||||||
@ -589,7 +589,7 @@ void process_mouse()
|
|||||||
Dword mouse_btn, ckeys, shift, ctrl;
|
Dword mouse_btn, ckeys, shift, ctrl;
|
||||||
|
|
||||||
int vert, hor;
|
int vert, hor;
|
||||||
kos_GetScrollInfo(vert, hor);
|
kos_GetScrollInfo(vert, hor);
|
||||||
if (vert != 0)
|
if (vert != 0)
|
||||||
{
|
{
|
||||||
stop_edit();
|
stop_edit();
|
||||||
@ -628,7 +628,7 @@ void process_mouse()
|
|||||||
mouse_x -= 5;
|
mouse_x -= 5;
|
||||||
mouse_y -= kos_GetSkinHeight();
|
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_y>=cell_box.top && mouse_y<=cell_box.top+22) return;
|
||||||
|
|
||||||
mouse_btn &= 0x0001;
|
mouse_btn &= 0x0001;
|
||||||
@ -644,7 +644,7 @@ void process_mouse()
|
|||||||
|
|
||||||
if (!size_state && !mouse_btn)
|
if (!size_state && !mouse_btn)
|
||||||
return;
|
return;
|
||||||
if (mouse_btn && !size_state) // LMB down
|
if (mouse_btn && !size_state) // LMB down
|
||||||
{
|
{
|
||||||
//rtlDebugOutString("lmb down and not resize");
|
//rtlDebugOutString("lmb down and not resize");
|
||||||
|
|
||||||
@ -707,7 +707,7 @@ void process_mouse()
|
|||||||
}
|
}
|
||||||
if (kx != -1 && ky != -1)
|
if (kx != -1 && ky != -1)
|
||||||
{
|
{
|
||||||
if (!shift)
|
if (!shift)
|
||||||
{
|
{
|
||||||
move_selection(kx, ky);
|
move_selection(kx, ky);
|
||||||
//return;
|
//return;
|
||||||
@ -795,13 +795,13 @@ void process_mouse()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
draw_drag();
|
draw_drag();
|
||||||
}
|
}
|
||||||
size_mouse_x = mouse_x;
|
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)
|
if (dx != 0)
|
||||||
{
|
{
|
||||||
@ -874,13 +874,13 @@ void process_key()
|
|||||||
dword key_editbox;
|
dword key_editbox;
|
||||||
Byte key_ascii, key_scancode;
|
Byte key_ascii, key_scancode;
|
||||||
|
|
||||||
// key pressed, read it
|
// key pressed, read it
|
||||||
ckeys = kos_GetSpecialKeyState();
|
ckeys = kos_GetSpecialKeyState();
|
||||||
shift = ckeys & 0x3;
|
shift = ckeys & 0x3;
|
||||||
ctrl = ckeys & 0x0c;
|
ctrl = ckeys & 0x0c;
|
||||||
sel_moved = 0;
|
sel_moved = 0;
|
||||||
sel_end_move = 0;
|
sel_end_move = 0;
|
||||||
|
|
||||||
kos_GetKeys(key_editbox, key_ascii, key_scancode);
|
kos_GetKeys(key_editbox, key_ascii, key_scancode);
|
||||||
|
|
||||||
if (cell_box.flags & ed_focus) {
|
if (cell_box.flags & ed_focus) {
|
||||||
@ -896,7 +896,7 @@ void process_key()
|
|||||||
{
|
{
|
||||||
mov eax, key_editbox
|
mov eax, key_editbox
|
||||||
}
|
}
|
||||||
edit_box_key((dword)&cell_box);
|
edit_box_key((dword)&cell_box);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (file_box.flags & ed_focus) {
|
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);
|
//sprintf(debuf, "%U %U %U %U", buf_col, buf_row, x0, y0);
|
||||||
//rtlDebugOutString(debuf);
|
//rtlDebugOutString(debuf);
|
||||||
|
|
||||||
buffer = (char***)allocmem(buf_col * sizeof(char**));
|
buffer = (char***)allocmem(buf_col * sizeof(char**));
|
||||||
for (i = 0; i < buf_col; i++)
|
for (i = 0; i < buf_col; i++)
|
||||||
{
|
{
|
||||||
@ -985,7 +985,7 @@ void process_key()
|
|||||||
buffer[i][j] = NULL;
|
buffer[i][j] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (key_ascii == 24) ///////WTF????
|
if (key_ascii == 24) ///////Unexpected!????
|
||||||
calculate_values();
|
calculate_values();
|
||||||
draw_grid();
|
draw_grid();
|
||||||
break;
|
break;
|
||||||
@ -1149,7 +1149,7 @@ void kos_Main()
|
|||||||
file_box.size = file_box.pos = strlen(fname);
|
file_box.size = file_box.pos = strlen(fname);
|
||||||
EventLoadFile();
|
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 (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (kos_WaitForEvent())
|
switch (kos_WaitForEvent())
|
||||||
@ -1165,7 +1165,7 @@ void kos_Main()
|
|||||||
case EM_BUTTON_CLICK:
|
case EM_BUTTON_CLICK:
|
||||||
process_button();
|
process_button();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EM_WINDOW_REDRAW:
|
case EM_WINDOW_REDRAW:
|
||||||
draw_window();
|
draw_window();
|
||||||
break;
|
break;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
// warnings. See
|
// warnings. See
|
||||||
// https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
|
// https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
|
||||||
// for more info.
|
// for more info.
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
@ -77,11 +78,11 @@ void notify(char *text);
|
|||||||
|
|
||||||
/*** Data section ***/
|
/*** Data section ***/
|
||||||
|
|
||||||
// Kolibri defaults
|
// KolibriOS defaults
|
||||||
int con_def_wnd_width = 80;
|
int con_def_wnd_width = 80;
|
||||||
int con_def_wnd_height = 25;
|
int con_def_wnd_height = 25;
|
||||||
/// winFile support
|
/// winFile support
|
||||||
int fileIsOd0a;
|
int fileIsOd0a;
|
||||||
|
|
||||||
typedef struct editor_row {
|
typedef struct editor_row {
|
||||||
int idx; // Row own index within the file.
|
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
|
// Having a dynamic buffer will allow us to write only one
|
||||||
// time once the screen is refreshing, instead of doing
|
// time once the screen is refreshing, instead of doing
|
||||||
// a lot of write's.
|
// a lot of writes.
|
||||||
struct a_buf {
|
struct a_buf {
|
||||||
char* buf;
|
char* buf;
|
||||||
int len;
|
int len;
|
||||||
@ -465,7 +466,7 @@ void enableRawMode() {
|
|||||||
/// die("Failed to set raw mode");
|
/// 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 editorReadKey() {
|
||||||
int key = con_getch2();
|
int key = con_getch2();
|
||||||
if (key == 0)
|
if (key == 0)
|
||||||
@ -485,13 +486,13 @@ int editorReadKey() {
|
|||||||
|
|
||||||
case 9: // TAB
|
case 9: // TAB
|
||||||
return key;
|
return key;
|
||||||
|
|
||||||
case 22: // Ctrl+V
|
case 22: // Ctrl+V
|
||||||
return CTRL_KEY('v');
|
return CTRL_KEY('v');
|
||||||
|
|
||||||
case 3: // Ctrl+C
|
case 3: // Ctrl+C
|
||||||
return CTRL_KEY('c');
|
return CTRL_KEY('c');
|
||||||
|
|
||||||
case 12: // Ctrl+L
|
case 12: // Ctrl+L
|
||||||
return CTRL_KEY('l');
|
return CTRL_KEY('l');
|
||||||
|
|
||||||
@ -516,7 +517,7 @@ int editorReadKey() {
|
|||||||
*/
|
*/
|
||||||
case 24: // Ctrl+X
|
case 24: // Ctrl+X
|
||||||
return CTRL_KEY('x');
|
return CTRL_KEY('x');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return key;
|
return key;
|
||||||
|
|
||||||
@ -529,7 +530,7 @@ int editorReadKey() {
|
|||||||
|
|
||||||
case 75: // Left
|
case 75: // Left
|
||||||
return ARROW_LEFT;
|
return ARROW_LEFT;
|
||||||
|
|
||||||
case 77: // Right
|
case 77: // Right
|
||||||
return ARROW_RIGHT;
|
return ARROW_RIGHT;
|
||||||
|
|
||||||
@ -541,16 +542,16 @@ int editorReadKey() {
|
|||||||
|
|
||||||
case 81: // PgDn
|
case 81: // PgDn
|
||||||
return PAGE_DOWN;
|
return PAGE_DOWN;
|
||||||
|
|
||||||
case 73: // PgUp
|
case 73: // PgUp
|
||||||
return PAGE_UP;
|
return PAGE_UP;
|
||||||
|
|
||||||
case 71: // Home
|
case 71: // Home
|
||||||
return HOME_KEY;
|
return HOME_KEY;
|
||||||
|
|
||||||
case 79: // End
|
case 79: // End
|
||||||
return END_KEY;
|
return END_KEY;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -844,7 +845,7 @@ void editorSelectSyntaxHighlight() {
|
|||||||
int editorRowCursorXToRenderX(editor_row* row, int cursor_x) {
|
int editorRowCursorXToRenderX(editor_row* row, int cursor_x) {
|
||||||
int render_x = 0;
|
int render_x = 0;
|
||||||
int j;
|
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
|
// 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
|
// 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
|
// 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
|
// to each one for the newline character we'll add to
|
||||||
// the end of each line.
|
// the end of each line.
|
||||||
for (j = 0; j < ec.num_rows; j++) {
|
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
|
+ (fileIsOd0a ? 1:0); /// winFile suppor
|
||||||
}
|
}
|
||||||
*buf_len = total_len;
|
*buf_len = total_len;
|
||||||
@ -1187,7 +1188,7 @@ void editorSave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
editorSetStatusMessage("Cant's save file. Error occurred: %s", strerror(errno));
|
editorSetStatusMessage("Can't save file. Error occurred: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Search section ***/
|
/*** Search section ***/
|
||||||
@ -1361,11 +1362,11 @@ void editorDrawStatusBar(struct a_buf* ab) {
|
|||||||
|
|
||||||
void editorDrawMessageBar(struct a_buf *ab) {
|
void editorDrawMessageBar(struct a_buf *ab) {
|
||||||
// Clearing the message bar.
|
// 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);
|
int msg_len = strlen(ec.status_msg);
|
||||||
if (msg_len > ec.screen_cols)
|
if (msg_len > ec.screen_cols)
|
||||||
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.
|
// remember the screen is only being refreshed after each keypress.
|
||||||
if (msg_len && time(NULL) - ec.status_msg_time < 5)
|
if (msg_len && time(NULL) - ec.status_msg_time < 5)
|
||||||
abufAppend(ab, ec.status_msg, msg_len);
|
abufAppend(ab, ec.status_msg, msg_len);
|
||||||
@ -1730,7 +1731,7 @@ void initEditor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printHelp() {
|
void printHelp() {
|
||||||
/*
|
/*
|
||||||
printf("Usage: tte [OPTIONS] [FILE]\n\n");
|
printf("Usage: tte [OPTIONS] [FILE]\n\n");
|
||||||
printf("\nKEYBINDINGS\n-----------\n\n");
|
printf("\nKEYBINDINGS\n-----------\n\n");
|
||||||
printf("Keybinding\t\tAction\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");
|
printf("\n\nFor now, usage of ISO 8859-1 is recommended.\n");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// NOTIFY HOTKEYS
|
/// NOTIFY HOTKEYS
|
||||||
char* __help__ =
|
char* __help__ =
|
||||||
"'Hotkeys: \n\
|
"'Hotkeys: \n\
|
||||||
^Q, ^Z Exit \n\
|
^Q, ^Z Exit \n\
|
||||||
Ctrl-S Save \n\
|
Ctrl-S Save \n\
|
||||||
@ -1765,9 +1766,9 @@ Ctrl-C Copy line \n\
|
|||||||
Ctrl-X Cut line \n\
|
Ctrl-X Cut line \n\
|
||||||
Ctrl-V Paste line' -t -I";
|
Ctrl-V Paste line' -t -I";
|
||||||
notify(__help__);
|
notify(__help__);
|
||||||
|
|
||||||
/// NOTIFY OPTIONS
|
/// NOTIFY OPTIONS
|
||||||
__help__ =
|
__help__ =
|
||||||
"'Options:\n\
|
"'Options:\n\
|
||||||
-h, --help Prints the help \n\
|
-h, --help Prints the help \n\
|
||||||
-v, --version Prints the version of tte \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[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
#ifdef TCC_BUILD
|
#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");
|
con_init_console_dll_param(con_def_wnd_width, con_def_wnd_height, con_def_wnd_width, con_def_wnd_height, "TinyTextEditor");
|
||||||
#endif
|
#endif
|
||||||
@ -1806,19 +1807,19 @@ int main(int argc, char* argv[]) {
|
|||||||
load_console();
|
load_console();
|
||||||
con_init(con_def_wnd_width, con_def_wnd_height, con_def_wnd_width, con_def_wnd_height, "TinyTextEditor");
|
con_init(con_def_wnd_width, con_def_wnd_height, con_def_wnd_width, con_def_wnd_height, "TinyTextEditor");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
initEditor();
|
initEditor();
|
||||||
int arg_response = handleArgs(argc, argv);
|
int arg_response = handleArgs(argc, argv);
|
||||||
if (arg_response == 1) {
|
if (arg_response == 1) {
|
||||||
char* filename = argv[1];
|
char* filename = argv[1];
|
||||||
// tolower
|
// tolower
|
||||||
for (int i = 0; i < strlen(filename); i++) filename[i] = tolower(filename[i]);
|
for (int i = 0; i < strlen(filename); i++) filename[i] = tolower(filename[i]);
|
||||||
|
|
||||||
editorOpen(filename);
|
editorOpen(filename);
|
||||||
char* title = argv[1];
|
char* title = argv[1];
|
||||||
strcat(title, " - TinyTextEditor");
|
strcat(title, " - TinyTextEditor");
|
||||||
con_set_title(title);
|
con_set_title(title);
|
||||||
}
|
}
|
||||||
else if (arg_response == -1)
|
else if (arg_response == -1)
|
||||||
return 0;
|
return 0;
|
||||||
enableRawMode();
|
enableRawMode();
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user