Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 625 → Rev 624

/programs/network/arpstat/trunk/arpstat.asm
17,7 → 17,6
dd 0x00000000 ; reserved=no extended header
include 'lang.inc'
include '..\..\..\macros.inc'
purge mov ; decrease kpack'ed size
START: ; start of execution
call draw_window ; at first, draw the window
55,13 → 54,15
; Fill the table with blanks
mov edi, text + 160
mov edx, text + 160
doBlank:
mov esi, blank
mov edi, edx
mov ecx, 40
rep movsb
add edx, 40
 
cmp edi, text + 560
cmp edx, text + 560
jne doBlank
pop ecx ; The number of entries
301,13 → 302,17
mov eax,0xffffffff ; close this program
mcall
 
jmp still
 
 
 
writeDecimal:
pusha
and eax, 0xff
mov ecx, eax
mov dl, 100
div dl
movzx ecx, ah
mov cl, ah
add al, '0'
mov [ebx], al
inc ebx
314,8 → 319,13
mov eax, ecx
mov dl, 10
div dl
add ax, '00'
mov [ebx], ax
mov cl, ah
add al, '0'
mov [ebx], al
inc ebx
mov al, ah
add al, '0'
mov [ebx], al
popa
ret
350,7 → 360,7
newline:
mcall
add ebx,16
add edx,esi
add edx,40
cmp [edx],byte 'x'
jnz newline
401,7 → 411,7
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
db 'x' ; <- END MARKER, DONT DELETE
db 'x <- END MARKER, DONT DELETE '
 
blank:
414,3 → 424,9
 
 
I_END:
 
 
/programs/network/stackcfg/trunk/stackcfg.asm
26,8 → 26,8
 
START: ; start of execution
 
cmp [PARAMS], dword 'BOOT'
jz boot_set_settings
cmp [PARAMS], byte 0
jne check_parameters
 
no_params:
 
45,7 → 45,7
jnz button
 
key: ; key
; mov al,2 ; just read it and ignore
mov al,2 ; just read it and ignore
mcall
jmp still
 
55,23 → 55,74
 
shr eax,8
 
dec eax ; button id=1 ?
cmp eax,1 ; button id=1 ?
jne noclose
or eax,-1 ; close this program
mcall
noclose:
 
dec eax
cmp eax,2
je read_stack_setup
 
dec eax
cmp eax,3
jne no_apply_stack_setup
call apply_stack_setup
jmp still
 
no_apply_stack_setup:
dec eax ; GET COM PORT
dec eax
cmp eax,11
jb no_set_interface
cmp eax,14
jg no_set_interface
sub eax,11
mov [interface],eax
call draw_window
jmp still
no_set_interface:
 
cmp eax,21
jb no_ip_sf
cmp eax,22
jg no_ip_sf
sub eax,21
not eax
and eax,1
mov [assigned],eax
call draw_window
jmp still
no_ip_sf:
 
cmp eax,7 ; GET IP
jne no_read_ip
mov [string_x],205
mov [string_y],80
mov [string_length],15
call read_string
mov esi,string-1
mov edi,ip_address
xor eax,eax
ip1:
inc esi
cmp [esi],byte '0'
jb ip2
cmp [esi],byte '9'
jg ip2
imul eax,10
movzx ebx,byte [esi]
sub ebx,48
add eax,ebx
jmp ip1
ip2:
mov [edi],al
xor eax,eax
inc edi
cmp edi,ip_address+3
jbe ip1
call draw_window
jmp still
no_read_ip:
 
cmp eax,5 ; GET COM PORT
jne no_read_comport
mov [string_x],272
mov [string_y],40
101,10 → 152,11
sub eax,48
add ebx,eax
mov [com_add],ebx
jmp red
call draw_window
jmp still
no_read_comport:
 
dec eax ; GET COM IRQ
cmp eax,6 ; GET COM IRQ
jne no_read_comirq
mov [string_x],284
mov [string_y],50
117,38 → 169,11
gci1:
sub eax,48
mov [com_irq],eax
jmp red
call draw_window
jmp still
no_read_comirq:
 
dec eax ; GET IP
jne no_read_ip
mov [string_x],205
mov [string_y],80
mov [string_length],15
call read_string
mov esi,string-1
mov edi,ip_address
ip0:
xor eax,eax
ip1:
inc esi
cmp [esi],byte '0'
jb ip2
cmp [esi],byte '9'
jg ip2
imul eax,10
movzx ebx,byte [esi]
sub ebx,48
add eax,ebx
jmp ip1
ip2:
stosb
cmp edi,ip_address+3
jbe ip0
jmp red
no_read_ip:
dec eax ; set gateway ip
cmp eax, 8 ; set gateway ip
jne no_set_gateway
 
