Pong: Fix title (score), whitespace changes.

git-svn-id: svn://kolibrios.org@6024 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2016-01-02 12:24:25 +00:00
parent e48064d090
commit 8f4ba7ce29
2 changed files with 251 additions and 266 deletions

View File

@ -89,44 +89,44 @@ _1dbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{ {
local bounce,exit,anot,bc,nbc local bounce,exit,anot,bc,nbc
mov esi,[img1_off] ;xs1 mov esi, dword[img1_off] ;xs1
mov edi,[img2_off] ;ys2 mov edi, dword[img2_off] ;ys2
mov eax,x1 ; mov eax, x1 ;
mov ebx,x2 ; mov ebx, x2 ;
call _1dbounce call _1dbounce
mov edx,ecx mov edx,ecx
mov esi,[img1_off+4] ;ys1 mov esi, dword[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2 mov edi, dword[img2_off+4] ;ys2
mov eax,y1 ; mov eax, y1 ;
mov ebx,y2 ; mov ebx, y2 ;
call _1dbounce call _1dbounce
add edx,ecx add edx, ecx
cmp edx,2 cmp edx, 2
je bounce je bounce
mov otv,0 mov otv, 0
jmp exit jmp exit
_1dbounce_count=_1dbounce_count+1 _1dbounce_count=_1dbounce_count+1
if (_1dbounce_count = 1) if (_1dbounce_count = 1)
_1dbounce: _1dbounce:
cmp ebx,eax cmp ebx,eax
jnae anot jnae anot
add eax,esi add eax,esi
cmp eax,ebx cmp eax,ebx
jna nbc jna nbc
jmp bc jmp bc
anot: anot:
add ebx,edi add ebx,edi
cmp ebx,eax cmp ebx,eax
jna nbc jna nbc
bc: bc:
mov ecx,1 mov ecx,1
ret ret
nbc: nbc:
mov ecx,0 mov ecx,0
ret ret
end if end if
bounce: bounce:
mov otv,1 mov otv,1
exit: exit:
} }
@ -316,14 +316,14 @@ local noaddword
yespicsize: yespicsize:
mov eax,bmp_load_area mov eax,bmp_load_area
mov ebx,eax mov ebx,eax
add ebx, [bmp_load_area+2];file size add ebx, dword[bmp_load_area+2];file size
inc ebx inc ebx
mov dword [bmp_soi],ebx ;soi-start of image area for drawing mov dword [bmp_soi],ebx ;soi-start of image area for drawing
add eax, [bmp_load_area+10] add eax, dword[bmp_load_area+10]
mov dword [sop],eax ;sop-start of picture in file mov dword [sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34] add eax, dword[bmp_load_area+34]
mov dword [eop],eax ;eop-end of picture in file mov dword [eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18] mov eax, dword[bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax lea eax,[eax+2*eax] ;3x pixels in eax
mov edi,dword [bmp_soi] ;initializing mov edi,dword [bmp_soi] ;initializing
@ -341,9 +341,9 @@ local noaddword
rep movsd rep movsd
convert1: convert1:
pop edi pop edi
sub esi,dword [bps] sub esi, dword[bps]
sub esi,dword [bps] sub esi, dword[bps]
cmp esi,dword [sop] cmp esi, dword[sop]
jb end_bmp;nomorestring jb end_bmp;nomorestring
add edi,eax add edi,eax
jmp nextstring jmp nextstring
@ -353,10 +353,10 @@ local noaddword
convertno32: convertno32:
mov ebx,bmp_load_area mov ebx,bmp_load_area
add ebx, [bmp_load_area+14] add ebx, dword[bmp_load_area+14]
add ebx,14 ;start of color table add ebx,14 ;start of color table
push esi push esi
add esi,dword [bps] add esi, dword[bps]
mov dword [eos],esi mov dword [eos],esi
pop esi pop esi
nextelem: nextelem:

View File

@ -5,6 +5,8 @@
; Not use bmpfile! ; Not use bmpfile!
;****************************************************************************** ;******************************************************************************
format binary as ""
use32 use32
org 0x0 org 0x0
db 'MENUET01' ; 8 byte id db 'MENUET01' ; 8 byte id
@ -13,7 +15,7 @@
dd IM_END ; size of image dd IM_END ; size of image
dd 0x300000 ; memory for app dd 0x300000 ; memory for app
dd 0x300000 ; esp dd 0x300000 ; esp
dd temp_area , 0x0 ; I_Param , I_Icon dd temp_area, 0x0 ; I_Param , I_Path
;****************************************************************************** ;******************************************************************************
@ -24,341 +26,324 @@ include 'ascgml.inc'
START: ; start of execution START: ; start of execution
call draw_window call draw_window
; loadbmp '/RD/1/PONG.BMP',temp_area,I_END,tsoi
convbmp pongfile,tsoi
bmptoimg pongfile,tsoi,pong
getimg pong,0,0,80,4,img
getimg pong,0,4,80,4,img2
getimg pong,5,38,15,15,img3
getimg pong,0,8,80,20,img5
fullimg img4 , 80 ,20 ,0x00000000 ;black for rocket
fullimg img6 , 15 ,15 ,0x00000000 ;black for ball
convbmp pongfile, tsoi
bmptoimg pongfile, tsoi,pong
getimg pong, 0, 0, 80, 4, img
getimg pong, 0, 4, 80, 4, img2
getimg pong, 5, 38, 15, 15, img3
getimg pong, 0, 8, 80, 20, img5
fullimg img4, 80 ,20 ,0x00000000 ;black for rocket
fullimg img6, 15 ,15 ,0x00000000 ;black for ball
still: still:
scevent red,key,button
scevent red,key,button ;mcall 48, 4 ;get skin width
;sub [skin_h], 16
;div eax, 2
;mov [skin_h], eax
;mcall 48, 4 ;get skin width outcount [scoreb], 300, 4, 0x10000000 + cl_Blue, 5 shl 16
;sub [skin_h], 16 outcount [scorea], 350, 4, 0x10000000 + cl_Red, 5 shl 16
;div eax, 2
;mov [skin_h], eax
outcount dword [scoreb],300,8,cl_Blue,5*65536
outcount dword [scorea],350,8,cl_Red,5*65536
del_images: del_images:
setimg dword [ply1x],dword [ply1y],img4 setimg [ply1x], [ply1y], img4
setimg dword [ply2x],dword [ply2y],img4 setimg [ply2x], [ply2y], img4
setimg dword [ballx],dword [bally],img6 setimg [ballx], [bally], img6
setimg dword [gravx],dword [gravy],img4 setimg [gravx], [gravy], img4
move_ply1: move_ply1:
correct [ply1x], [ply1rx], 4
correct [ply1y], [ply1ry], 2
correct [ply1x],[ply1rx],4 ; automove ball
correct [ply1y],[ply1ry],2 mov eax, [ballxv]
add [ballx], eax
;automove ball mov eax, [ballyv]
mov eax,dword [ballxv] add [bally], eax
add dword [ballx],eax
mov eax,dword [ballyv]
add dword [bally],eax
;autoslow ball ;autoslow ball
cmp dword [ballxv],0 cmp [ballxv], 0
jl ballb jl ballb
balla: balla:
cmp dword [ballxv],2 cmp [ballxv], 2
jng balln jng balln
dec dword [ballxv] dec [ballxv]
jmp balln jmp balln
ballb: ballb:
cmp dword [ballxv],-2 cmp [ballxv], -2
jnl balln jnl balln
inc dword [ballxv] inc [ballxv]
jmp balln jmp balln
balln: balln:
cmp dword [ballyv],2 cmp [ballyv], 2
jng by_n jng by_n
dec dword [ballyv] dec [ballyv]
by_n: by_n:
;ball collusion of screen ;ball collusion of screen
cmp dword [ballx],640-32 cmp [ballx], 640-32
jna xa_ok jna xa_ok
neg dword [ballxv] neg [ballxv]
xa_ok: xa_ok:
cmp dword [ballx],6 cmp [ballx], 6
jnb xb_ok jnb xb_ok
neg dword [ballxv] neg [ballxv]
xb_ok: xb_ok:
;if ball far out of screen come back ;if ball far out of screen come back
; is not work already ; is not work already
cmp dword [bally],466 cmp [bally], 466
jng yax_ok jng yax_ok
call draw_window call draw_window
inc dword [scoreb] inc [scoreb]
mov dword [bally],240 mov [bally], 240
mov dword [ballx],310 mov [ballx], 310
mov dword [ballyv],2 mov [ballyv], 2
random 5,dword [ballxv] random 5, [ballxv]
sub dword [ballxv],2 sub [ballxv], 2
yax_ok: yax_ok:
cmp dword [bally],30 cmp [bally], 30
jnl yax_ok2 jnl yax_ok2
call draw_window call draw_window
inc dword [scorea] inc [scorea]
mov dword [bally],240 mov [bally], 240
mov dword [ballx],310 mov [ballx], 310
mov dword [ballyv],2 mov [ballyv], 2
random 5,dword [ballxv] random 5, [ballxv]
sub dword [ballxv],2 sub [ballxv], 2
yax_ok2: yax_ok2:
xorx: xorx:
cmp dword [ballxv],0 cmp [ballxv], 0
jne norx jne norx
random 5,dword [ballxv] random 5, [ballxv]
sub dword [ballxv],2 sub [ballxv], 2
cmp dword [ballxv],0 cmp [ballxv], 0
je xorx je xorx
norx: norx:
;test on collusion ply1 of ball ;test on collusion ply1 of ball
collusion_test: collusion_test:
collimg img,[ply1x],[ply1y],img3,[ballx],[bally],eax collimg img, [ply1x], [ply1y], img3, [ballx], [bally], eax
cmp eax,1 cmp eax, 1
jne not_coll jne not_coll
neg dword [ballyv] neg [ballyv]
add dword [bally],4 add [bally], 4
; neg dword [ballxv] ; neg [ballxv]
not_coll: not_coll:
;test on collusion com of ball ;test on collusion com of ball
collusion_com: collusion_com:
collimg img,[ply2x],[ply2y],img3,[ballx],[bally],eax collimg img, [ply2x], [ply2y], img3, [ballx], [bally], eax
cmp eax,1 cmp eax, 1
jne not_collcom jne not_collcom
neg dword [ballyv] neg [ballyv]
sub dword [bally],4 sub [bally], 4
; neg dword [ballxv] ; neg dword [ballxv]
not_collcom: not_collcom:
;test on collusion gravity of ball ;test on collusion gravity of ball
collusion_grav: collusion_grav:
collimg img,[gravx],[gravy],img3,[ballx],[bally],eax collimg img, [gravx], [gravy], img3, [ballx], [bally], eax
cmp eax,1 cmp eax, 1
jne not_collg jne not_collg
neg dword [ballyv] neg [ballyv]
; mov dword [ballxv],-20 ; mov [ballxv], -20
cmp dword [ballyv],0 cmp [ballyv], 0
jl ab jl ab
jg bf jg bf
jmp not_collgx jmp not_collgx
ab: ab:
sub dword [ballyv],25 sub [ballyv], 25
jmp not_collgx jmp not_collgx
bf: bf:
add dword [ballyv],25 add [ballyv], 25
not_collgx: not_collgx:
cmp dword [ballxv],0 cmp [ballxv], 0
jl abx jl abx
jg bfx jg bfx
jmp not_collg jmp not_collg
abx: abx:
sub dword [ballxv],8 ;15 sub [ballxv], 8 ;15
jmp not_collg jmp not_collg
bfx: bfx:
add dword [ballxv],8 add [ballxv], 8
; mov dword [ballyv],20 ; mov [ballyv], 20
not_collg: not_collg:
;ply contorl ;ply contorl
cmp dword [ply1rx],560 cmp [ply1rx], 560
jna plyok jna plyok
cmp dword [ply1rx],12000 cmp [ply1rx], 12000
jna paa jna paa
mov dword [ply1rx],4 mov [ply1rx], 4
jmp plyok jmp plyok
paa: paa:
mov dword [ply1rx],560 mov [ply1rx], 560
plyok: plyok:
;com contorl ;com contorl
cmp dword [ply2x],560 cmp [ply2x], 560
jna cplyok jna cplyok
cmp dword [ply2x],12000 cmp [ply2x], 12000
jna cpaa jna cpaa
mov dword [ply2x],4 mov [ply2x], 4
jmp cplyok jmp cplyok
cpaa: cpaa:
mov dword [ply2x],560 mov [ply2x], 560
cplyok: cplyok:
;com move ;com move
cx_move: cx_move:
cmp dword [bally],160 cmp [bally], 160
jna cno_m jna cno_m
mov eax,dword [ballx] mov eax, [ballx]
sub eax,30 sub eax, 30
cmp dword [ply2x],eax cmp [ply2x], eax
je cno_m je cno_m
cmp dword [ply2x],eax cmp [ply2x], eax
ja cm_m ja cm_m
cm_p: cm_p:
add dword [ply2x],3 add [ply2x], 3
jmp cno_m jmp cno_m
cm_m: cm_m:
sub dword [ply2x],3 sub [ply2x], 3
cno_m: cno_m:
;garvity ;garvity
gravity: gravity:
cmp dword [gravtime],0 cmp [gravtime], 0
je no_dg je no_dg
dec dword [gravtime] dec [gravtime]
no_dg: no_dg:
draw_gravity: draw_gravity:
cmp dword [gravtime],0 cmp [gravtime], 0
je nograv je nograv
mov eax,dword [ply1x] mov eax, [ply1x]
mov ebx,dword [ply1y] mov ebx, [ply1y]
add ebx,10 add ebx, 10
mov dword [gravx],eax mov [gravx], eax
mov dword [gravy],ebx mov [gravy], ebx
jmp endgrav jmp endgrav
nograv: nograv:
mov dword [gravx],1000 mov [gravx], 1000
mov dword [gravy],1000 mov [gravy], 1000
endgrav: endgrav:
redraw_images: redraw_images:
setimg dword [ply1x],dword [ply1y],img setimg [ply1x], [ply1y], img
setimg dword [ply2x],dword [ply2y],img2 ;2 setimg [ply2x], [ply2y], img2
setimg dword [ballx],dword [bally],img3 setimg [ballx], [bally], img3
setimg dword [gravx],dword [gravy],img5 setimg [gravx], [gravy], img5
delay 1 ;don't generate delay for fast speed programm
delay 1 ;don't generate delay for fast speed programm jmp still
jmp still
red: red:
call draw_window call draw_window
jmp still jmp still
key: ; key key: ; key
mov eax,2 mov eax, 2
mcall mcall
cmp ah,key_Left cmp ah, key_Left
jne no_l jne no_l
sub dword [ply1rx],32 ;16 sub [ply1rx], 32 ;16
no_l: no_l:
cmp ah,key_Right cmp ah, key_Right
jne no_r jne no_r
add dword [ply1rx],32 ;16 add [ply1rx], 32 ;16
no_r: no_r:
cmp ah,key_Up cmp ah, key_Up
jne no_u jne no_u
sub dword [ply1ry],16 sub [ply1ry], 16
no_u: no_u:
cmp ah,key_Down cmp ah, key_Down
jne no_d jne no_d
add dword [ply1ry],16 add [ply1ry], 16
no_d: no_d:
cmp ah,key_Space cmp ah, key_Space
jne no_sp jne no_sp
mov dword [gravtime],100 mov [gravtime], 100
no_sp: no_sp:
jmp still jmp still
button: ; button button: ; button
mov eax,17 ; get id mov eax, 17 ; get id
mcall mcall
cmp ah,1 ; button id=1 ? cmp ah, 1 ; button id=1 ?
jne noclose jne noclose
mov eax,-1 ; close this program mov eax, -1 ; close this program
mcall mcall
noclose: noclose:
jmp still jmp still
draw_window: draw_window:
mcall 12,1 ;start window redraw mcall 12,1 ;start window redraw
mcall 0, <10, 640+8>, <10, 480+24>, 0x14000000,, wtitle mcall 0, <10, 640+8>, <10, 480+24>, 0x14000000,, wtitle
mcall 12,2 ;end window redraw mcall 12,2 ;end window redraw
ret ret
; DATA AREA ; DATA AREA
wtitle db 'PONG: USE ARROW KEYS SCORE:',0 wtitle db 'PONG: USE ARROW KEYS SCORE:',0
;skin_h dd 25 ;skin_h dd 25
xt dd 100 xt dd 100
yt dd 100 yt dd 100
gravtime dd 10 gravtime dd 10
gravx dd 1000 gravx dd 1000
gravy dd 1000 gravy dd 1000
ply1rx dd 200 ply1rx dd 200
ply1ry dd 50 ply1ry dd 50
ply1x dd 200 ply1x dd 200
ply1y dd 50 ply1y dd 50
ply2x dd 200 ply2x dd 200
ply2y dd 400 ply2y dd 400
ballx dd 200 ballx dd 200
bally dd 200 bally dd 200
ballyv dd 3 ballyv dd 3
ballxv dd 3 ballxv dd 3
scorea dd 0 scorea dd 0
scoreb dd 0 scoreb dd 0
counter dd 0 counter dd 0
tsoi dd 0 tsoi dd 0
pongfile: pongfile file 'pong.bmp'
file 'pong.bmp'
IM_END: IM_END:
temp: temp rb 20000
rb 20000
pong: pong rb 80*60*3+8
rb 80*60*3+8 img rb 32*32*3+8
img: img2 rb 32*32*3+8
rb 32*32*3+8 img3 rb 32*32*3+8
img2: img4 rb 80*20*3+8
rb 32*32*3+8 img5 rb 32*32*3+8
img3: img6 rb 15*15*3+8
rb 32*32*3+8
img4:
rb 80*20*3+8
img5:
rb 32*32*3+8
img6:
rb 15*15*3+8
temp_area: temp_area rb 0x15000
rb 0x15000
I_END: I_END: