Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 30 → Rev 31

/programs/phenix/trunk/ascgl.inc
0,0 → 1,1385
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by halyavin, add at ~07.06.2004
;0.11 many macros optimized by halyavin, add at ~30.08.2004
;0.12 bmptoimg ~07.09.2004
;0.13 imgtoimg ~08.09.2004
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
;0.15 giftoimg, giftoani ~10.09.2004
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
 
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aframetoimg_use_count=aframetoimg_use_count+1
if aframetoimg_use_count = 1
 
jmp end_aframetoimg_proc
 
acolor dd 0
aframetoimg_proc:
;getout coord
mov [acolor],ebp
 
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aframetoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aframetoimg_proc
}
 
frametoimg_use_count=0
macro frametoimg img, x, y, canvas
{
local loo,loo2
frametoimg_use_count=frametoimg_use_count+1
if frametoimg_use_count = 1
 
jmp end_frametoimg_proc
 
frametoimg_proc:
;getout coord
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
 
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_frametoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call frametoimg_proc
}
 
 
aimgtoimg_use_count=0
macro aimgtoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aimgtoimg_use_count=aimgtoimg_use_count+1
if aimgtoimg_use_count = 1
 
jmp end_aimgtoimg_proc
 
acolor dd 0
aimgtoimg_proc:
;getout coord
mov [acolor],ebp
 
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
 
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aimgtoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aimgtoimg_proc
}
 
 
 
 
imgtoimg_use_count=0
macro imgtoimg img, x, y, canvas
{
local loo,loo2
imgtoimg_use_count=imgtoimg_use_count+1
if imgtoimg_use_count = 1
 
jmp end_imgtoimg_proc
imgtoimg_proc:
;getout coord
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_imgtoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call imgtoimg_proc
}
 
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
wordstoreg ebx,x,xs ;x*65536+xs
wordstoreg ecx,y,ys ;y*65536+ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,[fps_cntr]
mov [fps],ebx
mov [fps_cntr],0
out_fps:
if ~(delcolor eq )
mov ebx,x*65536+30
mov ecx,y*65536+7
mov edx,delcolor
mov eax,13
int 0x40
end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,5*65536
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
int 0x40
no_out_fps:
}
 
; COLLIMG - Collusion image's
_1dbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{
local bounce,exit,anot,bc,nbc
mov esi,[img1_off] ;xs1
mov edi,[img2_off] ;ys2
mov eax,x1 ;
mov ebx,x2 ;
call _1dbounce
mov edx,ecx
mov esi,[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2
mov eax,y1 ;
mov ebx,y2 ;
call _1dbounce
add edx,ecx
cmp edx,2
je bounce
mov otv,0
jmp exit
_1dbounce_count=_1dbounce_count+1
if _1dbounce_count = 1
_1dbounce:
cmp ebx,eax
jb anot
add eax,esi
cmp eax,ebx
jbe nbc
bc:
mov ecx,1
ret
anot:
add ebx,edi
cmp ebx,eax
ja bc
nbc:
xor ecx,ecx
ret
end if
bounce:
mov otv,1
exit:
}
 
macro rgbtobgr image
{
local loo
mov eax,[image]
mul dword [image+4]
mov ecx,eax
mov esi,image+8
; add esi,8
loo:
mov al,[esi]
mov bl,[esi+2]
mov [esi],bl
mov [esi+2],al
add esi,3
dec ecx
jnz loo
}
 
 
macro setimg x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
mov cx,[arg3]
shl ecx,16
add cx,[arg3+4]
; wordstoreg ecx,[arg3],[arg3+4]
wordstoreg edx, x , y ;arg1*65536+arg2
int 0x40
}
 
macro setframe x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
wordstoreg edx, x , y ;arg1*65536+arg2
add edx,dword [arg3]
mov ecx,dword [arg3+4]
int 0x40
}
 
 
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
if xs eqtype 0
mov dword [imgdest],xs
else
mov eax,xs
mov dword [imgdest],eax
end if
if ys eqtype 0
mov dword [imgdest+4],ys
else
mov eax,ys
mov dword [imgdest+4],eax
end if
 
mov eax,dword [imgsrc] ;getx size
; lea ecx,[eax+2*eax]
mov ecx,eax
shl ecx,1
add ecx,eax
 
mov ebx,y
mul ebx
add eax,x
mov edx,ecx
lea eax,[eax+2*eax] ;eax=offset on imsrc
; mov ebp,eax
; shl eax,1
; add eax,ebp
 
mov ecx,xs
mov ebx,ys
 
mov edi,8+imgdest
lea esi,[eax+8+imgsrc]
; mov esi,eax
; add esi,8
; add esi,imgsrc
 
cld
cyc:
movsw
movsb
dec ecx
jne cyc
add esi,edx
mov ecx,xs
sub esi,ecx
sub esi,ecx
sub esi,ecx
dec ebx
jne cyc
}
 
macro copyimg img2_off,img1_off
{
mov eax,dword [img1_off]
mov ebx,dword [img1_off+4]
mul ebx
lea ecx,[eax+2*eax]
lea esi,[img1_off+8]
lea edi,[img2_off+8]
cld
rep movsb
}
 
macro fullimg img_off,xs,ys,color
{
local cop
mov eax,xs
mov ebx,ys
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ebp,[eax+2*eax]
mov esi,color
if color eqtype 0
mov ecx,color/65536
else
mov ecx,esi
shr ecx,16
end if
xor edi,edi
cop:
mov word [img_off+8+edi],si
add edi,2
mov byte [img_off+8+edi],cl
inc edi
cmp edi,ebp
jne cop
}
 
 
 
