Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 1802 → Rev 1803

/programs/games/kox/trunk/data.inc
0,0 → 1,66
;#**************************
;#* X.0.X - DATA
;#************************** 21/10/2007
 
macro DATA_SECTION
{
; „€›… Žƒ€ŒŒ›
;-----------------------------------------------------------------------------
lootxt: db 'oops! - Looser...' ; los
text: db 'KOX v0.003 [ESC] - quit' ; winheader string
texts: db 'Congratulations! You are winner.' ; in window win
textend: db 'New' ;button id=200
px: dw 50 ;x,y -
py: dw 50 ; - for x_put/o_put
seed: dd 0 ;rnd
idx: dd 0 ;N cell
;============ X = Y ============= coords of cells
pole: dw 50, 50 ;+0 or - dd 50*65536+50
dw 100, 50 ;+4
dw 150, 50 ;+8
dw 50,100 ;+..
dw 100,100 ;+
dw 150,100 ;
dw 50,150 ;
dw 100,150 ;
dw 150,150 ;
pox: dd 0,0 ;POLE ( 3x3 )= 9 _bytes_: 'x' / 'o' / empty
pox_: db 0 ;9= 8+1
fill: db 0 ;turn counter 0..9
xwin: db 0 ;who is winner 0/1
owin: db 0 ;who is looser 0/1
poxl: dw 0 ;16 bits - x memory
pool: dw 0 ;16 bits - o memory
;----------------------------------------------------------------------------
oxwall: dw 100100100b,0010010010b,0001001001b ;vert.
dw 111000000b,0000111000b,0000000111b ;horiz
dw 100010001b,0001010100b ;diag -winning combinations
prav: ;==== ¯à ¢¨« -ª®¬¡¨­ æ¨¨=====
dw 000000110b,0 ;á¨âã æ¨ï - 室 ¢ á¨âã æ¨¨
dw 000000101b,1
dw 000000011b,2
dw 000110000b,3
dw 000101000b,4
dw 000011000b,5
dw 110000000b,6
dw 101000000b,7
dw 011000000b,8 ;horiz
 
dw 001001000b,0
dw 001000001b,3
dw 000001001b,6
dw 010010000b,1
dw 010000010b,4
dw 000010010b,7
dw 100100000b,2
dw 100000100b,5
dw 000100100b,8 ;vert
 
dw 000010001b,8
dw 100010000b,0
dw 100000001b,4
dw 000010100b,6
dw 001010000b,2
dw 001000100b,4 ;diag
 
}
/programs/games/kox/trunk/kox.asm
0,0 → 1,20
;************************************************
;* X-0-X / Kolibri OS /
;************************** 17/10/2007 **********
include 'main.inc'
include 'data.inc'
include 'macs.inc'
 
BeginProgram
 
SetEventMask 100111b
call rndseed
 
main_loop
 
Subroutines
 
DATA_SECTION
 
EndProgram
 
/programs/games/kox/trunk/kox.txt
0,0 → 1,27
Kox v0.003
----------------
Šà¥á⨪¨-­®«¨ª¨ ¢ ª®¬¬¥­â à¨ïå ­¥ ­ã¦¤ îâáï.
‚ᥠ¨£à «¨? ‚ᯮ¬¨­ ©â¥... - ¯ «ì楬 ­  § ¯®â¥¢è¥¬ á⥪«¥,
¬¥«®¬ ­  ¤®áª¥, ¯ «ª®© ­  á­¥£ã, ­  §¥¬«¥, àã窮©
­  ãப å ¢ ª«¥âç â®© â¥âà ¤¨...
’¥¯¥àì ¨ ¢ Š®«¨¡à¨.
 
–¥«ì ª ¦¤®£® ¨£à®ª  - ¯¥à¢ë¬ ¢ëáâநâì àï¤ ¨§ âà¥å ᢮¨å
䨣ãà (ªà¥á⨪®¢ ¨«¨ ­®«¨ª®¢) å®¤ï ¯®®ç¥à¥¤­® ­  ¯®«¥ 3x3.
Šâ® ¯¥à¢ë© - â®â ¢ë¨£à «.
 
‚ë ¨£à ¥â¥ ªà¥á⨪ ¬¨, ­®«¨ª ¬¨ - ¢ è ᮯ¥à­¨ª, ª®¬¯ìîâ¥à.
Ž­ ¤®áâ â®ç­® 㬥­, 蠭ᮢ ¢ë¨£à âì - ­¥ ®ç¥­ì ¬­®£®.
 
à¨« £ î ¨á室­ë© ⥪áâ ­   áᥬ¡«¥à¥, ¤¥« ©â¥ á ­¨¬ çâ® å®â¨â¥.
Ž­ á«¥£ª  ®¯â¨¬¨§¨à®¢ ­ (¯® à §¬¥àã) ­® १¥à¢ë ¥é¥ ¥áâì.
Œ®¦¥â ¯®å㤥âì ¥é¥ ¡ ©â ­  ¤¢¥áâ¨...
 
Œ®¦­® ¥é¥ ã«ãçè¨âì  «£®à¨â¬ ¨áªãá⢥­­®£® ¨­â¥««¥ªâ 
(§ âª­ãâì ¯®á«¥¤­îî ¤ëàªã, ç⮡ë ìë«  ­¨ç¥©­ ï ᬥàâì)
¢â®àë¬ å®¤®¬ 室¨âì ¢ 㣮« (¯à®¯ã᪠âì ­¥ç¥â­ë© idx)
¥á«¨ ®â¢¥â¨â ¢ ¯à®â¨¢®¯®«®¦­ë© - á­®¢  ¢ 㣮«.
Œ­¥ «¥­¨¢® ¤®¡ ¢«ïâì ­¥áª®«ìª® ¤¥áï⪮¢ ¡ ©â ¨§-§  1 室 .
ˆ â ª ­¥¯«®å® ¢à®¤¥...
 
== 21/10/2007 == board.kolibrios.org
/programs/games/kox/trunk/macs.inc
0,0 → 1,317
;************************************
;******** Œ€ŠŽ‘› *******************
;************************************
;------------------------------------
; constants
;-----------------------梥â:0xRRGGBB
cBLACK = 0x000000 ; ç¥à­ë©
cRED = 0xFF0000 ; ªà á­ë©
cYELLOW = 0xFFFF00 ; ¦¥«âë©
cGREEN = 0x00FF00 ; §¥«¥­ë©
cNAVY = 0x0000FF ; ᨭ¨©
cMAGENTA = 0xFF00FF ; ¬ «¨­®¢ë©
cBLUE = 0x00FFFF ; £®«ã¡®©
cWHITE = 0xFFFFFF ; ¡¥«ë©
cBROWN = 0x554433 ; ª®à¨ç­¥¢ë©
 
;-------------------------------
cMAGENTAl = 0xB800B8 ; magenta light
cVIOLETl = 0xF800F8 ; 䨮«¥â®¢ë© ᢥâ«
 
macro BeginProgram
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd 0x10000 ;__memory
dd 0x10000 ;__stack
dd 0x0 ; dd __params
dd 0x0
__start:
}
 
macro EndProgram
{
align 32
rb 256
__end:
;org 0x10000
__stack:
__memory:
}
 
 
macro LoopBegin lab,begi
{
push ecx ; ECX->STACK store old
mov ecx,begi
lab:
push ecx ; ECX->STACK counter store
}
 
macro LoopEnd lab,endi
{
pop ecx ;ECX<-STACK counter restore
inc ecx
cmp ecx,endi
jne lab
pop ecx ;ECX<-STACK restore old
}
 
macro SetEventMask mmm
{
mov eax,40
mov ebx,mmm
int 0x40
}
 