mov [string_x],205
157,7 → 182,6
call read_string
mov esi,string-1
mov edi,gateway_ip
gip0:
xor eax,eax
gip1:
inc esi
171,14 → 195,17
add eax,ebx
jmp gip1
gip2:
stosb
mov [edi],al
xor eax,eax
inc edi
cmp edi,gateway_ip+3
jbe gip0
jmp red
jbe gip1
call draw_window
 
jmp still
 
no_set_gateway:
 
dec eax
cmp eax, 9
jne no_set_subnet
 
mov [string_x],205
187,7 → 214,6
call read_string
mov esi,string-1
mov edi,subnet_mask
sip0:
xor eax,eax
sip1:
inc esi
201,13 → 227,17
add eax,ebx
jmp sip1
sip2:
stosb
mov [edi],al
xor eax,eax
inc edi
cmp edi,subnet_mask+3
jbe sip0
jmp red
jbe sip1
call draw_window
 
jmp still
 
no_set_subnet:
dec eax
cmp eax, 10
jne no_set_dns
 
mov [string_x],205
216,7 → 246,6
call read_string
mov esi,string-1
mov edi,dns_ip
dip0:
xor eax,eax
dip1:
inc esi
230,30 → 259,19
add eax,ebx
jmp dip1
dip2:
stosb
mov [edi],al
xor eax,eax
inc edi
cmp edi,dns_ip+3
jbe dip0
jmp red
jbe dip1
call draw_window
 
jmp still
 
no_set_dns:
jmp still
 
dec eax
jb no_set_interface
cmp eax,14-11
ja no_set_interface
mov [interface],eax
jmp red
no_set_interface:
 
sub eax,21-11
jb no_ip_sf
cmp eax,22-21
ja no_ip_sf
xor eax,1
mov [assigned],eax
jmp red
no_ip_sf:
jmp still
 
read_stack_setup:
 
300,8 → 318,12
shr eax,7
and eax,1
mov [assigned],eax
jmp red
 
call draw_window
 
jmp still
 
 
apply_stack_setup:
 
mov eax,[com_irq]
341,6 → 363,7
mcall
 
ret
jmp still
 
 
string_length dd 16
365,7 → 388,7
mcall
cmp eax,2
jne read_done
; mov eax,2
mov eax,2
mcall
shr eax,8
cmp eax,13
396,6 → 419,11
 
read_done:
 
call print_text
 
ret
 
 
print_text:
 
pusha
579,27 → 607,27
mcall
;mov eax,8 ; BUTTON 6 : SET IRQ
mov ecx,49*65536+8
inc edx
mov edx,6
mcall
;mov eax,8 ; BUTTON 7 : SET IP
mov ecx,79*65536+8
inc edx
mov edx,7
mcall
 
;mov eax,8 ; BUTTON 8 : SET gateway IP
mov ebx,299*65536+8
mov ecx,89*65536+8
inc edx
mov edx,8
mcall
 
;mov eax,8 ; BUTTON 9 : SET subnet
mov ecx,99*65536+8
inc edx
mov edx,9
mcall
 
;mov eax,8 ; BUTTON 10 : SET dns ip
mov ecx,109*65536+8
inc edx
mov edx,10
mcall
 
mov ebx,31*65536+40 ; draw info text with function 4
627,6 → 655,13
 
;******************************************************************************
 
check_parameters:
cmp [PARAMS], dword "BOOT" ; received BOOT parameter -> goto handler
je boot_set_settings
jmp no_params
 
;******************************************************************************
 
boot_set_settings:
 
mov eax,52
688,3 → 723,5
config dd 0
 
I_END:
 
 
/programs/demos/3dcube2/trunk/3DCUBE2.ASM
25,31 → 25,12
 
include 'lang.inc'
include '..\..\..\macros.inc'
;purge mov
include 'ascl.inc'
include 'ascgl.inc'
 
START:
init_sin_cos:
finit
fldz
xor edi,edi
mov ecx,512
isc_make:
fld st0
fsincos
fmul [fixed_point_const]
fistp word [cos_table+edi]
fmul [fixed_point_const]
fistp word [sin_table+edi]
 
fadd [inc_angle]
 
add edi,2
loop isc_make
fstp st0
red:
call draw_window
call init_sin_cos
 
still:
mov eax,11
95,6 → 76,9
 
jmp still
 
red:
call draw_window
jmp still
key:
mov eax,2
mcall
140,37 → 124,46
mov ecx,3
mov edi,@@tx1 ;bp
df_get_point:
movzx ebx, byte [esi]
movzx eax, word [object_translated + ebx*4]
stosd
movzx eax, word [object_translated + ebx*4 + 2]
stosd
xor bh,bh
mov bl,byte [esi]
shl bx,2
mov ax,word [object_translated+bx]
mov word [edi],ax
mov ax,word [object_translated+bx+2]
mov word [edi+2],ax
inc esi
add edi,4
dec ecx
jnz df_get_point
 
mov eax,[@@ty1]
sub eax,[@@ty3]
mov ebx,[@@tx2]
sub ebx,[@@tx1]
imul ebx
push eax
mov eax,[@@tx1]
sub eax,[@@tx3]
mov ebx,[@@ty2]
sub ebx,[@@ty1]
imul ebx
mov ax,[@@ty1]
sub ax,[@@ty3]
mov bx,[@@tx2]
sub bx,[@@tx1]
imul bx
shl edx,16
mov dx,ax
push edx
mov ax,[@@tx1]
sub ax,[@@tx3]
mov bx,[@@ty2]
sub bx,[@@ty1]
imul bx
shl edx,16
mov dx,ax
pop ebx
sub ebx,eax
sub ebx,edx
or ebx,ebx
jge df_next
 
movzx eax, byte [esi]
xor ah,ah
mov al,byte [si]
mov [@@xcol], eax
mov [@@xcol],ax
 
call filled_triangle
df_next:
inc esi
inc si
pop ecx
dec ecx
jnz df_draw
185,7 → 178,7
mov ebx,scrbuf
mov ecx,SCREEN_X*65536+SCREEN_Y
mov edx,5*65536+22
mov eax,7
mov ax,7
mcall
 
;White background
203,22 → 196,21
 
;filled trangle procedure
 
align 4
@@tx1 dd 0
@@ty1 dd 0
@@tx2 dd 0
@@ty2 dd 0
@@tx3 dd 0
@@ty3 dd 0
@@xcol dd 0
@@tx1 dw 0
@@ty1 dw 0
@@tx2 dw 0
@@ty2 dw 0
@@tx3 dw 0
@@ty3 dw 0
@@xcol dw 0
 
@@dx12 dd 0
@@dx13 dd 0
@@dx23 dd 0
@@dx12 dw 0
@@dx13 dw 0
@@dx23 dw 0
 
filled_triangle:
 
mov eax,[@@xcol] ;trnsforming color
mov ax,[@@xcol] ;trnsforming color
mov bl,al ;byte bbbggrrx
mov dl,al ;to 3 byte
mov dh,al ;bbbxxxxx ggxxxxxx rrxxxxxx
242,139 → 234,140
shl eax,8
mov al,dl
mov dword [@@rgb],eax
mov eax,0 ; for 16 bit instructions
 
mov eax,[@@ty1]
cmp eax,[@@ty3]
mov ax,[@@ty1]
cmp ax,[@@ty3]
jb ft_check1
 
xchg eax,[@@ty3]
mov [@@ty1],eax
xchg ax,[@@ty3]
mov [@@ty1],ax
 
mov eax,[@@tx1]
xchg eax,[@@tx3]
mov [@@tx1],eax
mov ax,[@@tx1]
xchg ax,[@@tx3]
mov [@@tx1],ax
ft_check1:
mov eax,[@@ty2]
cmp eax,[@@ty3]
mov ax,[@@ty2]
cmp ax,[@@ty3]
jb ft_check2
 
xchg eax,[@@ty3]
mov [@@ty2],eax
xchg ax,[@@ty3]
mov [@@ty2],ax
 
mov eax,[@@tx2]
xchg eax,[@@tx3]
mov [@@tx2],eax
mov ax,[@@tx2]
xchg ax,[@@tx3]
mov [@@tx2],ax
ft_check2:
mov eax,[@@ty1]
cmp eax,[@@ty2]
mov ax,[@@ty1]
cmp ax,[@@ty2]
jb ft_check3
 
xchg eax,[@@ty2]
mov [@@ty1],eax
xchg ax,[@@ty2]
mov [@@ty1],ax
 
mov eax,[@@tx1]
xchg eax,[@@tx2]
mov [@@tx1],eax
mov ax,[@@tx1]
xchg ax,[@@tx2]
mov [@@tx1],ax
ft_check3:
 
mov ebx,[@@ty2]
sub ebx,[@@ty1]
mov bx,[@@ty2]
sub bx,[@@ty1]
jnz ft_dx12_make
 
mov [@@dx12],dword 0
mov [@@dx12],word 0
jmp ft_dx12_done
ft_dx12_make:
mov eax,[@@tx2]
sub eax,[@@tx1]
shl eax,7
cdq
idiv ebx
mov [@@dx12],eax ; dx12 = (x2-x1)/(y2-y1)
mov ax,[@@tx2]
sub ax,[@@tx1]
shl ax,7
cwd
idiv bx
mov [@@dx12],ax ; dx12 = (x2-x1)/(y2-y1)
ft_dx12_done:
 
mov ebx,[@@ty3]
sub ebx,[@@ty1]
mov bx,[@@ty3]
sub bx,[@@ty1]
jnz ft_dx13_make
 
mov [@@dx13],dword 0
mov [@@dx13],word 0
jmp ft_dx13_done
ft_dx13_make:
mov eax,[@@tx3]
sub eax,[@@tx1]
shl eax,7
cdq
idiv ebx
mov [@@dx13],eax ; dx13 = (x3-x1)/(y3-y1)
mov ax,[@@tx3]
sub ax,[@@tx1]
shl ax,7
cwd
idiv bx
mov [@@dx13],ax ; dx13 = (x3-x1)/(y3-y1)
ft_dx13_done:
 
mov ebx,[@@ty3]
sub ebx,[@@ty2]
mov bx,[@@ty3]
sub bx,[@@ty2]
jnz ft_dx23_make
 
mov [@@dx23],dword 0
mov [@@dx23],word 0
jmp ft_dx23_done
ft_dx23_make:
mov eax,[@@tx3]
sub eax,[@@tx2]
shl eax,7
cdq
idiv ebx
mov [@@dx23],eax ; dx23 = (x3-x2)/(y3-y2)
mov ax,[@@tx3]
sub ax,[@@tx2]
shl ax,7
cwd
idiv bx
mov [@@dx23],ax ; dx23 = (x3-x2)/(y3-y2)
ft_dx23_done:
 
mov eax,[@@tx1]
shl eax,7
mov ebx,eax
mov ax,[@@tx1]
shl ax,7
mov bx,ax
 
mov ecx,[@@ty1]
mov cx,[@@ty1]
ft_loop1:
 
pushad
 
mov [@@ly],ecx
mov edx,ebx
shr edx,7
mov [@@lx2],edx
mov edx,eax
shr edx,7
mov [@@lx1],edx
mov eax,[@@xcol]
mov [@@lcol],eax
mov [@@ly],cx
mov dx,bx
shr dx,7
mov [@@lx2],dx
mov dx,ax
shr dx,7
mov [@@lx1],dx
mov ax,[@@xcol]
mov [@@lcol],ax
call horizontal_line
 
popad
 
add eax,[@@dx13]
add ebx,[@@dx12]
inc ecx
cmp ecx,[@@ty2]
add ax,[@@dx13]
add bx,[@@dx12]
inc cx
cmp cx,[@@ty2]
jb ft_loop1
 
mov ebx,[@@tx2]
shl ebx,7
mov ecx,[@@ty2]
mov bx,[@@tx2]
shl bx,7
mov cx,[@@ty2]
ft_loop2:
 
pushad
 
mov [@@ly],ecx
mov edx,ebx
shr edx,7
mov [@@lx2],edx
mov edx,eax
shr edx,7
mov [@@lx1],edx
mov eax,[@@xcol]
mov [@@lcol],eax
mov [@@ly],cx
mov dx,bx
shr dx,7
mov [@@lx2],dx
mov dx,ax
shr dx,7
mov [@@lx1],dx
mov ax,[@@xcol]
mov [@@lcol],ax
call horizontal_line
 
popad
 
add eax,[@@dx13]
add ebx,[@@dx23]
add ax,[@@dx13]
add bx,[@@dx23]
inc ecx
cmp ecx,[@@ty3]
cmp cx,[@@ty3]
jb ft_loop2
 
ret
381,25 → 374,28
 
;horizontal line subproc
 
align 4
@@lx1 dd 0
@@lx2 dd 0
@@ly dd 0
@@lcol dd 0
@@lx1 dw 0
@@lx2 dw 0
@@ly dw 0
@@lcol dw 0
 
@@rgb dd 0
 
horizontal_line:
 
mov ecx,[@@lx1]
sub ecx,[@@lx2]
mov ecx,0
mov cx,[@@lx1]
cmp cx,[@@lx2]
ja x12
je ext
; ret
neg ecx
mov cx,[@@lx2]
sub cx,[@@lx1]
mov edi,3
jmp xx
x12:
mov cx,[@@lx1]
sub cx,[@@lx2]
mov edi,-3
jmp xx
ext:
406,11 → 402,17
mov ecx,-1 ;1
; sub ebp,3
xx:
mov eax,[@@ly]
mov eax,0
mov ax,[@@ly]
mov ebx,SCREEN_X ;320
mul ebx
add eax,[@@lx1]
lea ebp,[eax*3-3] ; for delete white dots
mov ebp,0
mov bp,[@@lx1] ;for correct 16 bit size
add eax,ebp
mov ebx,3
mul ebx
mov ebp,eax
sub ebp,3 ;for delete white dots
add ecx,2
loo:
 
454,11 → 456,12
mov edi,@@sin_x
mov edx,3
rp_sin_cos:
mov ebx, [esi]
and ebx,511
mov ax,word [sin_table+ebx*2]
mov bx,word [esi]
and bx,511
shl bx,1
mov ax,word [sin_table+bx]
mov word [edi],ax
mov ax,word [cos_table+ebx*2]
mov ax,word [cos_table+bx]
mov word [edi+2],ax
 
add esi,2
588,7 → 591,8
mov [my],bx
popad
 