; number of frame in ecx
; callculatin offset of raw data
 
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
{
local loo,setpic
mov ebp,num_of_frame ;ecx
mov esi,offset_of_animation;Image
loo:
cmp ebp,0
je setpic
movzx eax,word [esi+4]
movzx ebx,word [esi+6]
mul ebx ;dword [esi+4]
mov ebx,3
mul ebx
add eax,8
add esi,eax
dec ebp
jmp loo
setpic:
mov dword offset_of_frame,esi
}
 
 
; BMPTOIMG -Convert BMP format TO IMG format
; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset
; (SAMPLE) View BMPLS.ASM sample.
; ( NOTE ) This is macros is not brake bmp structure! Tested in 32,8,4 bits
 
 
bmptoimg_data_area_count=0
macro bmptoimg bmp_load_area,img_dest_area
{
local fileinfo,string,end_bmp,nodix
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
;local qwe,bmpfn
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
add eax,31
shr eax,5
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov ebp,img_dest_area+8
 
mov eax,bmp_load_area
mov ebx,eax
add ebx, [bmp_load_area+2];file size
inc ebx
mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing
 
add eax, [bmp_load_area+10]
mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax
 
mov edi,dword [bmptoimg_soi] ;initializing
mov esi,dword [bmptoimg_data_area_eop]
sub esi,dword [bmptoimg_data_area_bps]
 
 
nextstring:
push edi
push ebp
cmp word [bmp_load_area+28],24
jne convertno32
 
mov edi,ebp
mov ecx,[bmptoimg_data_area_dwps]
cld
rep movsd
 
convert1:
pop ebp
pop edi
sub esi,dword [bmptoimg_data_area_bps]
sub esi,dword [bmptoimg_data_area_bps]
cmp esi,dword [bmptoimg_data_area_sop]
jb end_bmp
add edi,eax
add ebp,eax
jmp nextstring
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bmptoimg_data_area_bps]
mov dword [bmptoimg_data_area_eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
 
convert2:
pop eax
inc esi
cmp esi,dword [bmptoimg_data_area_eos]
jae convert1
add edi,3
 
add ebp,3
 
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
 
add ebp,3
 
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
js convert2
add edi,3
 
add ebp,3
 
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
; mov dword [edi],edx
mov [ebp],edx
ret
 
bmptoimg_data_area_count=bmptoimg_data_area_count+1
if bmptoimg_data_area_count = 1
; DATA AREA
bmptoimg_soi dd 0
bmptoimg_data_area_bps dd 0
bmptoimg_data_area_dwps dd 0
bmptoimg_data_area_sop dd 0
bmptoimg_data_area_eop dd 0
bmptoimg_data_area_eos dd 0
end if
 
end_bmp:
mov eax,dword [bmp_load_area+18]
mov ebx,dword [bmp_load_area+22]
mov dword [img_dest_area],eax
mov dword [img_dest_area+4],ebx
}
 
; For convert RGB to BGR
COLOR_ORDER equ MENUETOS
 
macro giftoani gifsrc,imgsrc,num_of_frames
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null equ 0x1000 ; 0x1000
 
; jmp sss
; if defined gif_hash_offset
; else
; hasharea:
; times 4096 dd 0 ;4096
; end if
;sss:
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
push ecx
pop dword num_of_frames
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
movsd
movsd
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
cmp byte[edi],0x3b ;read next frame
jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
 
 
macro giftoimg gifsrc,imgsrc
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null fix 0x1000 ; 0x1000
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
; movsd
; movsd
 
mov bp,word[esi+4]
movzx ebx,bp
mov [edi],ebx
 
mov bp,word[esi+6]
movzx ebx,bp
mov [edi+4],ebx
 
add edi,8
add esi,8
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
; cmp byte[edi],0x3b ;read next frame
; jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/phenix/trunk/ascgml.inc
0,0 → 1,49
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; GaMe
; Libary
;
; Ver 0.03 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 correct
;0.02 control ~14.05.2004
;0.03 all macros optimized by halyavin, add at ~07.06.2004
 
 
; corectiryemoe,corectnoe,step
macro correct arg1,arg2,arg3
{
local plus,minus,equal
mov eax,arg2
cmp arg1,eax
je equal
mov eax,arg3
ja minus
plus:
add arg1,eax
jmp equal
minus:
sub arg1,eax
equal:
}
 
macro control min,max,arg
{
local gr,low,norm
mov eax,max
cmp arg,eax
jg gr
mov eax,min
cmp arg,eax
jnl norm
gr:
low:
mov arg,eax
norm:
}
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/phenix/trunk/ascl.inc
0,0 → 1,895
;lang equ ru ; ru en fr ge fi
 
;
; Assembler
; SMALL
; CODE
; Libary
;
; Ver 0.14 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;Please compile aplications on FASM ver1.54 or higer!!!
 
;InfoList
;0.01 scank,putpix,puttxt
;0.02 label,random,colors
;0.03 window,startwd,endwd,attributes
;0.04 close,delay,scevent ~30.04.2004
;0.05 small random, ~04.05.2004
;0.06 wtevent ~09.05.2004
;0.07 timeevent ~23.05.2004
;0.08 txtput ~14.06.2004
;0.09 opendialog,savedialog ~20.06.2004
;0.10 wordstoreg by halyavin, add at ~30.08.2004
; random bug deleted eax is use.
;0.11 loadfile from me +puttxt bug del ~07.09.2004
;0.12 open/save dialog ~13.09.2004
;0.13 dialogs bugs deleted
;0.14 drawlbut ~03.10.2004
;0.15 extendet label!
 
; LOADFILE
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area
 
 
macro loadfile file_name,file_load_area,file_temp_area
{
local open,fileinfo,string
jmp open
fileinfo:
dd 0
dd 0
dd 1
dd file_load_area
dd file_temp_area
string:
db file_name,0
open:
mov dword [fileinfo+8],1 ; how many blocks to read (1)
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[file_load_area+2]
shr eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
}
 
 
macro wordstoreg reg,hiword,loword
{
if hiword eqtype 0 & loword eqtype 0
mov reg,dword (hiword)*65536+(loword)
else if hiword eqtype 12 & loword eqtype eax
mov reg,dword (hiword)*65536
add reg,dword loword
else if hiword eqtype 12 & loword eqtype [123]
mov reg,dword (hiword)*65536
add reg,dword loword
else
mov reg,dword hiword
shl reg,16
add reg,dword loword
end if
}
 
 
 
macro dword2reg reg,doubleword
{
if doubleword eq
; not changes
else
mov reg,dword doubleword
end if
}
 