macro Subroutines
{
;------------------------------------------------------------------------------
rndseed:
mov eax,26
mov ebx,9
int 0x40
mov dword[seed],eax
ret
rndnext:
mov eax,3
int 0x40
shr eax,16
add eax,dword[seed]
; not eax
ror eax,3
xor eax,0xdeadbeef
mov dword[seed],eax
ret
;============0========== word[px],word[py]
o_put:
mov ax,word[px]
shl eax,16 ;*65536
add eax,35 ;+35
mov ebx,eax ;posX*65536+dX ; [x0] *65536 + [dx]
mov ax,word[py] ;
shl eax,16 ;*65536
add eax,35 ;+35
mov ecx,eax ;posY*65536+dY ; [y0] *65536 + [dy]
mov edx,cB
mov eax,13 ; äã­ªæ¨ï 13 - box
int 0x40 ;BLACK BOX---------------
 
mov ax,word[px]
inc ax ;+1
inc ax ;+1
shl eax,16 ;*65536
add eax,31 ;3 ;+35
mov ebx,eax ;posX*65536+dX ; [x0] *65536 + [dx]
 
mov ax,word[py]
add eax,2
;inc eax
;inc eax
shl eax,16
add eax,31 ;3 ;-2
mov ecx,eax ;posY*65536+dY ; [y0] *65536 + [dy]
mov edx,cW
mov eax,13 ; äã­ªæ¨ï 13 - box
int 0x40 ;WHITE BOX----------
ret
;============X==========
x_put:
;xor eax,eax
mov ax,word[px]
shl eax,16 ;*65536
add ax,word[px]
add eax,35 ;+35
mov ebx,eax ;posX*65536+dX
 
xor eax,eax
mov ax,word[py]
shl eax,16 ;*65536
add ax,word[py]
add eax,35 ;+35
mov ecx,eax ;posX*65536+dX
mov edx,cB
mov eax,38 ; äã­ªæ¨ï 38 - line \
int 0x40
;------------------------------xx
xor eax,eax
mov ax,word[px]
inc eax
shl eax,16 ;*65536
add ax,word[px]
add eax,36 ;+35+1
mov ebx,eax ;posX*65536+dX
xor eax,eax
mov ax,word[py]
shl eax,16 ;*65536
add ax,word[py]
add eax,35 ;+35
mov ecx,eax ;posX*65536+dX ; [x0] *65536 + [dx]
mov edx,cB
mov eax,38 ; äã­ªæ¨ï 38 - line \\
int 0x40
;---------------------------------
xor eax,eax
mov ax,word[px]
shl eax,16 ;*65536
mov ebx,eax ;posX*65536 = .BX
 
xor eax,eax
mov ax,word[px]
add eax,35
add ebx,eax ;---------------------------BX
 
xor eax,eax
mov ax,word[py]
add eax,35
shl eax,16 ;*65536
add ax,word[py] ;+y
mov ecx,eax ;(posY+35)*65536+posY = .CX
mov edx,cB ; 梥â : ç¥à­ë©
mov eax,38 ; äã­ªæ¨ï 38 - line /
int 0x40
;----------------------------------------
xor eax,eax
mov ax,word[px]
inc ax
shl eax,16 ;*65536
mov ebx,eax ;posX*65536 = .BX
 
xor eax,eax
mov ax,word[px]
add eax,36 ;+35+1
add ebx,eax ;---------------------------BX
 
xor eax,eax
mov ax,word[py]
add eax,35
shl eax,16 ;*65536
add ax,word[py] ;+y
mov ecx,eax ;(posY+35)*65536+posY = .CX
mov edx,cB
mov eax,38 ; äã­ªæ¨ï 38 - line //
int 0x40
ret
;------------------------------------Ž‚…Š€ H  ¢ë¨£àëè­ãî á¨âã æ¨î-----x
x_win: xor ecx,ecx
xor ebx,ebx
xor eax,eax
lx0: mov bx,word[poxl] ;áà ¢­¨âì ⥪ãéãî á¨âã æ¨î ­  ¯®«¥ X
mov esi,ecx
shl esi,1 ;*2
mov ax,word[oxwall+esi] ; next pattern
and ebx,eax ;á ¯®¡¥¤­ë¬¨ , ¥á«¨ å®âì ®¤­  ᮢ¯ ¤ ¥â -
sub eax,ebx
jz wx ;¯®¡¥¤  -> set byte xwin=1
inc ecx
cmp ecx,8 ;横« ecx < 8
jb lx0
g00: ;­¥â ᮢ¯ ¤¥­¨©
ret
wx:
inc byte[xwin] ;mov byte[xwin],1
ret
;------------------------------------Ž‚…Š€ H  ¢ë¨£àëè­ãî á¨âã æ¨î-----0
o_win: xor ecx,ecx
xor ebx,ebx
xor eax,eax
lo0: mov bx,word[pool] ;áà ¢­¨âì ⥪ãéãî á¨âã æ¨î ­  ¯®«¥ O
mov esi,ecx
shl esi,1 ;*2
mov ax,word[oxwall+esi] ; next pattern
and ebx,eax ;á ¯®¡¥¤­ë¬¨ , ¥á«¨ å®âì ®¤­  ᮢ¯ ¤ ¥â -
sub eax,ebx
jz wo ;¯®¡¥¤  -> set byte owin=1
inc ecx
cmp ecx,8 ;横«
jb lo0
ret
wo: inc byte[owin] ;mov byte[owin],1
ret
;==================================COmbinations -0- =============
o_com: xor ecx,ecx
xor ebx,ebx
xor eax,eax
l000: mov bx,word[poxl] ; ⥪ãéãî á¨âã æ¨î ­  ¯®«¥ X
; or bx,word[pool] ;+ ⥪ãéãî á¨âã æ¨î ­  ¯®«¥ O
mov esi,ecx
shl esi,2 ;*4 -ᤢ¨£ -á«®¢
mov ax,word[prav+esi] ; á«¥¤ãî饥 ¯à ¢¨«®
and ebx,eax ; ¥á«¨ ­¥ ᮢ¯ ¤ ¥â -
sub eax,ebx
jnz @F ;next ecx
xor eax,eax
xor ebx,ebx
mov ax,word[prav+esi+2] ;esi<-¨§ â ¡«¨æë ¯à ¢¨«
mov bl,byte[pox+eax]
cmp ebx,0 ;empty?
je g00d
@@:
inc ecx
cmp ecx,24 ;横« ¤® 24
jb l000
ret ;­¥â ᮢ¯ ¤¥­¨© - do nothing
g00d:
;¯à¨¬¥­¨âì ¥£®
xor eax,eax
mov ax,word[prav+esi+2] ;esi<-¨§ â ¡«¨æë ¯à ¢¨«
mov esi,eax
mov dword[idx],esi ;á®åà ­¨¬ ¢ idx
ret
 
;==================================¯à¥¤¢ë¨£àëè­ ï ª®¬¡¨­ æ¨ï...
x_com: xor ecx,ecx
xor ebx,ebx
xor eax,eax
l111: mov bx,word[pool] ; ⥪ãéãî á¨âã æ¨î ­  ¯®«¥ O
mov esi,ecx
shl esi,2 ;*4 -ᤢ¨£ -á«®¢
mov ax,word[prav+esi] ; á«¥¤ãî饥 ¯à ¢¨«®
and ebx,eax ; ¥á«¨ ­¥ ᮢ¯ ¤ ¥â -
sub eax,ebx
jnz @F ;next ecx
xor eax,eax
xor ebx,ebx
mov ax,word[prav+esi+2] ;esi<-¨§ â ¡«¨æë ¯à ¢¨«
mov bl,byte[pox+eax]
cmp ebx,0 ;empty?
je g11d
@@:
inc ecx
cmp ecx,24 ;横« ¤® 24
jb l111
ret ;­¥â ᮢ¯ ¤¥­¨© - do nothing
 
g11d:
;¯à¨¬¥­¨âì ¥£®
xor eax,eax
mov ax,word[prav+esi+2] ;esi<-¨§ â ¡«¨æë ¯à ¢¨«
mov esi,eax
mov dword[idx],esi ;á®åà ­¨¬ ¢ idx
ret
}
 
macro playing_field
{
pole_x0:
mov eax,38 ; func 38
mov edx,cB ; the color is black
 
mov ebx,92*65536+92 ;x
mov ecx,42*65536+192 ;y
int 0x40 ;- line vert 1
mov ebx,142*65536+142 ;x
mov ecx,42*65536+192 ;y
int 0x40 ;- line vert 2
mov ebx,42*65536+192 ;x
mov ecx,92*65536+92 ;y
int 0x40 ;- line horiz 1
mov ebx,42*65536+192 ;x
mov ecx,142*65536+142 ;y
int 0x40 ;- line horiz 2
}
/programs/games/kox/trunk/main.inc
0,0 → 1,290
;#**************************
;#* X-0-X = MAIN()
;#************************** 21/10/2007
cB equ cBLACK
cW equ cWHITE
 
