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