movzx ebx,word [esi+4]
mov ebx,0 ;?
mov bx,word [esi+4]
mov ax,[my]
cmp ax,0
jng no_m
597,18 → 601,20
no_m:
add bx,256 ; Z factor (zoom)
 
movsx eax,word [esi]
shl eax,8
cdq
idiv ebx
add eax,(SCREEN_X/2) ;160 ;X factor (center X)
mov eax,0 ;?
mov ax,word [esi]
shl ax,8
cwd
idiv bx; bx
add ax,(SCREEN_X/2) ;160 ;X factor (center X)
stosw
 
movsx eax,word [esi+2]
shl eax,8
cdq
idiv ebx
add eax,(SCREEN_Y/2) ;100 ;Y factor (center Y)
mov eax,0 ;?
mov ax,word [esi+2]
shl ax,8
cwd
idiv bx
add ax,(SCREEN_Y/2) ;100 ;Y factor (center Y)
stosw
 
add esi,6
616,6 → 622,32
jnz translate_points
ret
 
init_sin_cos:
finit
fldz
fstp [temp]
xor edi,edi
mov ecx,512
isc_make:
fld [temp]
fld st0
fld st0
fsin
fmul [fixed_point_const]
fistp word [sin_table+edi]
fcos
fmul [fixed_point_const]
fistp word [cos_table+edi]
 
fadd [inc_angle]
fstp [temp]
 
add edi,2
loop isc_make
ret
 
temp dd 0
 
fixed_point_const dd 16384.0
inc_angle dd 0.01227184630309 ; pi/256
 
/programs/games/rsquare/trunk/rsquare.asm
File deleted
/programs/games/rsquare/trunk/RSQUARE.ASM
0,0 → 1,711
LEVELCONV equ 10
SQ equ 8
FLDSIZE equ 49
FLDSIZE2 equ FLDSIZE*8
DELAY equ 20
TICKS equ 10
LEV_START equ 1
MOBILITY equ 9;13
 
use32
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd run ; start of code
dd I_END ; size of image
dd stak+0x400 ; memory for app
dd stak+0x400 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
include "lang.inc"
include "MACROS.INC"
;include "DEBUG.INC"
 
run:
if LEVELCONV eq 1
call compress_levels
jmp close
end if
mcall 3
mov cl,16
ror eax,cl
mov [generator],eax ; random generator from Tetris
reset:
mov [levptr],level
mov [levnum],LEV_START
if ~ LEV_START eq 1
mov ecx,[levnum]
dec ecx
mov esi,[levptr]
jecxz start
.lp:
movzx eax,word[esi]
and eax,0x7fff
add esi,eax ; limit
loop .lp
mov [levptr],esi
; sub esi,level
; dpd esi
end if
start:
mov ecx,[generator]
and ecx,0xff
.shuf:
call random
loop .shuf
xor eax,eax
and [locked],eax
and [captured],eax
mov [ticks],TICKS
mov [mode],-1
mov ebx,FLDSIZE
mov eax,[generator]
xor edx,edx
div ebx
mov cl,dl
call random
mov eax,[generator]
xor edx,edx
div ebx
mov ch,dl
xchg eax,ecx
movzx ecx,al
imul cx,bx
shr ax,8
add cx,ax
mov esi,[levptr]
mov [dot],ecx
call decompress_level
mov ebx,8
call nokey
red:
call draw_window
; and [event],0
 
still:
 
.flush:
mcall 2
test al,al
jz .flush
 
mov ebx,DELAY
mov eax,[levnum]
shr eax,1
sub ebx,eax
mov eax,23
cmp [mode],0
jl .wait
mov eax,10
.wait:
mcall
.evt:
mov ebx,8
test eax,eax
jne .ev_yes
dec [ticks]
jne still
; mov [ticks],TICKS
; cmp al,[event]
jmp key.ex
; and [event],al
; jmp still
.ev_yes:
cmp eax,2
je key
cmp eax,1 ; redraw request ?
je red
cmp eax,3 ; button in buffer ?
je button
key:
; mov [event],al
mcall 2
cmp ah,13
je button.mode
cmp ah,27
je button.mode
cmp [mode],-1
jne still
cmp ah,104
jne .nohelp
mov [mode],4
jmp red
.nohelp:
cmp ah,112
jne .nopau
mov [mode],3
jmp red
.nopau:
shr eax,8
; dpd eax
cmp eax,' '
je .ex
cmp eax,176
jb still
cmp eax,179
ja still
cmp [locked],0
jnz still
lea ebx,[eax-176]
.ex:
mov [ticks],TICKS
call nokey
call evolution
call red_field
jmp still
 