macro main_loop
{
 
; äã­ªæ¨ï ®âà¨á®¢ª¨ ®ª­ 
;========================================
draw_window:
mov eax,12 ; äã­ªæ¨ï 12: á®®¡é¨âì á¨á⥬¥
mov ebx,1 ; ¯®¤äã­ªæ¨ï 1, ­ ç «® ¯¥à¥à¨á®¢ª¨
int 0x40
; ===== ŽŠŽ !!!
mov eax,0 ; äã­ªæ¨ï 0: ®¯à¥¤¥«¨âì ¨ ¢ë¢¥á⨠®ª­®
mov ebx,100*65536+250 ; [x ­ ç «ì­ë©] *65536 + [x à §¬¥à]
mov ecx,ebx ;,100*65536+250 ; [y ­ ç «ì­ë©] *65536 + [y à §¬¥à]
mov edx,0x02FFFFFF
 
mov esi,0x808899AA ; 梥⠧ £®«®¢ª  RRGGBB
mov edi,0xFFAAcc ; 梥â à ¬ª¨ RRGGBB
int 0x40
; €„ˆ‘œ ¢ § £®«®¢ª¥ KOX v0.001
mov eax,4 ; äã­ªæ¨ï 4: ­ ¯¨á âì ⥪áâ ¢ ®ª­¥
mov ebx,8*65536+8 ; [x ­ ç «ì­ë©] *65536 + [y ­ ç «ì­ë©]
mov ecx,0x00224422 ; 梥â ⥪áâ  RRGGBB
mov edx,text ; 㪠§ â¥«ì ­  ­ ç «® ⥪áâ 
mov esi,texts-text ; ¤«¨­  ⥪áâ  ¢ ¡ ©â å
int 0x40
;-----------------------------------#-----------------------------------------
; SCENE OF GAME - PLAY YARD - BOARD - DESK - PLAYING FIELD
;---------------
playing_field ;macro in macs.inc
;-------------------------------------------------------------------------------
; ----ŠŽŠˆ----
;-------------------------------------------------------------------------------
;buttons:
mov eax,8 ; äã­ªæ¨ï 8: ®¯à¥¤¥«¨âì ¨ ¢ë¢¥á⨠ª­®¯ªã
mov ebx,230*65536+12 ; [x ­ ç «ì­ë©] *65536 + [x à §¬¥à]
mov ecx,5*65536+12 ; [y ­ ç «ì­ë©] *65536 + [y à §¬¥à]
mov edx,100 ; ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨ =100
mov esi,0xFF6611 ; 梥⠪­®¯ª¨ RRGGBB
int 0x40 ; ===ŠŽŠ€ ‡€Š›’ˆŸ ŽŠ€===
;--------------------------------------------
mov eax,8 ;
mov ebx,200*65536+35 ; ;
mov ecx,25*65536+20 ;
mov edx,200 ;== NEW GAME ==
mov esi,0xCC66CC
int 0x40
;--------------------------------------------
mov eax,4 ; ­ ¯¨á âì ⥪áâ ­  ª­®¯ª¥ NEW
mov ebx,210*65536+30
mov ecx,cB
mov edx,textend
mov esi,3
int 0x40
endbut:
mov eax,12
mov ebx,2
int 0x40
;============================= draw_window: END
event_wait:
mov eax,23 ;==‘Ž›’ˆŸ==
mov ebx,100 ;¦¤ âì ᥪ㭤ã
int 0x40
;-------------------------------------------------------------------------------
; ⨯ ᮡëâ¨ï ¢®§¢à éñ­ ¢ eax, ¤ «¥¥ ¯à®¢¥à塞, ª ª®¥ ᮡë⨥ ¯à®¨§®è«®
;-------------------------------------------------------------------------------
cmp eax,1 ; § ¯à®á ­  ¯¥à¥à¨á®¢ªã?
je redraw
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ª« ¢¨ âãàë?
je key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ¢ ®ª­¥ ¯à®£à ¬¬ë?
je button
cmp eax,6 ; mouse - click or move?
je MOUSE
jmp event_wait ; ¢®§¢à é ¥¬áï ª ­ ç «ã 横«  ®¦¨¤ ­¨ï ᮡë⨩
; ¥á«¨ ᮡë⨩ ­¥â
;-------------------------------------------------------------------------------
; ®¡à ¡®âª  ᮡë⨩
;-------------------------------------------------------------------------------
redraw:
call draw_window ; ¢ë§ë¢ ¥¬ äã­ªæ¨î draw_window ¨
jmp event_wait ; ¢®§¢à é ¥¬áï ­ § ¤ ª 横«ã ®¦¨¤ ­¨ï
key:
mov eax,2 ; áç¨â뢠¥¬ ª®¤ ­ ¦ â®© ª« ¢¨è¨. ‚®§¢à é¥­ ¢ ah.
int 0x40 ; Š« ¢¨è  ¤®«¦­  ¡ëâì ¯à®ç¨â ­  ¤«ï ®ç¨á⪨
cmp ah,27
je clos0 ; exit on ESC
jmp event_wait ; ¢®§¢à â ª event_wait
button:
mov eax,17 ; áç¨â뢠¥¬ ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
int 0x40 ; ¢®§¢à é¥­ ¢ ah.
;-------------------------------------------------------------------------------
; ᬮâਬ, ª ª ï ª­®¯ª  ¡ë«  ­ ¦ â  ¨ ᮮ⢥âáâ¢ãî騬 ®¡à §®¬ ॠ£¨à㥬.
;-------------------------------------------------------------------------------
cmp ah,100 ; ª­®¯ª  á id=100("§ ªàëâì")?
jne noclose ;
clos0: ;
mov eax,-1 ; äã­ªæ¨ï -1: § ¢¥àè¨âì ¯à®£à ¬¬ã
int 0x40 ;
noclose: ; ª­®¯ª  id=200( "New" )
mov dword[pox],0
mov dword[pox+4],0 ;clear memory
mov dword[pox_],0 ;rest and other stuff
mov word[poxl],0 ; bits of pole X
mov word[pool],0 ; bits of pole O
;mov byte[fill],0 ; ®¡­ã«ï¥¬ áç¥â稪 室®¢
;mov byte[xwin],0 ; flag - x winner
;mov byte[owin],0 ; flag - o winner
jmp redraw ; ç¨á⮥ ¨£à®¢®¥ ¯®«¥ ==>>
;-------------------------------------------------------------------------------
; ᬮâਬ, £¤¥ ¡ë«  ­ ¦ â  ¬ëèì
;-------------------------------------------------------------------------------
MOUSE:
mov eax,37 ; ¬ëèìî..
mov ebx,2
int 0x40
cmp eax,0 ; ..­¨ç¥£® ­¥ ­ ¦ â® - ¦¤ âì ᮡë⨩
je event_wait
;­ ¦ â  ª­®¯ª  ¬ëè¨
mov eax,37 ; cursor coords
mov ebx,1
int 0x40 ;eax=x*65536+y
mov [px],eax ;[px][py] - ª®®à¤¨­ â  ⪭ã⮣® ¬¥áâ 
 
xor eax,eax
g11: ;1st cell======
cmp word[px],92
ja g12 ;>92
cmp word[py],92
ja g12 ;>92
 
;mov dword[idx],0 ;N=(0..8)
jmp puts
 
g12: ;2nd cell========
inc al
cmp word[py],145
ja g13 ;>142
cmp word[px],92
ja g13 ;>92
;mov dword[idx],1 ;N=(0..8)
jmp puts
g13: ;3=========
inc al
cmp word[px],92
ja g21 ;>92
;mov dword[idx],2 ;N=(0..8)
jmp puts
g21: ;4========
inc al
cmp word[px],145
ja g22
cmp word[py],92
ja g22
;mov dword[idx],3 ;N=(0..8)
jmp puts
g22: ;5=======
inc al
cmp word[px],145
ja g23
cmp word[py],145
ja g23
;mov dword[idx],4 ;N=(0..8)
jmp puts
g23: ;6=======
inc al
cmp word[px],142
ja g31 ;>142
;mov dword[idx],5 ;N=(0..8)
jmp puts
g31: ;7=======
inc al
cmp word[py],92
ja g32
;mov dword[idx],6 ;N=(0..8)
jmp puts
g32: ;8======
inc al
cmp word[py],145
ja g33
;mov dword[idx],7 ;N=(0..8)
jmp puts
g33: ;9======
inc al
;mov dword[idx],8 ;N=(0..8)
 
puts: ;㦥 ®¯à¥¤¥«¨«¨ ª«¥âªã
push eax
pop dword[idx]
mov esi,dword[idx] ;
cmp byte[pox+esi],0 ;¯®«¥ ᢮¡®¤­®? (0-᢮¡®¤­®¥ ¯®«¥)
jne event_wait ;¢®§¢à é ¥¬áï ­ § ¤ ª 横«ã ®¦¨¤ ­¨ï
 
shl esi,2 ;*4
mov eax,dword[pole+esi]
mov dword[px],eax ;x coord from tabl ->px
;mov ax,word[pole+esi+2]
;mov word[py],ax ;y coord from tabl ->py
 
call x_put ;"X"
 
mov esi,dword[idx] ;esi - cell number =0..8
mov byte[pox+esi],'x'
inc byte[fill] ;turn+1
 
xor eax,eax ;eax=0
inc eax ;bit=1 eax=1
mov ecx,dword[idx] ; esi=n
shl ax,cl ; <<n-bit bit[n]=1
or word[poxl],ax ;set bit in [poxl]
 
call x_win ;¯à®¢¥àª  ¢ë¨£àëè  •
cmp byte[xwin],1 ;ä« £ ¯®¡¥¤ë ãáâ ­®¢«¥­?
jne del5 ;­¥â - ¯¥à¥áª®ª ­  delay
 
mov eax,4 ; äã­ª 4: ­ ¯¨á âì ⥪áâ 'WINNER!'
mov ebx,18*65536+215 ; [x ­ ç] *65536 + [y ­ ç]
mov ecx,0x10FF22FF ; 梥â ⥪áâ  RRGGBB
mov edx,texts ; 㪠§ â¥«ì ­  ­ ç «® ⥪áâ 
mov esi,textend-texts ; ¤«¨­  ⥪áâ  ¢ ¡ ©â å
int 0x40 ;
jmp event_wait ; ¢®§¢à é ¥¬áï ­ § ¤ ª 横«ã ®¦¨¤ ­¨ï
 
;===========================================================
del5: mov eax,5 ;=== delay 0,5 sec ===
mov ebx,50
int 0x40
 
cmp byte[fill],8 ;¢á¥ ¯®«ï § ­ïâë - 室¨âì ­¥ªã¤ 
jnb event_wait ;¢®§¢à é ¥¬áï ­ § ¤ ª 横«ã ®¦¨¤ ­¨ï - ª®­¥æ.
 
rnew: ;
call rndnext ; á«ãç ©­®¥ ç¨á«® ¢ eax
and eax, 0111b ; eax = 0..7
mov esi,eax ; eax->esi
call rndnext ; á«ãç ©­®¥ ç¨á«® ¢ eax
and eax, 01b ; eax= 0..1
add esi,eax ; esi+=eax
;esi=0..8 - index
cmp byte[pox+esi],0 ;á«ãç ©­®¥ ¯®«¥ ᢮¡®¤­®?
jne rnew ;­¥â - ­®¢®¥ á«ãç ©­®¥ ç¨á«®
 
cmp byte[pox+4],0 ;業âà ᢮¡®¤¥­?
jne @F ;­¥â - á«ãç ©­ë© 室 (㦥 ¢ esi)
mov esi,4 ;¤  - 室¨¬ ¢ 業âà (4) ¢¬¥áâ® á«ãç.
@@:
mov dword[idx],esi ;á®åà ­¨¬ ¢ idx
;esi=0..8 - index
call o_com ;¯à®¢¥àª  24åê ª®¬¡¨­ æ¨© XX0
call x_com ;¯à®¢¥àª  24åê ª®¬¡¨­ æ¨© 00*
 
mov esi,dword[idx] ;idx-¨­¤¥ªá ª«¥âª¨(0..8) ªã¤  室
shl esi,2 ; esi*4 - ¯®«¥ á®á⮨⠨§ § ¯¨á¥© ¯® dword
mov eax,dword[pole+esi] ;
mov dword[px],eax ;x coord from tabl ->px
; mov ax,word[pole+esi+2] ;
; mov word[py],ax ;y coord from tabl ->py
call o_put ; à¨á㥬 ­®«¨ª 'O'
 
mov esi,dword[idx]
mov byte[pox+esi],'o'
inc byte[fill] ;turn++
 
xor eax,eax ;eax=0
inc eax ;bit=1 eax=1
mov ecx,dword[idx] ; ecx=n
shl ax,cl ; <<n-bit bit[n]=1
or word[pool],ax ;set bit in [pool]
 
call o_win
cmp byte[owin],1
jne event_wait
 
mov eax,4 ; äã­ª 4: ­ ¯¨á âì ⥪áâ 'LOOSER!'
mov ebx,48*65536+215 ; [x ­ ç] *65536 + [y ­ ç]
mov ecx,0x10FF22FF ; 梥â ⥪áâ  RRGGBB
mov edx,lootxt ; 㪠§ â¥«ì ­  ­ ç «® ⥪áâ 
mov esi,text-lootxt ; ¤«¨­  ⥪áâ  ¢ ¡ ©â å
int 0x40 ;
jmp event_wait ; ¢®§¢à é ¥¬áï ­ § ¤ ª 横«ã ®¦¨¤ ­¨ï
;===========================================--
;
}
 
 
/programs/games/kox/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/games/kox
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/games/lights/trunk/Lights_HINT.PNG
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/games/lights/trunk/data.inc
0,0 → 1,53
;#**************************
;#* LIGHTS (c)* data.inc
;#************************** 15/10/2007
L0 equ 0x0000F8 ; light off
L1 equ 0xFFFF00 ; light on
deltaX equ 35
deltaY equ 35
posX equ 50
posY equ 50
 