macro words2reg reg,hiword,lowword
{
if hiword eq
if lowword eq
; not changes
else
if lowword eqtype 12
and reg,dword 0xffff0000
add reg,dword lowword
else
and reg,dword 0xffff0000
add reg,dword lowword
end if
end if
else
if lowword eq
if hiword eqtype 12
and reg,dword 0x0000ffff
add reg,dword hiword*65536
else
shl reg,16
add reg,dword hiword
ror reg,16
end if
else
if lowword eqtype 12 & hiword eqtype 12
if lowword eq 0 & hiword eq 0
xor reg,reg
else
mov reg,dword hiword*65536+lowword
end if
else
mov reg,dword hiword
shl reg,16
add reg,dword lowword
end if
end if
end if
}
 
 
 
 
; DRAW BUTTON with label
 
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
{
local asd,lab
jmp asd
lab db text ;arg label
asd:
words2reg ebx,x,xs
words2reg ecx,y,ys
mov edx,id
mov esi,bcolor
mov eax,8
int 0x40
 
mov eax,asd-lab ;calc size
mov ebx,6
mul ebx
mov esi,eax
 
mov eax,xs
sub eax,esi
shr eax,1
add eax,x
 
mov edx,ys
sub edx,7
shr edx,1
add edx,y
 
mov ebx,eax
shl ebx,16
add ebx,edx
 
mov ecx,tcolor ;arg4 color
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
 
macro opendialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo ; 0x10000
;run_filepath
db '/RD/1/SYSXTREE',0
 
procinfo:
times 256 db 0
}
 
 
macro savedialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, run_filepath, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,120 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
rb 4 ; My dec PID
rb 6 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo
run_filepath:
db '/RD/1/SYSXTREE',0
 
procinfo:
times 256 db 0
}
 
 
 
 
; RANDOM - generate random count (small)
; (SYNTAX) RANDOM MaxCount,OutArgument
; (SAMPLE) RANDOM 10000,eax
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations
 
randomuse = 0
 
macro random arg1,arg2
{
local rxproc
randomuse = randomuse + 1
 
jmp rxproc
 
if defined randomuse & randomuse = 1
randomproc:
jmp rnj
rsx1 dw 0x4321
rsx2 dw 0x1234
rnj:
; mov eax,arg1
push bx
push cx
push dx
push si
push di
mov cx,ax
mov ax,word ptr rsx1
mov bx,word ptr 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 word ptr rsx1,bx
mov word ptr rsx2,ax
xor dx,dx
cmp ax,0
je nodiv
cmp cx,0
je nodiv
div cx
nodiv:
mov ax,dx
pop di
pop si
pop dx
pop cx
pop bx
and eax,0000ffffh
; mov arg2,0
; mov arg2,eax
ret
end if
 
rxproc:
mov eax,arg1
call randomproc
mov arg2,eax
}
 
macro scank
{
mov eax,10
int 0x40
}
 
macro putpix x,y,color
{
mov ebx,x
mov ecx,y
mov edx,color
mov eax,1
int 0x40
}
 
macro puttxt x,y,offs,size,color
{
; mov ebx,x
; shl ebx,16
; add ebx,y
words2reg ebx,x,y
mov ecx,color
mov edx,offs
mov esi,size
mov eax,4
int 0x40
}
 
macro outcount data, x, y, color, numtype
{
mov ecx,data
mov ebx,numtype
mov bl,0
; mov edx,x*65536+y
words2reg edx,x,y
mov esi,color
mov eax,47
int 0x40
}
 
; SCEVENT - Scan event
 