button: ; BUTTON - only close supported
mcall 17
cmp ah,2
jne close
mcall 8,,,2+1 shl 31
; mov [event],2
.mode:
mov [ticks],TICKS
mov al,[mode]
cmp al,1
je reset
cmp al,2
je reset
mov [mode],-1
test al,al
jnz .no0
inc [levnum]
jmp start
.no0:
jmp red
close:
or eax,-1
int 0x40
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
mov [ticks],TICKS
mcall 12,1
mcall 0,<100,FLDSIZE2+16>,<100,FLDSIZE2+38>,0x04008000
mcall 4,<8,8>,0x10ffffff,header,header.size
mov esi,ecx
if lang eq ru
mcall 47,0x20000,[levnum],<165,8>
else
mcall 47,0x20000,[levnum],<145,8>
end if
call red_field
cmp [mode],0
jl .edraw
mov ecx,(FLDSIZE2-20) shl 16+20
cmp [mode],4
jne .nohelp
mov ecx,100 shl 16+FLDSIZE2-35-100+38
.nohelp:
mcall 13,<5+8,FLDSIZE2-8>,,0xf5deb3;0xffff00
mcall 8,<FLDSIZE2-40,35>,<FLDSIZE2-18,15>,2,0xc0c000
mcall 4,<363,FLDSIZE2-20+6>,0x100000ff,msg_ok,2
mov ebx,(5+8+35)shl 16+FLDSIZE2-20+6
movzx ecx,[mode]
mov edx,messages+4
cmp ecx,4
jne .nxt
mov edx,desc+4
xor ecx,ecx
mov ebx,20 shl 16+110
.nxt:
mov esi,[edx-4]
jecxz .drw
dec ecx
lea edx,[edx+esi+4]
jmp .nxt
.drw:
cmp esi,-1
je .edraw
mcall ,,0x000000ff
mov ecx,1
add ebx,18
cmp [mode],4
je .nxt
.edraw:
mcall 12,2
ret
 
red_field:
mov edi,field
mov ebp,28 shl 16+SQ ; y
mov ecx,FLDSIZE
.lp1:
push ecx
mov ecx,FLDSIZE
mov ebx,8 shl 16+SQ ; x
.lp2:
push ecx
mov edx,0x8000
cmp byte[edi],0
je .zero
cmp byte[edi],2
jne .nored
mov edx,0xff0000
cmp [locked],0
jz .zero
mov edx,0xa00000
jmp .zero
.nored:
mov edx,0
.zero:
mcall 13,,ebp
inc edi
pop ecx
add ebx,8 shl 16
loop .lp2
pop ecx
add ebp,8 shl 16
loop .lp1
 
mov eax,[dot]
mov cl,FLDSIZE
div cl
 
; movzx ebx,ah
; shl ebx,19
; add ebx,8 shl 16+7
; movzx ecx,al
; shl ecx,19
; add ecx,28 shl 16+7
; push eax
; mcall 13,,,0xff
; pop eax
 
movzx ebx,ah
shl ebx,19
add ebx,8 shl 16
shld edx,ebx,16
add dx,SQ-1
mov bx,dx
movzx ecx,al
shl ecx,19
add ecx,28 shl 16
shld edx,ecx,16
add dx,SQ-1
mov cx,dx
mcall 38,,,0xffffff
ror ecx,16
mcall
ret
 
nokey:
xor eax,eax
mov edi,buff
mov ecx,FLDSIZE*FLDSIZE+3
push ecx edi
rep stosb
pop edi
;mov esi,field
mov edi,field
mov edx,FLDSIZE
pop ecx
.llp:
mov eax,2
repne scasb
jecxz .exx
and byte[edi-1],0
push ecx
lea eax,[edi-field-1]
div dl
call get_cell
mov byte[buff+ecx],2
pop ecx
loop .llp
.exx:
mov edi,field
mov esi,buff
mov ecx,FLDSIZE*FLDSIZE
.lp4:
lodsb
cmp al,2
jne .skip3
mov [edi],al
.skip3:
inc edi
loop .lp4
 
ret
 
get_cell:
; ax - source cell [x][y]
; ebx - direction
; 4 2 5
; 0 . 3
; 6 1 7
; out - ecx cell ptr
 
push eax ebx
add ax,[ebx*2+dirs]
mov ebx,FLDSIZE
.c0:
cmp al,bl
jb .c1
sub al,bl
jmp .c0
.c1:
cmp ah,bl
jb .c2
sub ah,bl
jmp .c1
.c2:
movzx ecx,al
imul cx,bx
shr ax,8
add cx,ax
pop ebx eax
ret
 
evolution:
xor edi,edi
and [locked],edi
mov edx,FLDSIZE
mov ecx,FLDSIZE*FLDSIZE
.l1:
push ecx
mov eax,edi
div dl
mov ecx,8
xor ebx,ebx
mov word[neib],bx ; neighbour count
.l2:
push ecx
call get_cell
movzx esi,byte[field+ecx]
test esi,esi ; 0?
jz .skip2
inc byte[neib-1+esi]
.skip2:
inc ebx
pop ecx
loop .l2
mov cl,[neib]
add cl,[neib+1]
cmp cl,2
jne .no2
mov al,[field+edi]
jmp .writebuf
.no2:
xor al,al
cmp cl,3
jne .writebuf
inc al
mov cl,[neib+1]
cmp cl,[neib]
jb .writebuf
inc al
.writebuf:
mov [buff+edi],al
pop ecx
inc edi
loop .l1
 