macro DATA_SECTION
{
; „€›… Žƒ€ŒŒ›
;-----------------------------------------------------------------------------
text: db 'LIGHTS v0.002 [ESC] - quit' ; winheader string
texts: db 'Congratulations!!!' ; in window
textend:
 
;=================Table===================== 18x18 :: N,Color,X,Y , up,lf,rt,dn
tButIdx: dd 0
tBut:
db 5,0, posX+deltaX*0, posY+deltaY*0 , 0 , 0 , 1 , 1
db 6,0, posX+deltaX*1, posY+deltaY*0 , 0 , 1 , 1 , 1
db 7,0, posX+deltaX*2, posY+deltaY*0 , 0 , 1 , 1 , 1
db 8,0, posX+deltaX*3, posY+deltaY*0 , 0 , 1 , 1 , 1
db 9,0, posX+deltaX*4, posY+deltaY*0 , 0 , 1 , 0 , 1
 
db 10,0, posX+deltaX*0, posY+deltaY*1 , 1 , 0 , 1 , 1
db 11,0, posX+deltaX*1, posY+deltaY*1 , 1 , 1 , 1 , 1
db 12,0, posX+deltaX*2, posY+deltaY*1 , 1 , 1 , 1 , 1
db 13,0, posX+deltaX*3, posY+deltaY*1 , 1 , 1 , 1 , 1
db 14,0, posX+deltaX*4, posY+deltaY*1 , 1 , 1 , 0 , 1
 
db 15,0, posX+deltaX*0, posY+deltaY*2 , 1 , 0 , 1 , 1
db 16,0, posX+deltaX*1, posY+deltaY*2 , 1 , 1 , 1 , 1
db 17,0, posX+deltaX*2, posY+deltaY*2 , 1 , 1 , 1 , 1
db 18,0, posX+deltaX*3, posY+deltaY*2 , 1 , 1 , 1 , 1
db 19,0, posX+deltaX*4, posY+deltaY*2 , 1 , 1 , 0 , 1
 
db 20,0, posX+deltaX*0, posY+deltaY*3 , 1 , 0 , 1 , 1
db 21,0, posX+deltaX*1, posY+deltaY*3 , 1 , 1 , 1 , 1
db 22,0, posX+deltaX*2, posY+deltaY*3 , 1 , 1 , 1 , 1
db 23,0, posX+deltaX*3, posY+deltaY*3 , 1 , 1 , 1 , 1
db 24,0, posX+deltaX*4, posY+deltaY*3 , 1 , 1 , 0 , 1
 
db 25,0, posX+deltaX*0, posY+deltaY*4 , 1 , 0 , 1 , 0
db 26,0, posX+deltaX*1, posY+deltaY*4 , 1 , 1 , 1 , 0
db 27,0, posX+deltaX*2, posY+deltaY*4 , 1 , 1 , 1 , 0
db 28,0, posX+deltaX*3, posY+deltaY*4 , 1 , 1 , 1 , 0
db 29,0, posX+deltaX*4, posY+deltaY*4 , 1 , 1 , 0 , 0
;=======================================:: N,Color,X,Y , up,lf,rt,dn
;----------------------------------------------------------------------------
}
/programs/games/lights/trunk/lights.asm
0,0 → 1,15
;#**************************
;#* LIGHTS * Kolibri OS
;#************************** 15/10/2007
include 'main.inc'
include 'data.inc'
include 'macs.inc'
 
BeginProgram
 
main_loop
 
DATA_SECTION
 
EndProgram
 
/programs/games/lights/trunk/lights.txt
0,0 → 1,11
LIGHTS v0.002
 
Š« áá¨ç¥áª ï ¨£à  ¢ ‹ ¬¯®çª¨ ¨§¢¥áâ­  ¤ ¢­®.
à ¢¨«  ¯à®áâë. –¥«ì ¨£àë ¢ª«îç¨âì ¢á¥ 25 "« ¬¯®ç¥ª".
 ¦ â¨¥ ¬ë誮© ­  ª«¥âªã ¡ã¤¥â ¯¥à¥ª«îç âì « ¬¯®çªã
(  â ª¦¥ ᬥ¦­ë¥)   â ª¦¥ á®á¥¤­¨¥ ¢ á®áâ®ï­¨¥ ¢ª«./¢ëª«.
 
Š ¦¥âáï «¥£ª®, ­® íâ® ¤®¢®«ì­® âà㤭®.
 
 
===16/10/2007===http://board.kolibrios.org/
/programs/games/lights/trunk/macs.inc
0,0 → 1,72
macro BeginProgram
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd 0x10000 ;__memory
dd 0x10000 ;__stack
dd 0x0 ; dd __params
dd 0x0
__start:
}
 
macro EndProgram
{
align 32
rb 2048
__end:
;org 0x10000
__stack:
__memory:
}
 
macro mButton nn,crgb,x,y,dx,dy
{
mov eax,8 ; äã­ªæ¨ï 8: ®¯à¥¤¥«¨âì ¨ ¢ë¢¥á⨠ª­®¯ªã
mov ebx,x*65536+dx ; [x ­ ç «ì­ë©] *65536 + [x à §¬¥à]
mov ecx,y*65536+dy ; [y ­ ç «ì­ë©] *65536 + [y à §¬¥à]
mov edx,nn ; ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨ =1
mov esi,crgb ;0x116611 ; 梥⠪­®¯ª¨ RRGGBB
int 0x40
}
 
macro LoopBegin lab,begi
{
push ecx ; ECX->STACK store
mov ecx,begi
lab:
push ecx ; ECX->STACK counter
}
 
macro LoopEnd lab,endi
{
pop ecx ;ECX<-STACK counter
inc ecx
cmp ecx,endi
jne lab
pop ecx ;ECX<-STACK restore
}
 
 
 
;------------------------------------
; constants
;-----------------------梥â:0xRRGGBB
cBLACK = 0x000000 ; ç¥à­ë©
cRED = 0xFF0000 ; ªà á­ë©
cYELLOW = 0x3FFFF00 ; ¦¥«âë©
cGREEN = 0x00FF00 ; §¥«¥­ë©
cNAVY = 0x0000FF ; ᨭ¨©
cMAGENTA = 0xFF00FF ; ¬ «¨­®¢ë©
cBLUE = 0x00FFFF ; £®«ã¡®©
cWHITE = 0xFFFFFF ; ¡¥«ë©
cBROWN = 0x554433 ;
 