macro scevent red,key,but
{
mov eax,11
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; WTEVENT - Wait event
 
macro wtevent red,key,but
{
mov eax,10
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; TIMEEVENT - Wite for event with timeout
 
macro timeevent xfps,noevent,red,key,but
{
mov eax,23
mov ebx,xfps
int 0x40
cmp eax,0
je noevent
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
 
; CLOSE - Close program
 
macro close
{
mov eax,-1
int 0x40
}
 
; DELAY - Create delay 1/100 sec
; (SYNTAX) Delay time
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec
 
macro delay arg1
{
mov eax,5
mov ebx,arg1
int 0x40
}
 
; WINDOW - Draw window
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned
 
macro window arg1,arg2,arg3,arg4,arg5
{
; mov ebx,arg1*65536+arg3
; mov ecx,arg2*65536+arg4
words2reg ebx,arg1,arg3
words2reg ecx,arg2,arg4
mov edx,arg5
mov eax,0
int 0x40
}
 
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
{
mov ebx,arg1*65536+arg3
mov ecx,arg2*65536+arg4
mov edx,arg5
mov esi,arg6
mov edi,arg7
mov eax,0
int 0x40
}
 
 
; STARTWD - Start of window draw
 
macro startwd
{
mov eax,12
mov ebx,1
int 0x40
}
 
; ENDWD - End window draw
 
macro endwd
{
mov eax,12
mov ebx,2
int 0x40
}
 
; LABEL - Put text to frame
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big
 
macro label arg1,arg2,arg3,arg4
{
local asd,lab
jmp asd
lab db arg3 ;arg label
asd:
; mov ebx,arg1 ;arg1=y arg2=x
; shl ebx,16
; add ebx,arg2
 
 
words2reg ebx,arg1,arg2
 
dword2reg ecx,arg4
 
 
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
;Key's
key_Up equ 178
key_Down equ 177
key_Right equ 179
key_Left equ 176
key_Esc equ 27
key_Space equ 32
key_Enter equ 13
key_Bspace equ 8
key_F1 equ 50
key_F2 equ 51
key_F3 equ 52
key_F4 equ 53
key_F5 equ 54
key_F6 equ 55
key_F7 equ 56
key_F8 equ 57
key_F9 equ 48
key_F10 equ 49
key_F11 equ 68
key_F12 equ 255
key_Home equ 180
key_End equ 181
key_PgUp equ 184
key_PgDown equ 183
 
;Attributes
 
;Window Attributes
window_Skinned equ 0x03000000
window_Type2 equ 0x02000000
window_Type1 equ 0x00000000
window_Reserve equ 0x01000000
 
;Font Attributes
font_Big equ 0x10000000
 
;Colors
cl_White equ 0x00ffffff
cl_Black equ 0x00000000
cl_Grey equ 0x00888888
cl_Red equ 0x00ff0000
cl_Lime equ 0x0000ff00
cl_Green equ 0x0000af00
cl_Blue equ 0x000000ff
cl_Purple equ 0x008080ff
cl_Violet equ 0x008040ff
cl_Cyan equ 0x0040e0ff
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/phenix/trunk/ascml.inc
0,0 → 1,94
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Massive operation
; Libary
;
; Ver 0.1 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 readmas,compmas,findmas
 
macro readmas masoff,obroff
{
local loo
mov edi,masoff ;tekoff
add edi,8
mov ebp,[masoff] ;elements
mov edx,[masoff+4] ;elemsize
mov eax,0 ;count
loo:
pushad
call obroff
popad
add edi,edx
inc eax
cmp eax,ebp
jne loo
}
 
 
macro compmas masoff1,masoff2,obroff
{
local loo,loo2
mov esi,masoff2
add esi,8
mov ecx,[masoff2]
mov ebx,[masoff2+4]
mov eax,0
 
loo2:
push eax
 
mov edi,masoff1 ;tekoff
add edi,8
mov ebp,[masoff1] ;elements1
mov edx,[masoff1+4] ;elemsize1
mov eax,0 ;count
loo:
pushad
call obroff
popad
add edi,edx
inc eax
cmp eax,ebp
jne loo
 
add esi,ebx
pop eax
inc eax
cmp eax,ecx
jne loo2
}
 
 
macro findmas masoff,obroff
{
local loo,looend,lend
mov edi,masoff ;tekoff
add edi,8
mov ebp,[masoff] ;elements
mov edx,[masoff+4] ;elemsize
mov eax,0 ;count
loo:
pushad
mov eax,0
call obroff
cmp eax,1
je looend
popad
add edi,edx
inc eax
cmp eax,ebp
jne loo
stc
jmp lend
looend:
popad
clc
lend:
}
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/phenix/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm phenix.asm phenix
@pause
/programs/phenix/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm phenix.asm phenix
@pause
/programs/phenix/trunk/phenix.asm
0,0 → 1,1328
;
; Phenix Dynamic Game Created by Pavlushin Evgeni for ASCL
;
; 100% Full relase!
;
; www.waptap@mail.ru
;
 
 
;******************************************************************************
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd IM_END ; size of image
dd I_END ; memory for app
dd I_END ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
;******************************************************************************
 
 
include 'lang.inc'
include 'ascl.inc'
include 'ascgl.inc'
include 'ascml.inc'
 
 
showmas:
cmp [edi+8],dword 0
je noshow
cmp [edi+8],dword 1
jne no_gun
mov eax,shoot
jmp outp
no_gun:
push edi
random 3,ebx
pop edi
cmp ebx,0
jne no_star
mov eax,star
jmp outp
no_star:
cmp ebx,1
jne no_star2
mov eax,star2
jmp outp
no_star2:
mov eax,star3
outp:
aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
noshow:
ret
 
showobjmas:
cmp [edi+8],dword 0
je noshow1
cmp [edi+4],dword 380
jg noshow1
cmp [edi+4],dword 0
jl noshow1
cmp [edi+8],dword 1
jne no_warship1
mov eax,warship1
jmp outws
no_warship1:
cmp [edi+8],dword 2
jne no_warship2
mov eax,warship2
jmp outws
no_warship2:
cmp [edi+8],dword 3
jne no_meteor
mov eax,meteor
jmp outws
no_meteor:
cmp [edi+8],dword 4
jne no_box
mov eax,box
jmp outws
no_box:
outws:
aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
noshow1:
ret
 
 
moveobjmas:
cmp [edi+8],dword 0
je no_ws
mov eax,[edi+12]
add [edi],eax
mov eax,[edi+16]
add [edi+4],eax
 
cmp dword [edi],600
jng xok1
sub dword [edi],20
neg dword [edi+12]
jmp xok2
xok1:
cmp dword [edi],0
jnl xok2
add dword [edi],20
neg dword [edi+12]
xok2:
cmp dword [edi+4],400
jng yok
mov dword [edi+8],0
ret
yok:
cmp dword [edi+8],2 ;green ship
jne no_grs
cmp dword [edi+4],100
jna no_grs
cmp dword [edi+4],103
jna grs
cmp dword [edi+4],200
jna no_grs
cmp dword [edi+4],203
jna grs
cmp dword [edi+4],300
jna no_grs
cmp dword [edi+4],303
ja no_grs
grs:
neg dword [edi+12]
mov [temp],edi
findmas massive,findzero
;in edi off to free element
jc close_app
mov esi,edi
mov edi,[temp]
mov eax,[edi]
mov [esi],eax
mov eax,[edi+4]
mov [esi+4],eax
mov [esi+8],dword 1
mov [esi+12],dword 0
mov [esi+16],dword 10
no_grs:
 
cmp dword [edi+8],1 ;blue ship
jne no_bls
cmp dword [edi+4],50
jna no_bls
cmp dword [edi+4],64
jna bls
cmp dword [edi+4],100
jna no_bls
cmp dword [edi+4],114
jna bls
cmp dword [edi+4],150
jna no_bls
cmp dword [edi+4],164
ja no_bls
bls:
mov [temp],edi
findmas massive,findzero
jc close_app
mov esi,edi
mov edi,[temp]
mov eax,[edi]
mov [esi],eax
mov eax,[edi+4]
mov [esi+4],eax
mov [esi+8],dword 2
mov [esi+12],dword 0
mov [esi+16],dword 5
no_bls:
 
no_ws:
ret
 
 
delfarshoot:
cmp [edi+4],dword 40
jb del
cmp [edi+4],dword 400
ja del
cmp [edi],dword 40
jb del
cmp [edi],dword 600
ja del
jmp nodel
del:
mov [edi+8],dword 0
nodel:
ret
 
 
movemas:
cmp [edi+8],dword 0
jne no_freeel
ret
no_freeel:
mov eax,[edi+12]
add [edi],eax
mov eax,[edi+16]
add [edi+4],eax
ret
 
 
 
endshowmas:
cmp [edi+8],dword 0
je noshowem
mov eax,star2
aimgtoimg eax,dword [edi],dword [edi+4],canvas,0x0
noshowem:
ret
 
 
 
endmovemas:
cmp [edi+8],dword 0
jne no_fr
ret
no_fr:
mov eax,[edi+12]
add [edi],eax
mov eax,[edi+16]
add [edi+4],eax
ret
 
 
findzero:
cmp [edi+8],dword 0
je iz_zero
xor eax,eax
ret
iz_zero:
mov eax,1
ret
 
compobr:
cmp [esi+8],dword 0
je no_crsh
cmp [edi+8],dword 0
je no_crsh
cmp [esi+16],dword 0
jg no_crsh
 
mov eax,[esi]
mov [temp],eax
mov eax,[esi+4]
mov [temp2],eax
mov eax,[edi]
mov [temp3],eax
mov eax,[edi+4]
mov [temp4],eax
 
pushad
collimg imgsize,[temp],[temp2],imgsize,[temp3],[temp4],[otv]
popad
cmp [otv],dword 0
je no_crsh
 
cmp [edi+8],dword 2
jne no_grship
inc [gship]
add [score],30
jmp setzero
no_grship:
cmp [edi+8],dword 1
jne no_blship
inc [bship]
add [score],20
jmp setzero
no_blship:
cmp [edi+8],dword 3
jne no_metr
dec dword [edi+16]
cmp dword [edi+16],0
jne mok
mov dword [edi+16],1
mok:
mov [esi+8],dword 0
ret
no_metr:
 
setzero:
mov [esi+8],dword 0
mov [edi+8],dword 0
no_crsh:
ret
 
shipobjtest:
cmp [edi+8],dword 0
je no_obj
mov eax,[edi]
mov [temp3],eax
mov eax,[edi+4]
mov [temp4],eax
pushad
collimg imgsize,[shipx],[shipy],imgsize,[temp3],[temp4],[otv]
popad
cmp [otv],dword 0
je no_obj
cmp [edi+8],dword 4 ;if box
jne no_fbox
add [energy],5
add [score],50
mov [edi+8],dword 0
inc [boxget]
ret
no_fbox:
sub [energy],16
mov [edi+8],dword 0
no_obj:
ret
 
shipguntest:
cmp [edi+8],dword 0
je no_gobj
cmp [edi+16],dword 0
jl no_gobj
mov eax,[edi]
mov [temp3],eax
mov eax,[edi+4]
mov [temp4],eax
pushad
collimg imgsize,[shipx],[shipy],imgsize,[temp3],[temp4],[otv]
popad
cmp [otv],dword 0
je no_gobj
sub [energy],4
mov [edi+8],dword 0
no_gobj:
ret
 
 
START: ; start of execution
 
massize = 400
elemsize = 20
 
mov [massive],dword massize
mov [massive+4],dword elemsize
 
omassize = 100
oelemsize = 20
 
mov [objmas],dword omassize
mov [objmas+4],dword oelemsize
 
 
mov eax,66
mov ebx,1
mov ecx,1
int 0x40
 
mov eax,26
mov ebx,2
mov ecx,1
mov edx,keymap
int 0x40
 
startgame:
gif_hash_offset = gif_hash_area
giftoimg gif_file_area2,canvas
 
gif_hash_offset = gif_hash_area
giftoimg gif_file_area,img_area
 
getimg img_area,0,0,32,32,ship
getimg img_area,32,0,32,32,shoot
getimg img_area,64,0,32,32,warship1
getimg img_area,96,0,32,32,warship2
getimg img_area,128,0,32,32,meteor
getimg img_area,160,0,32,32,star
getimg img_area,192,0,32,32,star2
getimg img_area,224,0,32,32,star3
getimg img_area,0,32,32,32,box
 
 
 
main_menu:
call draw_logowindow
 
stillm:
wtevent redm,keym,buttonm
jmp stillm
redm:
call draw_logowindow
jmp stillm
keym:
mov eax,2
int 0x40
jmp stillm
buttonm:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
je close_app
cmp ah,2 ; button id=1 ?
je start_game
cmp ah,3 ; button id=1 ?
je help
cmp ah,4 ; button id=1 ?
je close_app
jmp stillm
 
draw_logowindow:
call draw_window
setimg 5,21,canvas
drawlbut 300,300,60,14,'START',2,0x990000,cl_Black
drawlbut 300,320,60,14,'HELP',3,0x990000,cl_Black
drawlbut 300,340,60,14,'EXIT',4,0x990000,cl_Black
ret
 
;***********************
; Draw help menu
;***********************
 
help:
call draw_helpwindow
 
stillh:
wtevent redh,keyh,buttonh
jmp stillh
redh:
call draw_helpwindow
jmp stillh
keyh:
mov eax,2
int 0x40
jmp stillh
buttonh:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
je close_app
cmp ah,2 ; button id=1 ?
je start_game
cmp ah,3 ; button id=1 ?
je help
cmp ah,4 ; button id=1 ?
je close_app
cmp ah,5 ; button id=1 ?
je main_menu
jmp stillh
 
draw_helpwindow:
call draw_window
setimg 5,21,canvas
 
drawfbox 40,50,580,380,cl_Grey
 
mov ebp,4*7
mov ebx,180*65536+90
mov edx,helptext
mov esi,50
mov ecx,cl_White
dec ebp
looht:
mov eax,4
int 0x40
add edx,esi
add ebx,10
dec ebp
jnz looht
 
setimg 90,90,ship
setimg 90,130,shoot
setimg 90,170,star
setimg 90,210,warship1
setimg 90,250,warship2
setimg 90,290,meteor
setimg 90,330,box
 
drawlbut 500,400,80,14,'<<BACK',5,0x990000,cl_Black
 
jmp stillh
 
helptext:
db 'Phenix '
db 'Controls: Num1 move left, Num3 move right '
db ' P-pause (use for screen shooting) '
db ' '
 
db 'Lazer cannon '
db 'Press Num5 for shoot '
db 'Core fast, speed fast, reload slow '
db ' '
 
db 'Plazma cannon '
db 'Press Num2 for Plazma Nuke and Num8 for shoot '
db 'Core slow, speed medium, reload fast '
db ' '
 
db 'Blue warship '
db 'Speed fast '
db 'Attack method: plazma bomb '
db ' '
 
db 'Green warship '
db 'Speed slow '
db 'Attack method: laser shoot '
db ' '
 
db 'Meteor '
db 'Dangeros object! '
db 'SuperSheld '
db ' '
 
db 'Fly Box '
db 'Sheld pack, sheld +5, score +30 '
db 'Get for sheld level up! '
db ' '
 
start_game:
 
; jmp end_gm
 
mov [canvas],dword 640
mov [canvas+4],dword 440
 
call draw_window
 
;Main loop wait for event with 10msec
still:
; scevent red,key,button ;for full speed
 
timeevent 1,no_event,red,key,button
no_event:
setimg 5,21,canvas
 
cmp [pause_on],0
jne still
 
cmp [energy],0
jl game_over
 
cmp [ctime],dword 0
je no_dct
dec dword [ctime]
no_dct:
 
cmp [xtime],dword 0
je no_dxt
dec dword [xtime]
no_dxt:
 
 
;
; Add to level new ships
;
inc dword [pathtime]
mov ebp,[levelpart]
shl ebp,5
add ebp,levels
mov eax,[ebp]
cmp [pathtime],eax ;500
jne no_nextloc
 
randobjmasx:
mov ebp,[levelpart]
shl ebp,5
add ebp,levels
 
mov ecx,[ebp+8]
mov [shiptype],2
mov [xmoving],9
mov [xaccel],4
mov [ymoving],3
mov [yaccel],2
call add_ships
 
mov ecx,[ebp+12]
mov [shiptype],1
mov [xmoving],3
mov [xaccel],1
mov [ymoving],3
mov [yaccel],6
call add_ships
 
mov ecx,[ebp+16]
mov [shiptype],3
mov [xmoving],5
mov [xaccel],2
mov [ymoving],5
mov [yaccel],2
call add_ships
 
mov ecx,[ebp+20]
mov [shiptype],4
mov [xmoving],4
mov [xaccel],1
mov [ymoving],4
mov [yaccel],1
call add_ships
 
jmp newlocend
 
shiptype dd 0
xmoving dd 0
ymoving dd 0
xaccel dd 0
yaccel dd 0
 
add_ships:
looship:
cmp ecx,0
je no_ships
push ecx
findmas objmas,findzero
;in edi off to free element
jc close_app
mov ebp,[shiptype]
mov dword [edi+8],ebp ;2 ;green ship
; random x
push edi
random 600,eax
pop edi
mov [edi],eax
; random y
push edi
mov ebp,[levelpart]
shl ebp,5
add ebp,levels
mov esi,[ebp+4] ;get max range
random esi,eax
neg eax
pop edi
mov [edi+4],eax
; x moving
push edi ;planers
random [xmoving],eax
sub eax,[xaccel];4
pop edi
mov [edi+12],eax
; y moving
push edi
random [ymoving],eax ;slow
add eax,[yaccel] ;2
pop edi
mov [edi+16],eax
pop ecx
dec ecx
jnz looship
no_ships:
ret
 
 
levelpart dd 0
levels:
;level1
dd 1,800,0,0,5,8,0,0 ;one at start
dd 500,2000,4,20,30,0,0,0
dd 500,2000,4,20,0,8,0,0
dd 500,2000,10,0,0,4,0,0
dd 500,4000,0,30,0,0,0,0
dd 400,400,0,0,10,0,0,0
dd 400,400,0,0,10,0,0,0
dd 0,0,0,0,0,0,0,0 ;end of level
;level2
dd 1,16000,0,30,0,0,0,0 ;one at start
dd 200,8000,0,20,0,0,0,0
dd 200,2000,0,10,0,8,0,0
dd 200,4000,0,10,0,0,0,0
dd 0,0,0,0,0,0,0,0 ;end of level
;level3
dd 1,4000,0,20,30,8,0,0 ;one at start
dd 400,4000,10,10,20,6,0,0
dd 400,4000,0,20,10,2,0,0
dd 400,4000,10,10,20,0,0,0
dd 0,-1,0,0,0,0,0,0 ;end of game
 
 
newlocend:
mov [pathtime],0
inc [levelpart]
jmp no_nextloc
 
endgame dd 0
objects dd 0
endtest:
cmp dword [edi+8],0
jne no_free
ret
no_free:
mov [endgame],0
inc [objects]
ret
 
 
no_nextloc:
mov [objects],0
mov [endgame],1
readmas objmas,endtest
cmp [endgame],1
jne no_end_lev ;no_nextloc
 
mov ebp,[levelpart]
shl ebp,5
add ebp,levels
mov eax,[ebp+4]
cmp eax,dword 0
je end_lev ;end of level
cmp eax,dword -1
je end_gm ;end of game
 
no_end_lev:
 
cmp [num5],dword 0
je no_addsh
cmp [ctime],dword 0
jne no_addsh
cmp [lazer],dword 0
je no_addsh
findmas massive,findzero
;in edi off to free element
jc close_app
mov eax,[shipx]
mov [edi],eax
mov eax,[shipy]
mov [edi+4],eax
mov [edi+8],dword 1 ;show
mov [edi+12],dword 0
mov [edi+16],dword -12
mov [ctime],dword 8 ;wait for cannon
dec [lazer]
no_addsh:
 
cmp [num8],dword 0
je no_addplx
cmp [xtime],dword 256-16
jae no_addplx
cmp [plazma],0
je no_addplx
findmas massive,findzero
;in edi off to free element
jc close_app
mov eax,[shipx]
mov [edi],eax
mov eax,[shipy]
mov [edi+4],eax
mov [edi+8],dword 2 ;show
add [xtime],dword 8 ;wait for cannon
cmp [xtime],dword 256
jna okx
mov [xtime],256
okx:
mov [edi+12],dword 0 ;wait for cannon
mov [edi+16],dword -8 ;wait for cannon
dec [plazma]
no_addplx:
 
 
 
cmp [num2],dword 0
je no_addsh2
cmp [xtime],dword 0
jne no_addsh2
cmp [plazma],0
je no_addsh2
mov eax,[shipy]
mov [temp3],eax
mov [temp2],dword 5
loox2:
mov [temp],dword 10
loox:
findmas massive,findzero
;in edi off to free element
jc close_app
random 25,eax
mov ebp,eax
sub eax,12
add eax,[shipx]
mov [edi],eax
shr ebp,3
random ebp,eax
neg eax
add eax,[temp3] ;[shipy]
mov [edi+4],eax
mov [edi+8],dword 2 ;show hstar
random 5,eax
sub eax,2
mov [edi+12],eax ;show hstar
random 7,eax
sub eax,8
mov [edi+16],eax ;show hstar
dec [temp]
jnz loox
sub [temp3],30
dec [temp2]
jnz loox2
mov [xtime],dword 256 ;wait for cannon
sub [plazma],50
no_addsh2:
 
 
cmp [num1],dword 0
je no_left
sub dword [shipx],6
no_left:
 
cmp [num3],dword 0
je no_right
add dword [shipx],6
no_right:
 
;ship correct
cmp [shipx],5
jnl xl_ok
mov [shipx],5
xl_ok:
cmp [shipx],603
jng xr_ok
mov [shipx],603
xr_ok:
 
 
;clear scrbuf
mov edi,canvas+8
cld
mov ecx,640*440*3/4
mov eax,0
rep stosd
 
compmas objmas,massive,compobr
 
readmas objmas,shipobjtest
readmas massive,shipguntest
 
readmas objmas,showobjmas
readmas objmas,moveobjmas
 
readmas massive,showmas
readmas massive,movemas
readmas massive,delfarshoot
; findmas massive,findzero
;in edi off to free element
; jc close_app
 
aimgtoimg ship,[shipx],[shipy],canvas,0x0
 
drawfbox 150,5,64,5,0x000000
mov eax,[xtime]
sub eax,256
neg eax
shr eax,2
drawfbox 150,5,eax,5,0x0000ff
 
drawfbox 150,12,64,5,0x000000
mov eax,[ctime]
sub eax,8
neg eax
shl eax,3
drawfbox 150,12,eax,5,0xffff00
 
drawfbox 220,2,6*5+2 ,9,cl_Grey
outcount [plazma],221,3,cl_Blue,5*65536
drawfbox 220,11,6*5+2 ,9,cl_Grey
outcount [lazer],221,12,0xffff00,5*65536
 
 
drawfbox 280,6,6*5+2 ,9,cl_Grey
outcount [gship],281,7,cl_Green,5*65536
drawfbox 320,6,6*5+2 ,9,cl_Grey
outcount [bship],321,7,cl_Blue,5*65536
drawfbox 360,6,6*5+2 ,9,cl_Grey
outcount [boxget],361,7,0xffaa00,5*65536
 
drawfbox 400,2,6*5+2 ,9,cl_Grey
outcount [objects],401,2,0x00ff00,5*65536
drawfbox 400,11,6*5+2 ,9,cl_Grey
outcount [energy],401,12,0xff0000,5*65536
 
drawfbox 450,11,6*5+2 ,9,cl_Grey
outcount [score],451,12,0xffff00,5*65536
 
 
jmp still
 
red:
call draw_window
jmp still
 
key: ; key
mov eax,2
int 0x40 ; read (eax=2)
 
shr eax,8
and eax,0xff
mov ah,al
 
cmp ah,153
jne no_pause
not [pause_on]
jmp still
no_pause:
 
 
cmp ah,76
jne no_num5d
mov [num5],1
jmp still
no_num5d:
cmp ah,204
jne no_num5u
mov [num5],0
jmp still
no_num5u:
 
cmp ah,80
jne no_num2d
mov [num2],1
jmp still
no_num2d:
cmp ah,208
jne no_num2u
mov [num2],0
jmp still
no_num2u:
 
cmp ah,79 ;key_Space 85 exit
jne no_num1d
mov [num1],1
jmp still
no_num1d:
cmp ah,207 ;key_Space 85 exit
jne no_num1u
mov [num1],0
jmp still
no_num1u:
 
cmp ah,81 ;key_Space 85 exit
jne no_num3d
mov [num3],1
jmp still
no_num3d:
cmp ah,209 ;key_Space 85 exit
jne no_num3u
mov [num3],0
jmp still
no_num3u:
 
cmp ah,72 ;key_Space 85 exit
jne no_num8d
mov [num8],1
jmp still
no_num8d:
cmp ah,200 ;key_Space 85 exit
jne no_num8u
mov [num8],0
jmp still
no_num8u:
 
jmp still ; not testing
 
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne noclose
close_app:
mov eax,-1 ; close this program
int 0x40
noclose:
jmp still
 
draw_window:
startwd
window 40,40,(640+9),(440+26),window_Skinned+0x00
label 8,8,'ASCL DYNAMIC GAME',cl_White+font_Big
; setimg 5,22,img_area
endwd
ret
 
;**********************
; Game Over process
;**********************
 
game_over:
; close
call draw_gowindow
stillgo:
wtevent redgo,keygo,buttongo
jmp stillgo
redgo:
call draw_gowindow
jmp stillgo
keygo:
mov eax,2
int 0x40
jmp stillgo
buttongo:
mov eax,17 ; get id
int 0x40
cmp ah,1
je close_app
cmp ah,4
je close_app
cmp ah,5
je main_menu
cmp ah,7
je restart_lev
jmp stillgo
 
restart_lev:
mov [pathtime],0
 
prevpart:
mov ebp,[levelpart]
shl ebp,5
add ebp,levels
mov eax,[ebp]
cmp eax,dword 1
je rest ;end of level
dec [levelpart]
jmp prevpart
 
 
rest:
;massives reset - clear massives
mov edi,massive+8
cld
mov ecx,massize*elemsize/4
mov eax,0
rep stosd
 
mov edi,objmas+8
cld
mov ecx,omassize*oelemsize/4
mov eax,0
rep stosd
 
;counters reset
mov [boxget],0
mov [gship],0
mov [bship],0
 
;ship reset
mov [energy],100
mov [shipx],300
mov [shipy],400
mov [lazer],1000
mov [plazma],500
 
 
; reset keyboard
mov [num1],0
mov [num5],0
mov [num3],0
mov [num2],0
mov [num8],0
jmp start_game
 
draw_gowindow:
startwd
drawfbox 170,160,300,120,cl_Grey
drawlbut 180,260,80,14,'(X) EXIT',4,0x990000,cl_Black
drawlbut 280,260,80,14,'<MENU>',5,0x990000,cl_Black
drawlbut 380,260,80,14,'RESTART',7,0x990000,cl_Black
 
label 280,200,' GAME OVER ',cl_Black
endwd
ret
 
 
;**********************
; End level process
;**********************
 
end_lev:
; close
call draw_scorewindow
stilleg:
wtevent redeg,keyeg,buttoneg
jmp stilleg
redeg:
call draw_scorewindow
jmp stilleg
keyeg:
mov eax,2
int 0x40
jmp stilleg
buttoneg:
mov eax,17 ; get id
int 0x40
cmp ah,1
je close_app
cmp ah,2
je next_lev
cmp ah,3
je help
cmp ah,4
je close_app
cmp ah,5
je main_menu
jmp stilleg
 
next_lev:
mov [pathtime],0
inc [levelpart]
 
;ship reset
mov [energy],100
mov [shipx],300
mov [shipy],400
mov [lazer],1000
mov [plazma],500
 
;counters reset
mov [boxget],0
mov [gship],0
mov [bship],0
 
; reset keyboard
mov [num1],0
mov [num5],0
mov [num3],0
mov [num2],0
mov [num8],0
jmp start_game
 
draw_scorewindow:
call draw_window
startwd
drawfbox 170,130,300,190,cl_Grey
drawlbut 180,300,80,14,'(X) EXIT',4,0x990000,cl_Black
drawlbut 280,300,80,14,'<MENU>',5,0x990000,cl_Black
drawlbut 380,300,80,14,'NEXT >>',2,0x990000,cl_Black
 
setimg 180,140,warship1
outcount [bship],241,151,cl_Blue,5*65536
 
setimg 180,180,warship2
outcount [gship],241,191,cl_Green,5*65536
 
setimg 180,220,meteor
setimg 180,260,box
outcount [boxget],241,271,0xbbbb00,5*65536
endwd
ret
 
 
;**********************
; End of game process
;**********************
 
end_gm:
mov [pathtime],0
call draw_window
label 200 ,8,'YOU WIN PRESS ANY KEY TO EXIT',cl_White+font_Big
 
stilleg2:
; scevent redeg2,keyeg2,buttoneg2
timeevent 1,no_event2,redeg2,keyeg2,buttoneg2
 
no_event2:
setimg 5,21,canvas
 
;clear scrbuf
mov edi,canvas+8
cld
mov ecx,640*440*3/4
mov eax,0
rep stosd
 
aimgtoimg ship,320,220,canvas,0x0
 
readmas massive,endshowmas
readmas massive,endmovemas
readmas massive,delfarshoot
; findmas massive,findzero
;in edi off to free element
; jc close_app
 
inc [pathtime]
cmp [pathtime],30
jne no_firework
mov [pathtime],0
random 400,eax
mov [temp3],eax
random 600,eax
mov [temp2],eax
mov [temp],dword 8;10
xloox:
findmas massive,findzero
;in edi off to free element
jc close_app
 
mov eax,[temp2] ;[shipx]
mov [edi],eax
mov eax,[temp3] ;[shipy]
mov [edi+4],eax
mov [edi+8],dword 2 ;show hstar
rerand:
random 5,eax
sub eax,2
cmp eax,0
je rerand
mov [edi+12],eax ;show hstar
rerand2:
random 7,eax
sub eax,3
cmp eax,0
je rerand2
mov [edi+16],eax ;show hstar
dec [temp]
jnz xloox
no_firework:
jmp stilleg2
 
redeg2:
jmp end_gm ;stilleg2
keyeg2:
mov eax,2
int 0x40
jmp main_menu
buttoneg2:
mov eax,17 ; get id
int 0x40
jmp stilleg2
 
 
 
 
 
 
; DATA AREA
IM_END:
;global
pause_on dd 0
 
;massive
shipx dd 300
shipy dd 400
 
;guns
lazer dd 1000
plazma dd 500
 
;keys
num1 dd 0
num5 dd 0
num3 dd 0
num2 dd 0
num8 dd 0
 
;enemy countres
gship dd 0
bship dd 0
boxget dd 0
 
energy dd 100
score dd 0
 
;delay for cannon
ctime dd 0
;delay for nuke gun
xtime dd 0
;path time
pathtime dd 0
;
temp dd 0
temp2 dd 0
temp3 dd 0
temp4 dd 0
otv dd 0
 
;for collimg
imgsize:
dd 32
dd 32
 
;massive:
;dd 400 ;elements num
;dd 20 ;size of element in bytes
;rb 400*20
 
 
keymap:
rb 1000
 
;gif_file_area ~21500
gif_file_area2:
file 'phenix.gif'
rb 50
gif_file_area:
file 'star2.gif';include gif file
rb 50 ;50 bytes temp back zone
img_area:
rb 256*64*3+8
ship:
rb 32*32*3+8
shoot:
rb 32*32*3+8
warship1:
rb 32*32*3+8
warship2:
rb 32*32*3+8
meteor:
rb 32*32*3+8
star:
rb 32*32*3+8
star2:
rb 32*32*3+8
star3:
rb 32*32*3+8
box:
rb 32*32*3+8
 
gif_hash_area:
rd 4096+1 ;hash area size for unpacking GIF
 
massive:
rd massize ;elements num
rd elemsize ;size of element in bytes
rb massize*elemsize
 
objmas:
rd omassize ;elements num
rd oelemsize ;size of element in bytes
rb omassize*oelemsize
 
canvas:
canvas_x:
rd 1
canvas_y:
rd 1
rb (640*440*3)+2000
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/phenix/trunk/phenix.gif
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/phenix/trunk/star2.gif
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