mov esi,buff
mov edi,field
mov ecx,FLDSIZE*FLDSIZE
rep movsb
call square_check
call dot_move
ret
 
square_check:
mov ecx,FLDSIZE*FLDSIZE+3
mov edx,FLDSIZE
mov edi,field
xor eax,eax
pusha
and dword[cells],eax
and [locked],eax
.nored:
mov al,[edi]
inc edi
dec ecx
jecxz .ex1
test al,al
jz .nored
inc [cells-2+eax*2]
jmp .nored
.ex1:
mov ax,[cells+2]
cmp ax,[cells]
ja dot_move.next_lev
cmp [cells+2],4
je .sq_check
add esp,32
cmp [cells+2],0
jne .loc
mov [mode],1
mov dword[esp+4],red
.loc:
inc [locked]
ret
.sq_check:
popa
.nored2:
mov eax,2
repne scasb
jecxz .loc
lea eax,[edi-field-1]
div dl
xor dh,dh
push ecx
mov ebx,1
call get_cell
add dh,[field+ecx]
mov ebx,3
call get_cell
add dh,[field+ecx]
mov ebx,7
call get_cell
add dh,[field+ecx]
pop ecx
cmp dh,6
jne .nored2
ret
 
random:
mov eax, [generator]
sub eax,0x43ab45b5 ; next random number
ror eax,1
xor eax,0x32c4324f
ror eax,1
mov [generator],eax
ret
 
dot_move:
call random
mov eax,[generator]
xor edx,edx
mov ebx,MOBILITY
div ebx
cmp edx,8
jb .nostay
mov edx,16
.nostay:
mov ebx,edx
shr ebx,1
mov eax,[dot]
; dpd eax
mov cl,FLDSIZE
div cl
call get_cell
mov [dot],ecx
cmp byte[field+ecx],2
jne .nocap
inc [captured]
cmp [captured],2
jne .ex
.next_lev:
mov [mode],0
pop eax
mov eax,[levptr]
cmp word[eax],0
jne .nxt
mov [mode],2
.nxt:
mov dword[esp],red
ret
.nocap:
and [captured],0
.ex:
ret
 
if LEVELCONV eq 1
fileinfo:
 
dd 2
dd 0x0
dd 0x0
.fsize dd 10000
.ptr dd 0x20000
db '/sys/newlev.bin',0
 
macro flush
{
mov [edi],dh
inc edi
}
 
compress_levels:
mov esi,raw_level
mov edi,I_END
mov [fileinfo.ptr],edi
mov ecx,(raw_level_size-raw_level)/(FLDSIZE*FLDSIZE*4) ; 19
.lp1:
push ecx
mov ecx,FLDSIZE*FLDSIZE
mov ebx,edi
mov eax,[esi]
; movzx eax,byte[esi]
movzx edx,al
dpd edx
shl eax,15
stosw
.lp2:
lodsd ;lodsb
cmp al,0xd
jne .nored
flush
xor al,al
stosb
add esi,4
dec ecx
xor dh,dh
jmp .eloop
.nored:
cmp al,dl
jne .change
inc dh
cmp dh,0xff
jb .eloop
flush
xor dh,dh
jmp .eloop
.change:
flush
xor dl,1
mov dh,1
.eloop:
loop .lp2
flush
mov eax,edi
sub eax,ebx
add [ebx],ax
pop ecx
loop .lp1
xor eax,eax
stosw
sub edi,I_END
mov [fileinfo.fsize],edi
mcall 70,fileinfo
ret
 
raw_level:
file 'noname1.dat'
raw_level_size:
 
end if
 
decompress_level:
; esi - level begin
mov edi,field
movzx edx,word[esi]
xor ecx,ecx
mov eax,edx
and edx,0x7fff
add edx,esi ; limit
mov [levptr],edx
add esi,2
shr eax,15
.next:
cmp esi,edx
jae .exloop
movzx ebx,byte[esi]
inc esi
test ebx,ebx
jne .nored
rep stosb
xor al,1
mov word[edi],0x0202
add edi,2
jmp .next
.nored:
add ecx,ebx
cmp ebx,0xff
je .next
rep stosb
xor al,1
jmp .next
.exloop:
rep stosb
ret
 
; DATA AREA
 
FS1 equ (FLDSIZE-1)
dirs dw FS1 shl 8,\
1,\
FS1,\
1 shl 8,\
FS1 shl 8+FS1,\
1 shl 8+FS1,\
FS1 shl 8+1,\
1 shl 8+1,\
0
level:
file 'rlevels.bin'
 