;-------------------------------
cMAGENTAl = 0xB800B8 ; magenta
cVIOLETl = 0xF800F8 ; 䨮«¥â®¢ë©
 
/programs/games/lights/trunk/main.inc
0,0 → 1,217
;#**************************
;#* LIGHTS (c)* main.inc
;#************************** 15/10/2007
L0 equ 0x0000F8 ; light off
L1 equ 0xFFFF00 ; light on
LAG equ 2
deltaX equ 35
deltaY equ 35
posX equ 50
posY equ 50
 
macro main_loop
{
 
; äã­ªæ¨ï ®âà¨á®¢ª¨ ®ª­ 
draw_window:
mov eax,12 ; äã­ªæ¨ï 12: á®®¡é¨âì á¨á⥬¥ ®
; á®áâ®ï­¨¨ ¯¥à¥à¨á®¢ª¨ ®ª­ 
mov ebx,1 ; ¯®¤äã­ªæ¨ï 1, ­ ç «® ¯¥à¥à¨á®¢ª¨
int 0x40
; ===== ŽŠŽ !!1
mov eax,0 ; äã­ªæ¨ï 0: ®¯à¥¤¥«¨âì ¨ ¢ë¢¥á⨠®ª­®
mov ebx,100*65536+270 ; [x ­ ç «ì­ë©] *65536 + [x à §¬¥à]
mov ecx,100*65536+280 ; [y ­ ç «ì­ë©] *65536 + [y à §¬¥à]
mov edx,0x02ccddff ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB
; 0x02000000 = ⨯ ®ª­  2
mov esi,0x808899AA ; 梥⠮¡« á⨠§ £®«®¢ª  RRGGBB
; 0x80000000 = 梥⠯¥à¥â¥ª ¥â
mov edi,0xFFAAcc ; 梥â à ¬ª¨ RRGGBB
int 0x40
; €„ˆ‘œ ¢ § £®«®¢ª¥ Lights v0.001
mov eax,4 ; äã­ªæ¨ï 4: ­ ¯¨á âì ⥪áâ ¢ ®ª­¥
mov ebx,8*65536+8 ; [x ­ ç «ì­ë©] *65536 + [y ­ ç «ì­ë©]
mov ecx,0x00224422 ; 梥â ⥪áâ  RRGGBB
; áâ à訩 ¡ ©â (0x00) - à §¬¥à èà¨äâ 
; (¬ «¥­ìª¨©)
mov edx,text ; 㪠§ â¥«ì ­  ­ ç «® ⥪áâ 
mov esi,texts-text ; ¤«¨­  ⥪áâ  ¢ ¡ ©â å
int 0x40
 
xor eax,eax ; €„ˆ‘œ ¢ ®ª­¥!!!
mov ecx,eax
lb: ;loop ecx
mov edi,ecx ;
shl edi,3 ;
add edi,tBut ;
add al,byte[edi+1] ;
;
inc ecx ;
cmp ecx,25 ;
jne lb ;ecx<25
 
cmp eax, 0xE7 ;25
jne goon
;int3
;call Bin2Hex
mov eax,4 ; äã­ªæ¨ï 4: ­ ¯¨á âì ⥪áâ ¢ ®ª­¥
mov ebx,80*65536+250 ; [x ­ ç «ì­ë©] *65536 + [y ­ ç «ì­ë©]
mov ecx,0x10FF22FF ; 梥â ⥪áâ  RRGGBB
; ; áâ à訩 ¡ ©â (0x10) - à §¬¥à èà¨äâ 
; ; (¡®«ì让)
;mov edx,txthex
;mov esi,17
mov edx,texts ; 㪠§ â¥«ì ­  ­ ç «® ⥪áâ 
mov esi,textend-texts ; ¤«¨­  ⥪áâ  ¢ ¡ ©â å
int 0x40
 
goon:
;-------------------------------------------------------------------------------
; ----ŠŽŠˆ----
; button()
;-------------------------------------------------------------------------------
 
mov eax,8 ; äã­ªæ¨ï 8: ®¯à¥¤¥«¨âì ¨ ¢ë¢¥á⨠ª­®¯ªã
mov ebx,(200-19)*65536+12 ; [x ­ ç «ì­ë©] *65536 + [x à §¬¥à]
mov ecx,5*65536+12 ; [y ­ ç «ì­ë©] *65536 + [y à §¬¥à]
mov edx,100 ; ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨ =1
mov esi,0xFF6611 ; 梥⠪­®¯ª¨ RRGGBB
int 0x40 ; ===ŠŽŠ€ ‡€Š›’ˆŸ ŽŠ€===
 
 
LoopBegin labl,0 ;ecx - loop index
;add ecx,5
mov edi,ecx
shl edi,3 ;edi*8 -index of table
add edi,tBut
 
xor ebx,ebx
mov bl,byte[edi+2] ;X
shl ebx,16 ;*65536=256*256
add ebx,deltaX-LAG ;dX
xor ecx,ecx
mov cl,byte[edi+3] ;Y
shl ecx,16 ;*65536=256*256
add ecx,deltaY-LAG ;dY
xor edx,edx
mov dl,byte[edi] ;N
 
xor esi,esi
cmp byte[edi+1], 0 ;Color = 0/1
je lit_off
mov esi,L1 ;on
jmp lend
lit_off:
mov esi,L0 ;off
lend:
mov eax,8 ;8-BUTTON
int 0x40
LoopEnd labl,25
 
;=============================================================
endbut:
mov eax,12 ; äã­ªæ¨ï 12: á®®¡é¨âì á¨á⥬¥ ®
; á®áâ®ï­¨¨ ¯¥à¥à¨á®¢ª¨ ®ª­ 
mov ebx,2 ; ¯®¤äã­ªæ¨ï 2, ¯¥à¥à¨á®¢ª  ®ª®­ç¥­ 
int 0x40
;ret ; ª®­¥æ ä㭪樨 - íâ® ­¥ äã­ªæ¨ï!
 
event_wait:
;mov eax,10 ; äã­ªæ¨ï 10:=0A ®¦¨¤ ­¨¥ ᮡëâ¨ï
mov eax,23
mov ebx,100
int 0x40
 
; ⨯ ᮡëâ¨ï ¢®§¢à éñ­ ¢ eax, ¤ «¥¥ ¯à®¢¥à塞, ª ª®¥ ᮡë⨥ ¯à®¨§®è«®
;-------------------------------------------------------------------------------
cmp eax,1 ; § ¯à®á ­  ¯¥à¥à¨á®¢ªã?
je redraw
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ª« ¢¨ âãàë?
je key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ¢ ®ª­¥ ¯à®£à ¬¬ë?
je button
 
jmp event_wait ; ¢®§¢à é ¥¬áï ª ­ ç «ã 横«  ®¦¨¤ ­¨ï ᮡë⨩
 
; ¯®á«¥ ⮣®, ª ª ᮡë⨥ ¨¤¥­â¨ä¨æ¨à®¢ ­®, ¥£® ­ ¤® ®¡à ¡®â âì
;-------------------------------------------------------------------------------
redraw:
call draw_window ; ¢ë§ë¢ ¥¬ äã­ªæ¨î draw_window ¨
jmp event_wait ; ¢®§¢à é ¥¬áï ­ § ¤ ª 横«ã ®¦¨¤ ­¨ï
 
key:
mov eax,2 ; áç¨â뢠¥¬ ª®¤ ­ ¦ â®© ª« ¢¨è¨. ‚®§¢à é¥­ ¢ ah.
int 0x40 ; Š« ¢¨è  ¤®«¦­  ¡ëâì ¯à®ç¨â ­  ¤«ï ®ç¨á⪨
cmp ah,27
je clos0 ; exit on ESC
;
jmp event_wait ; ¢®§¢à â ª event_wait
 
button:
mov eax,17 ; áç¨â뢠¥¬ ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
int 0x40 ; ¢®§¢à é¥­ ah.
 
;-------------------------------------------------------------------------------
; ᬮâਬ, ª ª ï ª­®¯ª  ¡ë«  ­ ¦ â  ¨ ᮮ⢥âáâ¢ãî騬 ®¡à §®¬ ॠ£¨à㥬.
;-------------------------------------------------------------------------------
cmp ah,100 ; ª­®¯ª  á id=100("§ ªàëâì")?
jne noclose
clos0:
mov eax,-1 ; äã­ªæ¨ï -1: § ¢¥àè¨âì ¯à®£à ¬¬ã
int 0x40 ; ª­®¯ª  5-29
noclose:
 
xor ecx,ecx ;
mov cl,ah ;
sub ecx,5 ; ecx - index for tBut
 
mov edi,ecx
call x_lit ;+0 - 業âà
mov [tButIdx],edi ;save index
 
mov edi,[tButIdx]
cmp byte[edi+6],0
je next000
mov edi,ecx
inc edi
call x_lit ;+1 á¯à ¢ 
 
next000:
mov edi,[tButIdx]
cmp byte[edi+5],0
je next001
mov edi,ecx
dec edi
call x_lit ;-1 á«¥¢ 
 
next001:
mov edi,[tButIdx]
cmp byte[edi+4],0
je next002
mov edi,ecx
sub edi,5
call x_lit ;-5 ᢥàåã
 
next002:
mov edi,[tButIdx]
cmp byte[edi+7],0
je next003
mov edi,ecx
add edi,5
call x_lit ;+5 á­¨§ã
next003:
call draw_window
jmp event_wait
;================================--
x_lit: ; edi - index
shl edi,3 ; edi*8 -index of table tBut
add edi,tBut ;
not byte[edi+1] ; invert second byte = L0/L1
ret ;
;================================--
call draw_window ;­ è  ª­®¯ª ;)
; §¤¥áì ¯à®¢¥à塞 ®áâ «ì­ë¥ ª­®¯ª¨
jmp event_wait ;¢®§¢à é ¥¬áï ª 横«ã ®¦¨¤ ­¨ï
}
 
 
/programs/games/lights/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/games/lights
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/games/sw/trunk/sw.asm
0,0 → 1,1372
;v. 0.4: 20.10.2009 staper@inbox.ru
 
use32
org 0x0
db 'MENUET01'
dd 0x1
dd START
dd I_END
dd (I_END+600) and not 3
dd (I_END+600) and not 3
dd 0x0,0x0
 
DEBUG equ 0
 
use_new_logic equ 1 ;äîáàâëÿåò ïðîâåðêó êëåòêè íà "îêðóæ¸ííîñòü", ïðîãðàììà âûáèðàåò íàèáîëåå ñâîáîäíóþ
use_ext_logic equ 1 ;ê use_new_logic, äîïîëíèòåëüíàÿ ïðîâåðêà ÿ÷ååê âîêðóã çàäàííîé êëåòêè
 
include '../../../macros.inc'
include 'lang.inc'
 
;include 'debug.inc'
 
macro dbg_dec num
{pushad
newline
debug_print_dec num
popad}
 
 
START:
 
mcall 40,100111b
mcall 3
mov [rsx1],ax
shr eax,16
mov [rsx2],ax
jmp new_game
 
redraw_all:
mcall 12,1
mcall 0,100*65536+432,100*65536+260,0x34FFFFFF,,title
mcall 38,1*65536+421,27*65536+27,0x00b0b0b0
mov edi,10
@@: add ecx,20*65536+20
mcall
dec edi
jnz @b
mcall ,1*65536+1,27*65536+226,;000000
mov edi,21
@@: add ebx,20*65536+20
mcall
dec edi
jnz @b
mcall 13,202*65536+19,27*65536+202,0xFFFFFF
mcall 4,40*65536+12,0x80000000,text_user
mcall ,350*65536+12,,text_cpu
mcall 8,120*65536+70,7*65536+15,2,0xFFFFFF
mcall ,230*65536+70,,3,
mcall 4,135*65536+12,0x80000000,but_new
mcall ,240*65536+12,,but_auto
mcall 12,2
ret
 
draw_pole:
; mcall 0,100*65536+432,100*65536+260,0x74FFFFFF,,title
if DEBUG
call SysMsgBoardNum ;show esp
mcall 8,200*65536+10,7*65536+15,4,0xFFFFFF
endf
 
 
 
mov esi,table1
mov edi,90
mov ebp,10
mov ebx,1*65536+21
mov ecx,27*65536+47
call draw_bots
 
mov esi,table5
mov edi,90
mov ebp,10
mov ebx,221*65536+241
mov ecx,27*65536+47
call draw_bots
cmp [u_kill],10
jne @f
mcall 4,69*65536+12,0x80ff0000,text_win
bts [flags],5
@@: cmp [c_kill],10
jne @f
mcall 4,372*65536+12,0x80ff0000,text_win
bts [flags],5
@@: mcall 12,2
cmp [number_bots],10
jne still
bts [flags],0
still:
mcall 10
 
cmp eax,6
je mouse
dec eax
jnz @f
call redraw_all
jmp draw_pole
@@: dec eax
jz key
dec eax
jz button
jmp still
 
key:
mcall 2
jmp still
 
button:
mcall 17
dec ah
jnz @f
mcall -1
 
@@: mov ecx,(344)/4
mov esi,table1
.3: mov dword [esi],0
add esi,4
loop .3
 
dec ah
jz @f
 
mov [flags],1001b ;auto fill
mov [number_bots],0
 
call set_bots
mov [number_bots],0
bts [flags],2
call set_bots
call redraw_all
btc [flags2],0
jc second_pole.comp
jmp draw_pole
 
@@: ;new game
mov [number_bots],0
new_game:
mov [flags],1100b
call set_bots
btr [flags],0
btr [flags],3
btr [flags],2
mov [number_bots],0
call redraw_all
jmp draw_pole
 
draw_bots:
cmp byte [esi],1
je .one
cmp byte [esi],2
je .two
cmp byte [esi],3
je .three
cmp byte [esi],4
jne .null
bts [flags],4
jmp .three
 
.end:
inc esi
dec ebp
jnz draw_bots
test edi,edi
jz @f
sub edi,10
mov ebp,10
add ebx,-200*65536-200
add ecx,20*65536+20
jmp draw_bots
@@:
ret
 
.one:
push ebx ecx
call .0
mov edx,0x00aa66
mcall 13
pop ecx ebx
.null:
add ebx,20*65536+20
jmp .end
.two:
push ebx ecx
add ebx,8*65536-6
add ecx,12*65536-12
mcall 38,,,0x508cec
add ecx,-6*65536+6
mcall
pop ecx ebx
jmp .null
.three:
push ebx ecx
call .0
mov edx,0x00FF0000
bt [flags],4
jnc @f
mov edx,0x00555555
btr [flags],4
@@: mcall 13
pop ecx ebx
xor edx,edx
mcall 38
add ecx,20*65536-20
mcall
add ecx,-20*65536+20
jmp .null
 
.0:
shr ebx,16
inc bx
shl ebx,16
add ebx,19
shr ecx,16
inc cx
shl ecx,16
add ecx,19
ret
 
mouse:
bt [flags],5
jc still
mcall 37,2
test eax,eax
jz still
cmp al,2
jg still
;1 - «¥¢ ï ª­®¯ª , 2 - ¯à ¢ ï
dec al
jnz .mouse_1
btr [flags],1
jmp @f
.mouse_1:
bts [flags],1
@@:
mcall 37,1
mov dx,ax
shr eax,16
cmp dx,27
jbe still
cmp dx,227
jge still
cmp ax,1
jbe still
cmp ax,201
jge second_pole
;¯¥à¢®¥ ¯®«¥
bt [flags],0
jc still
sub ax,1
push dx
xor edx,edx
mov cx,20
div cx
pop dx
mov [oX],al
push ax
sub dx,27
mov ax,dx
xor dx,dx
div cx
mov [oY],al
xor dx,dx
mov cx,10
mul cx
pop dx
add ax,dx
cmp ax,100
jg still
 
set_bot:
mov esi,table1
bt [flags],2
jnc @f
mov esi,table2
@@: mov edi,esi
add edi,100
cmp [number_bots],6
jnb .1paluba
cmp [number_bots],3
jnb .2paluba
cmp [number_bots],0
je .4paluba
jmp .3paluba
 
.4paluba:
bt [flags],1 ;ç¥âëàñ寠«ã¡­ë©
jnc @f
cmp [oX],6
jg _still
jmp .41
@@: cmp [oY],6
jg _still
.41: inc [number_bots]
mov [edi],al
bt [flags],1
jc @f
add al,10
mov [edi+1],al
add al,10
mov [edi+2],al
add al,10
mov [edi+3],al
jmp init_table
@@: inc al
mov [edi+1],al
inc al
mov [edi+2],al
inc al
mov [edi+3],al
jmp init_table
 
 
.3paluba: ;âàñ寠«ã¡­ë©
bt [flags],1
jnc @f
cmp [oX],7
jg _still
jmp .31
@@: cmp [oY],7
jg _still
.31:
call find_near
 
bt [flags],1
jc @f
add al,10
call find_near
add al,10
call find_near
sub al,20
jmp .32
@@: inc al
call find_near
inc al
call find_near
sub al,2
.32:
inc [number_bots]
mov ecx,4
mov dl,[number_bots]
sub dl,2
jz @f
add ecx,3
@@:
mov [edi+ecx],al
bt [flags],1
jc @f
add al,10
mov [edi+ecx+1],al
add al,10
mov [edi+ecx+2],al
jmp init_table
@@: inc al
mov [edi+ecx+1],al
inc al
mov [edi+ecx+2],al
jmp init_table
 
 
 
.2paluba: ;¤¢ã寠«ã¡­ë©
bt [flags],1
jnc @f
cmp [oX],8
jg _still
jmp .21
@@: cmp [oY],8
jg _still
.21:
call find_near
bt [flags],1
jc @f
add al,10
call find_near
sub al,10
jmp .22
@@: inc al
call find_near
dec al
.22:
inc [number_bots]
mov ecx,8
mov dl,[number_bots]
sub dl,4
jz @f
add ecx,2
dec dl
jz @f
add ecx,2
@@: add ecx,2
mov [edi+ecx],al
bt [flags],1
jc @f
add al,10
mov [edi+ecx+1],al
jmp init_table
@@: inc al
mov [edi+ecx+1],al
jmp init_table
 
 
.1paluba: ;®¤­®¯ «ã¡­ë©
call find_near
inc [number_bots]
xor edx,edx
movzx ecx,[number_bots]
add ecx,9
mov [edi+ecx],al
jmp init_table
 