msg_ok db 'OK'
if lang eq ru
header db 'Red Square - “஢¥­ì h - ®¬®éì, p -  ã§ '
.size = $ - header
messages mstr 'Žâ«¨ç­®! ‚ë ¯¥à¥å®¤¨â¥ ­  á«¥¤ãî騩 ã஢¥­ì.',\
'Šà á­ë¥ ª«¥âª¨ ã­¨ç⮦¥­ë. ‚ë ¯à®¨£à «¨.',\
'‚ë ¯à®è«¨ ¢á¥ ã஢­¨. ®§¤à ¢«ï¥¬!',\
'ˆ£à  ¯à¨®áâ ­®¢«¥­ ...'
 
desc mstr ' ‚ë ¨£à ¥â¥ ªà á­ë¬ ª¢ ¤à â¨ª®¬. –¥«ì ¨£àë - ¢ë¦¨âì á।¨',\
'à §¢¨¢ îé¨åáï ç¥à­ëå ª«¥â®ª. …᫨ ‚ ¬ 㤠áâáï ¯®©¬ âì ¡¥«ë©',\
'ªà¥á⨪, ‚ë ¯à®©¤¥â¥ ã஢¥­ì.',\
' —â®¡ë ¯®©¬ âì ¡¥«ë© ªà¥á⨪, ®­ ¤®«¦¥­ ¡ëâì ­ ªàëâ ®¤­®©',\
'¨§ ªà á­ëå ª«¥â®ª ­  ¯à®â殮­¨¨ 2 ¯®ª®«¥­¨© ¯®¤àï¤.',\
' …᫨ ªà á­ë© ª¢ ¤à â à §àã襭, íâ® ¥é¥ ­¥ ¯à®¨£àëè. Œ®¦¥â',\
'¡ëâì, ‚ ¬ ¯®¢¥§¥â ¨ ¥á«¨ ¢ ¯à®æ¥áá¥ í¢®«î樨 ª®«¨ç¥á⢮ ‚ è¨å',\
'ªà á­ëå ª«¥â®ª áâ ­¥â ¡®«ìè¥, 祬 ç¥à­ëå, ã஢¥­ì ¡ã¤¥â',\
"¯à®©¤¥­.",\
'---',\
'„¦®­ •®àâ®­ Š®­ãí© ¨§®¡à¥« ¯à¥ªà á­ãî ¨£àã. ®ç⨠ª ¦¤ë©',\
'¯à®£à ¬¬¨áâ ­ ç¨­ ¥â á¢®î ¯à ªâ¨ªã á ­¥¥. Ž¤­ ª® ॠ«ì­ë¥',\
'¢®§¬®¦­®á⨠í⮩ ¨£àë ¥é¥ ¯«®å® ¨§ã祭ë.',\
'---',\
'Žà¨£¨­ « ¨£àë ¯®¤ Win32 ­ ¯¨á « ‚« ¤¨¬¨à à¨¢ «®¢, 2002',\
'‡ ¯à®£à ¬¬¨à®¢ « ­   áᥬ¡«¥à¥ Willow, 2005'
else
header db 'Red Square - Level h - Help, p - Pause'
.size = $ - header
messages mstr 'Well done! You are on the next level',\
'Your red cells are vanished! Game over.',\
"You've completed the game. Congratulations!",\
'Game paused...'
 
desc mstr ' The main goal of the game for your red square is to stay',\
'alive going through the evolving black cells. If you manage to',\
'catch the white cross, you will pass the level.',\
' To catch the white cross, it must be covered by red cell',\
'during 2 generations.',\
" If your red square is corrupted, you haven't lost yet. You",\
'may have a luck, and if your red cells is developing and the',\
'quantity of black cells is bigger than that of black cells,',\
"you'll pass the level.",\
'---',\
'John Horton Conway has created a great game. Almost every',\
'programmer begins his professional work from it. But the real',\
'possibilities of this game have not discovered yet.',\
'---',\
'Original game under Win32 by Vladimir Privalov, 2002',\
'Programmed in assembly by Willow, 2005'
end if
I_END:
neib db ?,?
cells dw ?,?
mode db ?
levptr dd ?
levnum dd ?
reds dd ?
locked dd ?
generator dd ?
dot dd ?
ticks dd ?
captured dd ?
if LEVELCONV eq 1
os_work rb 4096
end if
field:
rb FLDSIZE*FLDSIZE
rd 1
buff:
rb FLDSIZE*FLDSIZE
stak:
/programs/games/rsquare/trunk/build_en.bat
1,4 → 1,4
@echo lang fix en >lang.inc
@fasm rsquare.asm rsquare
@fasm 3dcube2.asm 3dcube2
@erase lang.inc
@pause
/programs/games/rsquare/trunk/build_ru.bat
1,4 → 1,4
@echo lang fix ru >lang.inc
@fasm rsquare.asm rsquare
@fasm 3dcube2.asm 3dcube2
@erase lang.inc
@pause