find_near:
push ax
call f_near ;0
 
cmp al,10
jb @f
sub al,10 ;-10
call f_near
 
@@: cmp al,11
jb @f
 
xor edx,edx
mov ecx,10
div cx
mov ax,[esp]
cmp dx,0
je @f
 
sub al,11 ;-11
call f_near
 
@@: cmp al,9
jb @f
 
xor edx,edx
mov ecx,10
div cx
mov ax,[esp]
cmp dx,9
je @f
 
sub al,9 ;-9
call f_near
 
@@: cmp al,1
jb @f
 
xor edx,edx
mov ecx,10
div cx
mov ax,[esp]
cmp dx,0
je @f
 
dec al ;-1
call f_near
 
@@: cmp al,99
jg @f
 
xor edx,edx
mov ecx,10
div cx
mov ax,[esp]
cmp dx,9
je @f
 
inc al ;+1
call f_near
 
@@: cmp al,90
jge @f
add al,10 ;+10
call f_near
 
@@: cmp al,91
jge @f
 
xor edx,edx
mov ecx,10
div cx
mov ax,[esp]
cmp dx,0
je @f
 
add al,9 ;+9
call f_near
 
@@: cmp al,89
jge @f
 
xor edx,edx
mov ecx,10
div cx
mov ax,[esp]
cmp dx,9
je @f
add al,11 ;+11
call f_near
 
@@: pop ax
; xor bl,bl
; bt [flags],6
; jnc @f
; bt [flags],9
; jnc @f
; inc [p_pov]
; cmp [p_pov],20
; jb @f
; bts [flags],9
; @@:
btr [flags],6
clc
ret
 
f_near:
bt [flags],6
jnc .2
; bt [flags],9
; jc @f
; cmp byte [esi+eax],2
; jge @f
; @@:
cmp byte [esi+eax],4
je @f
mov ax,[esp+4]
ret
@@:; add esp,4
; jmp second_pole.cpu
mov ax,[esp+4]
mov cx,ax
add esp,6
btr [flags],6
stc
; mov bl,1
ret
 
.2: movzx edx, byte [smeshenie]
@@: cmp al,[edi+edx]
je .end
dec dl
jnz @b
cmp al,[edi]
je .end
mov ax,[esp+4]
ret
.end: add esp,10
jmp _still
 
 
 
init_table:
; xor eax,eax
movzx ecx, byte [number_bots]
mov edx,3
dec cl
jz .i_t
 
mov al,2
.2: add dl,3
dec cl
jz .i_t
dec al
jnz .2
 
mov al,3
.3: add dl,2
dec cl
jz .i_t
dec al
jnz .3
 
mov al,4
.4: inc dl
dec cl
jz .i_t
dec al
jnz .4
 
.i_t: mov [smeshenie],dl
@@: movzx eax, byte [edi+edx]
mov byte [esi+eax],1
dec dl
jnz @b
movzx eax, byte [edi]
mov byte [esi+eax],1
bt [flags],3
jc set_bots
; mcall 12,1
jmp draw_pole
 
 
second_pole:
cmp ax,221
jbe still
cmp ax,421
jge still
;¢â®à®¥ ¯®«¥
bt [flags],0
jnc still
sub ax,221
push dx
xor edx,edx
mov cx,20
div cx
pop dx
push ax
sub dx,27
mov ax,dx
xor dx,dx
div cx
xor dx,dx
mov cx,10
mul cx
pop dx
add ax,dx
cmp ax,100
jg still
 
mov edi,table2
mov esi,table5
cmp byte [esi+eax],2
jge still
mov bl, byte [edi+eax]
add bl,2
mov ecx,table5
call if_bot_killed
mov [esi+eax],bl
cmp bl,3
jge .m_end
.comp: mov esi,table1
 
 
 
.cpu:
; jmp .rndm
xor eax,eax
; mov edi,4
btr [flags],8
xor ecx,ecx
mov edx,tbl_ranen
mov dword [edx],0
@@: mov al,[esi+ecx] ;¯®¨áª "¯®¤à ­¥­­®£® ª®à ¡«ï"
cmp al,3
je .0
cmp cl,99
jge .1
inc cl
jmp @b
.0: mov [edx],cl
if DEBUG
dbg_dec ecx
endf
inc edx
inc cl
jmp @b
 
.1:
dec edx
mov cl,[edx]
cmp edx,tbl_ranen
jb .rndm
je @f
sub cl,[edx-1]
cmp cl,1
jne .2
add cl,[edx-1]
jmp .12
.2:
add cl,[edx-1]
jmp .13
 
@@: bts [flags],8
mov eax,4
call random
dec al
jz .11
dec al
jz .12
dec al
jz .13
jmp .14
.11:
if DEBUG
dbg_dec 100
endf
cmp cl,10
jge @f
bts [flags],8
jmp .12
@@: sub cl,10
cmp byte [esi+ecx],2
jge @f
mov eax,ecx
bts [flags],6
call find_near
; test bl,bl
; jz .20
jnc .20
@@: bts [flags],8
add cl,10
bts [flags],8
.12:
if DEBUG
dbg_dec 200
endf
movzx eax,cl
push cx
mov ch,10
div ch
pop cx
cmp ah,9
jb @f
.121:
bt [flags],8
jc .13
bts [flags],8
mov edx,tbl_ranen
mov cl,[edx]
jmp .14
@@: inc cl
cmp byte [esi+ecx],2
jge @f
mov eax,ecx
bts [flags],6
call find_near
; test bl,bl
; jz .20
jnc .20
@@: dec cl
jmp .121
 
.13:
if DEBUG
dbg_dec 300
endf
cmp cl,90
jb @f
.131:
bt [flags],8
jc .14
bts [flags],8
mov edx,tbl_ranen
mov cl,[edx]
jmp .11
@@: add cl,10
cmp byte [esi+ecx],2
jge @f
mov eax,ecx
bts [flags],6
call find_near
; test bl,bl
; jz .20
jnc .20
@@: sub cl,10
jmp .131
 
.14:
if DEBUG
dbg_dec 400
endf
movzx eax,cl
push cx
mov ch,10
div ch
pop cx
cmp ah,0
jne @f
.141:
bts [flags],8
jmp .11;cpu;rndm
@@: dec cl
cmp byte [esi+ecx],2
jge @f
mov eax,ecx
bts [flags],6
call find_near
; test bl,bl
; jz .20
jnc .20
@@: inc cl
jmp .141
 
.rndm:
 
mov eax,100
call random
cmp eax,100
jb @f
shr eax,1
@@:
 
if use_new_logic
btc [flags],10
jnc @f
btc [flags],9
jnc @f
call check_freedom
endf
 
@@: cmp byte [esi+eax],2
jb @f; .rndm
;¯®¨áª ᢮¡®¤­®© ª«¥â®çª¨ ¯¥à¥¤/¯®á«¥ ¢ë¡à ­­®©,
;¨­ ç¥ random ¨­®£¤  ¢å®¤¨â ¢ ¡¥áª®­¥ç­ë© 横«
bt ax,0
jnc .r_1
.r_0:
cmp al,0
je .r_1
dec al
 
cmp byte [esi+eax],2
jb @f
jmp .r_0
.r_1:
cmp al,99
je .r_0
inc al
 
cmp byte [esi+eax],2
jb @f
jmp .r_1
@@:
bts [flags],6
call find_near
; test bl,bl
; jnz .cpu
jc .cpu;20
 
.20:
mov bl,[esi+eax]
add bl,2
mov ecx,esi
mov edi,esi
call if_bot_killed
mov [esi+eax],bl
; cmp [u_kill],10
; je .m_end
cmp [c_kill],10
je .m_end
cmp bl,3
jge .cpu
 
.m_end:; mcall 12,1
jmp draw_pole
 
if_bot_killed:
push ebx
add edi,100
mov ebx,19
@@: cmp al,[edi+ebx]
je @f
dec ebx
jnz @b
cmp al,[edi+ebx]
jne .end
@@:
cmp ebx,16
jnb .end_i
 
@@: cmp bl,10
jb .2
btc bx,0
mov bl, [edi+ebx]
cmp byte [ecx+ebx],3
jne .end
inc byte [ecx+ebx]
jmp .end_i
 
.2: cmp bl,4
jb .3
add edi,4
cmp bl,7
jb .3
add edi,3
.3: movzx edx, byte [edi]
cmp dl,al
je @f
cmp byte [ecx+edx],3
jne .end
@@: mov dl,[edi+1]
cmp dl,al
je @f
cmp byte [ecx+edx],3
jne .end
@@: mov dl,[edi+2]
cmp dl,al
je @f
cmp byte [ecx+edx],3
jne .end
 
@@: cmp bl,4
jnb @f
mov dl,[edi+3]
cmp dl,al
je @f
cmp byte [ecx+edx],3
jne .end
 
 
@@: mov dl,[edi]
cmp dl,al
je @f
inc byte [ecx+edx]
@@: mov dl,[edi+1]
cmp dl,al
je @f
inc byte [ecx+edx]
@@: mov dl,[edi+2]
 
cmp bl,4
jnb .9;@f
 
; cmp dl,al
; je .end_i
; inc byte [ecx+edx]
; jmp .end_i
 
 
@@: cmp dl,al
je @f
inc byte [ecx+edx]
@@: mov dl,[edi+3]
.9: cmp dl,al
je .end_i
inc byte [ecx+edx]
.end_i:
pop ebx
inc ebx
cmp ecx,table5
jne @f
inc [u_kill]
ret
@@: inc [c_kill]
ret
.end: pop ebx
ret
 
 
 
 
_still:
bt [flags],3
jnc still
 
set_bots:
cmp [number_bots],10
jne @f
ret
@@: xor edx,edx
mov ecx,10
cmp [number_bots],6
jb @f
push dword 10
jmp .1
@@: cmp [number_bots],3
jb @f
push dword 9
jmp .1
@@: cmp [number_bots],2
jb @f
push dword 8
jmp .1
@@: push dword 7
.1:
mov eax,[esp]
call random
mov [oX],al
mul cl
mov cl,al
mov eax,[esp]
call random
mov [oY],al
add cl,al
 
cmp cl,100
jge .1
 
add esp,4
mov eax,2
call random
cmp al,1
jne @f
bts [flags],1
mov al,cl
jmp set_bot
@@: btr [flags],1
mov al,cl
jmp set_bot
 
 
 
 
 
 
;¯à®æ¥¤ãà  ®â« ¢«¨¢ ¥â "­ ¨¡®«¥¥ ᢮¡®¤­ãî" ¨§ ª«¥â®ª ¤«ï  â ª¨
 
if use_new_logic
check_freedom:
; mov esi,table1
push ax
push word 100
xor eax,eax
mov ebx,0x900
 
.1: bts [flags],6
call find_near
jc .11
cmp byte [esi+eax],2 ;0
jb @f
.11: inc bl
 
@@: cmp al,10 ;-10
jb @f
push ax
 
sub al,10
if use_ext_logic
bts [flags],6
call find_near
jc .21
endf
cmp byte [esi+eax],2
jb .22
.21: inc bl
.22: pop ax
 
@@: cmp al,11
jb @f
push ax
 
xor edx,edx
mov ecx,10
push ax
div cx
pop ax
 
cmp dx,0
je .32
 
sub al,11
if use_ext_logic
bts [flags],6
call find_near
jc .31
endf
cmp byte [esi+eax],2 ;-11
jb .32
.31: inc bl
.32: pop ax
 
@@: cmp al,9
jb @f
push ax
 
xor edx,edx
mov ecx,10
push ax
div cx
pop ax
cmp dx,9
je .42
 
sub eax,9
if use_ext_logic
bts [flags],6
call find_near
jc .41
endf
cmp byte [esi+eax],2 ;-9
jb .42
.41: inc bl
.42: pop ax
 
@@: cmp al,1
jb @f
push ax
 
xor edx,edx
mov ecx,10
push ax
div cx
pop ax
cmp dx,0
je .52
 
dec al
if use_ext_logic
bts [flags],6
call find_near
jc .51
endf
cmp byte [esi+eax],2 ;-1
jb .52
.51: inc bl
.52: pop ax
 
@@: cmp al,99
jg @f
push ax
 
xor edx,edx
mov ecx,10
push ax
div cx
pop ax
cmp dx,9
je .62
 
inc al
if use_ext_logic
bts [flags],6
call find_near
jc .61
endf
cmp byte [esi+eax],2 ;+1
jb .62
.61: inc bl
.62: pop ax
 
@@: cmp al,90
jge @f
push ax
add al,10
if use_ext_logic
bts [flags],6
call find_near
jc .71
endf
cmp byte [esi+eax],2 ;+10
jb .72
.71: inc bl
.72: pop ax
 
@@: cmp al,91
jge @f
push ax
xor edx,edx
mov ecx,10
push ax
div cx
pop ax
cmp dx,0
je .82
 
add al,9
if use_ext_logic
bts [flags],6
call find_near
jc .81
endf
cmp byte [esi+eax],2 ;+9
jb .82
.81: inc bl
.82: pop ax
 
@@: cmp al,89
jge @f
push ax
 
xor edx,edx
mov ecx,10
push ax
div cx
pop ax
 
cmp dx,9
je .92
 
add al,11
if use_ext_logic
bts [flags],6
call find_near
jc .91
endf
cmp byte [esi+eax],2 ;+11
jb .92
.91: inc bl
.92: pop ax
 
@@: bt [flags],7
jc .ret
cmp byte [esi+eax],1
jg @f
cmp bl,bh
jg @f
 
; shl ebx,8
bts [flags],6
call find_near
; xchg cl,bl
; shr ebx,8
; test cl,cl
; jnz @f
jc @f
 
shl bx,8
pop dx ;dh - ¡«¨¦ ©è ï á«¥¢  ᢮¡®¤­¥©è ï ª«¥âª , dl - á¯à ¢ 
pop cx ;cl - à ­¤®¬­® ¢ë¡à ­­ ï ª«¥âª 
; cmp al,dl
; jg .5
; cmp al,cl
; jb .4
; mov dl,al
; jmp .5
;.4: cmp al,dh
; jb .5
; mov dh,al
cmp al,dh
jb .5
cmp al,cl
jg .4
mov dh,al
jmp .5
.4: cmp al,dl
jg .5
mov dl,al
.5: push cx dx
@@: xor bl,bl
inc al
cmp al,100
jb .1
pop dx ax
 
if DEBUG
dbg_dec eax
dbg_dec edx
endf
cmp dl,100
jb @f
mov al,dh
ret
@@: mov al,dh
push dx
bts [flags],7
call .1
shl bx,8
mov al,[esp]
call .1
pop dx
btr [flags],7
mov al,dl
test bl,bh
jbe .ret
mov al,dh
.ret:
ret
 
endf
 
 
 
 
 
 
 
align 4
rsx1 dw ?;0x4321
rsx2 dw ?;0x1234
random: ; ¨§ ASCL
push ecx edx esi
mov cx,ax
mov ax,[rsx1]
mov bx,[rsx2]
mov si,ax
mov di,bx
mov dl,ah
mov ah,al
mov al,bh
mov bh,bl
xor bl,bl
rcr dl,1
rcr ax,1
rcr bx,1
add bx,di
adc ax,si
add bx,0x62e9
adc ax,0x3619
mov [rsx1],bx
mov [rsx2],ax
xor dx,dx
cmp ax,0
je nodiv
cmp cx,0
je nodiv
div cx
nodiv:
mov ax,dx
pop esi edx ecx
and eax,0000ffffh
ret
 
 
if DEBUG
SysMsgBoardNum: ;warning: destroys eax,ebx,ecx,esi
mov ebx,esp
mov ecx,8
mov esi,(number_to_out+1)
.1:
mov eax,ebx
and eax,0xF
cmp al,10
sbb al,69h
das
mov [esi+ecx],al
shr ebx,4
loop .1
dec esi
mcall 71,1,number_to_out
ret
 
number_to_out db '0x00000000',13,10,0
endf
 
 
 
 
text_cpu db 'CPU',0
text_user db 'USER',0
if lang eq ru
title db 'Œ®à᪮© ¡®© 0.4',0
but_auto db ' ááâ ¢¨âì',0
but_new db '®¢ ï',0
text_win db '‚먣ࠫ!',0
else
title db 'Sea war 0.4',0
but_auto db 'Auto fill',0
but_new db 'New',0
text_win db 'Won!',0
endf
 
I_END:
; t1,t3,t5: 0-­¥¯®¬¥ç¥­­ ï ª«¥â®çª , 1-§ ­ïâ ï, 2-"¯à®¬ å", 3-"£®à¨â", 4-"¯®â®¯«¥­"
; t2,t4: â ¡«¨æë à á¯®«®¦¥­¨ï í«¥¬¥­â®¢, 1 í«¥¬¥­â ¯® 4 ª«¥âª¨, 2x3, 3x2, 4x1
align 16
table1 rb 100 ;«¥¢®¥ ¯®«¥
table3 rb 20
table2 rb 100 ;¯à ¢®¥
table4 rb 20
table5 rb 100
u_kill rb 1
c_kill rb 1
p_pov rb 1
smeshenie rb 1
number_bots rb 1
oX rb 1
oY rb 1
tbl_ranen rb 4
 
flags rw 1
flags2 rw 1
;¡¨â 0: 0/1 - § ¯®«­¥­¨¥ â ¡«¨æ /¨£à 
;1: ­ ¦ â  «¥¢ ï ª­®¯ª  ¬ëè¨ (¢¥à⨪ «ì) /¯à ¢ ï (£®à¨§®­â «ì)
;2: § ¯®«­ï¥âáï «¥¢®¥ ¯®«¥ /¯à ¢®¥
;3: àãç­®¥ § ¯®«­¥­¨¥ / ¢â®§ ¯®«­¥­¨¥
;4: ¢ .three - ¯®â®¯«¥­­ë© ª®à ¡«ì
;5: ¨£à  ®ª®­ç¥­ 
;6: ¢ second_pole - ¢ë§®¢ find_near
;7: ¢ check_freedom
;8: § à¥§¥à¢¨à®¢ ­®
;9: § à¥§¥à¢¨à®¢ ­®
;10: § à¥§¥à¢¨à®¢ ­®
/programs/games/sw/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/games/sw
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property