Upload optimized Phoenix and ASCL by Kolibrius

git-svn-id: svn://kolibrios.org@9241 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-11-03 18:23:06 +00:00
parent b69f000608
commit 251d03d5f0
9 changed files with 2545 additions and 2710 deletions

View File

@ -7,28 +7,160 @@ lang equ ru
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
; Ver 0.18
;
;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
; draw image into image with alpha color mask
; image_draw_acimage dest, source, x, y, alpha_color
;
macro image_draw_acimage dest, source, x, y, alpha_color
{
local next_pix,next_line,skip_pix,no_skip
push dest
push source
push x
push y
push alpha_color
pop ebp ; alpha color
pop eax ; y
pop ebx ; x
pop esi ; src
pop edi ; dest
call image_draw_acimage_proc
if ~ defined image_draw_acimage_used
image_draw_acimage_used equ 1
jmp end_image_draw_acimage_proc
image_draw_acimage_proc:
mov ecx,dword [edi] ; ecx = canvas width
mul ecx ; edx:eax = ypos * canvas width
add eax,ebx ; eax = (ypos * canvas width) + xpos
lea eax,[eax+eax*2+8] ; eax=(y*xsize+x)*3+8 (8=skip xy size dwords)
mov edx,[esi] ; edx = img width
sub ecx,edx ; ecx = canvas width - img width
lea ebx,[ecx*2+ecx] ; ebx = how many pixels skip for new line
mov ecx,[esi+4] ; ecx = img height
add esi,8 ; esi + 8 for skip xy size dwords
add edi,eax ; edi = dest position
shl ebp,8 ; for fast compare with alpha color
cld ; set movs direction flag
next_line:
push edx
next_pix:
mov eax,[esi]
shl eax,8
cmp eax,ebp
je skip_pix
movsw
movsb
jmp no_skip
skip_pix:
add esi,3
add edi,3
no_skip:
dec edx
jnz next_pix
pop edx
add edi,ebx
dec ecx
jnz next_line
ret
end_image_draw_acimage_proc :
end if
}
macro image_set_size image,width,height
{
mov dword [image],width
mov dword [image+4],height
}
; label - draw label on window
; example:
; label 10,12,'Hello World!',cl_Green+font_size_x4+utf16
macro image_draw_label image,x,y,text,color
{
local label_text
draw_to_buffer equ 00001000b shl 24
jmp @f
label_text db text
@@:
words2reg ebx,x,y ; ebx - position
dword2reg ecx,color+draw_to_buffer ; ecx - color
mov edi,image
mov edx,label_text ; edx - address of label text
mov esi,@b-label_text ; esi - size of libel in bytes
mov eax,4
mcall
}
; draw_frect - draw filled rect
macro draw_frect 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
mcall
}
; draw_label - Draw label in window
; example:
; draw_label 10,12,'Hello World!',cl_Green+font_size_x4+utf16
macro draw_label x,y,text,color
{
local label_text
words2reg ebx,x,y ; ebx - position
if text eqtype 123 | text eqtype eax
movt edx,text
mov ecx,color+(1 shl 31) ; ecx - color
else
mov edx,label_text ; edx - address of label text
jmp @f
label_text db text
@@:
mov esi,@b-label_text ; esi - size of libel in bytes
movt ecx,color ; ecx - color
end if
mov eax,4
mcall
}
hide_zeros equ (1 shl 31)
use_bg_color equ (1 shl 30)
use_big_font equ (1 shl 28)
macro draw_number data, x, y, color, numtype, bg_color
{
movt ecx,data
movt ebx,numtype
mov bl,0 ; if bl = 0, ecx is contain number
words2reg edx,x,y
if bg_color eq
movt esi,color
else
movt esi,color+use_bg_color
movt edi,bg_color
end if
mov eax,47
mcall
}
; draw_image - macro for draw image on window area
macro draw_image x, y, image
{
mov ecx,[image-2] ; -2 for except shl ecx,16
mov cx,[image+4] ; ecx = xsize*65536+ysize
wordstoreg edx, x, y ; edx = x*65536+y
lea ebx,[image+8] ; ebx = image data address
mov eax,7 ; eax = 7 is draw image function
mcall
}
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
@ -81,7 +213,6 @@ loo:
add ebp,3
jmp nx
yx:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
@ -205,97 +336,6 @@ end if
}
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
{
@ -346,9 +386,7 @@ pop esi
add ebp,eax
shl eax,1
add ebp,eax
add ebp,3
dec edi
jnz loo2
ret
@ -365,17 +403,6 @@ end if
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
mcall
}
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
@ -414,7 +441,7 @@ end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,5*65536
; mov bl,0
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
@ -422,81 +449,20 @@ end if
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
mcall
jnz @b
}
macro setframe x , y ,arg3
@ -513,57 +479,47 @@ macro setframe x , y ,arg3
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
if xs eqtype 0
local next_pixel,next_line
; store image size
if xs eqtype 0 | xs eqtype eax
mov dword [imgdest],xs
else
mov eax,xs
mov dword [imgdest],eax
end if
if ys eqtype 0
if ys eqtype 0 | ys eqtype eax
mov dword [imgdest+4],ys
else
;push ys
;pop dword [imgdest+4]
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
lea edi,[8+imgdest] ; edi = destinaton address
mov eax,dword [imgsrc] ; eax = xsize of source image in pixels
push eax ; store eax before mul operation
mov edx,y
mul edx ; edx:eax = eax*edx
add eax,x
mov edx,ecx
lea eax,[eax+2*eax] ;eax=offset on imsrc
; mov ebp,eax
; shl eax,1
; add eax,ebp
lea esi,[imgsrc+8+eax+2*eax] ; esi = start offset on img src
pop eax ; restore eax
sub eax,xs ; eax = src image xsize - crop fragment xsize
lea eax,[eax+eax*2] ; eax = eax * 3 (bytes per pixel)
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:
; this loop used esi,edi,ecx,edx,eax registers
mov edx,ys ; edx = ysize in pixels
cld ; set direction
next_line:
mov ecx,xs ; ecx = xsize in pixels
next_pixel:
movsw
movsb
movsb ; write 3 bytes pixel
dec ecx
jne cyc
add esi,edx
mov ecx,xs
sub esi,ecx
sub esi,ecx
sub esi,ecx
dec ebx
jne cyc
jnz next_pixel
add esi,eax
dec edx
jnz next_line
}
macro copyimg img2_off,img1_off
@ -604,10 +560,8 @@ cop:
jne cop
}
; number of frame in ecx
; callculatin offset of raw data
; number of frame in ecx
; callculatin offset of raw data
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
{
@ -630,12 +584,10 @@ 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
; ( NOTE ) This is macro is not brake bmp structure! Tested in 32,8,4 bits
bmptoimg_data_area_count=0
macro bmptoimg bmp_load_area,img_dest_area
@ -659,7 +611,7 @@ local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
yespicsize:
yespicsize:
mov ebp,img_dest_area+8
mov eax,bmp_load_area
@ -680,7 +632,7 @@ local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
sub esi,dword [bmptoimg_data_area_bps]
nextstring:
nextstring:
push edi
push ebp
cmp word [bmp_load_area+28],24
@ -691,7 +643,7 @@ local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
cld
rep movsd
convert1:
convert1:
pop ebp
pop edi
sub esi,dword [bmptoimg_data_area_bps]
@ -702,7 +654,7 @@ local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
add ebp,eax
jmp nextstring
convertno32:
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
@ -710,7 +662,7 @@ local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
add esi,dword [bmptoimg_data_area_bps]
mov dword [bmptoimg_data_area_eos],esi
pop esi
nextelem:
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
@ -719,57 +671,50 @@ local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
je convert1bpp
call converttable
convert2:
convert2:
pop eax
inc esi
cmp esi,dword [bmptoimg_data_area_eos]
jae convert1
add edi,3
add ebp,3
jmp nextelem
convert4bpp:
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:
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
noaddelem:
push edx
call converttable
pop edx
dec edx
js convert2
add edi,3
add ebp,3
jmp nextbit
converttable:
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
; mov dword [edi],edx
; mov dword [edi],edx
mov [ebp],edx
ret

View File

@ -7,33 +7,83 @@ lang equ ru
; GaMe
; Libary
;
; Ver 0.03 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
; Ver 0.05
;
;InfoList
;0.01 correct
;0.02 control ~14.05.2004
;0.03 all macros optimized by halyavin, add at ~07.06.2004
; game_collision_2d - get collision of two 2d rectangles
; result of collision test placed in CF.
; if CF = 1, objects is collided
_1dbounce_count=0;
macro game_collision_2d xy1,wh1,xy2,wh2 ;img1_off,x1,y1,img2_off,x2,y2 ;,otv
{
movt eax,xy1
movt ebx,wh1
movt ecx,xy2
movt edx,wh2
call game_collision_proc
if ~ defined game_collision_used
game_collision_used equ 1
jmp exit
; eax = x1*65536+y1
; ebx = w1*65536+h1
; ecx = x2*65536+y2
; edx = w2*65536+h2
game_collision_proc:
; y h test
call _1dbounce
jnc @f
; x w test
shr eax,16 ;eax,y1 ;
shr ebx,16 ;mov ebx,[img1_off+4] ;h1
shr ecx,16 ;mov ecx,y2 ;
shr edx,16 ;mov edx,[img2_off+4] ;h2
call _1dbounce
@@:
ret
; ax - x1, bx - w1, cx - x2, dx - w2
; or
; ax - y1, bx - h1, cx - y2, dx - h2
; if collision ecx is incremented
_1dbounce:
cmp cx,ax ; if x2 < x1 jmp anot
jb anot
add ax,bx
cmp ax,cx ; if x1+xs <= x2 not coll
jbe not_coll
coll:
stc ; CF = 1
ret
anot:
add cx,dx
cmp cx,ax ; x2 + xs2 > x1
ja coll
not_coll:
clc ; CF = 0
ret
exit:
; corectiryemoe,corectnoe,step
macro correct arg1,arg2,arg3
end if
}
; approxto
macro approxto value,target_value,step
{
local plus,minus,equal
mov eax,arg2
cmp arg1,eax
mov eax,target_value
cmp value,eax
je equal
mov eax,arg3
mov eax,step
ja minus
plus:
add arg1,eax
add value,eax
jmp equal
minus:
sub arg1,eax
sub value,eax
equal:
}
macro control min,max,arg
macro clamp min,max,arg
{
local gr,low,norm
mov eax,max

View File

@ -0,0 +1,120 @@
lang equ ru
;
; Assembler
; SMALL
; CODE
; GUI
; Libary
;
; Ver 0.01
;
macro gui_text x,y,color,font_size,text {
db 4 ; type of gui element 4 - text
dw y, x
dd (1 shl 31)+color+((font_size-1) shl 24)
db text, 0
}
macro gui_button id,x,y,w,h,bcolor,tcolor,text {
db 8 ; type of gui element 8 - button with text
dw id, w, x, h, y
dd bcolor
dd (1 shl 31)+tcolor
db text, 0
}
macro gui_end {
db 255 ; type of gui element 255 - end of gui marker
}
macro draw_gui address
{
mov esi,address
call draw_gui_proc
if ~ defined draw_gui_used
draw_gui_used equ 1
jmp end_draw_gui_proc
draw_gui_proc:
next_element:
xor eax,eax
mov al,byte [esi]
; eax =4 draw label
cmp eax,4
jne no_label
mov ebx,[esi+1] ; x,y
mov ecx,[esi+1+4] ; color
lea edx,[esi+1+4+4] ; text offset
add esi,9
mcall
jmp skip_string
no_label:
; eax = 8 draw button
cmp eax,8
jne no_draw_button
xor edx,edx
mov dx,[esi+1] ; id
mov ebx,[esi+3] ; x,xs
mov ecx,[esi+7] ; y,ys
push esi
mov esi,[esi+11] ; button color
mcall
pop esi
lea ebp,[esi+19] ; start of text
call get_size_of_string
mov ebx,6
mul ebx
mov bx,[esi+3]
sub bx,ax
shr bx,1
add bx,[esi+5]
mov dx,[esi+7]
sub dx,7
shr dx,1
add dx,[esi+9]
shl ebx,16
mov bx,dx
mov ecx,[esi+15] ; text color
lea edx,[esi+19] ; text offset
mov eax,4
add esi,19
mcall
jmp skip_string
no_draw_button:
cmp eax,255
je end_of_gui
; unknown gui element
int3
end_of_gui:
ret
get_size_of_string:
xor eax,eax
next_bt:
cmp byte [ebp],0
jne no_en
ret
no_en:
inc ebp
inc eax
jmp next_bt
; function for skip string of text
next_byte:
inc esi
skip_string:
cmp byte [esi],0
jne next_byte
inc esi
jmp next_element
end_draw_gui_proc:
end if
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,161 @@
lang equ ru
;
; Assembler
; SMALL
; CODE
; Arrays
; Processing
; Libary
;
; Ver 0.04
;
; This macro iterates through an array of elements,
; processing each element using the specified process.
; modificate eax,{ebx},{ecx},edx,esi,[edi],[ebp]
macro array_processing object_array,process
{
movt edi,object_array
movt ebp,process
call array_processing_proc
if ~ defined array_processing_used
array_processing_used equ 1
jmp end_ap
array_processing_proc:
push ecx
push ebx
mov ecx,[edi] ; dword contain quantity of elements
mov ebx,[edi+4] ; dword contain size of each element
add edi,8
ap_read_next:
;pop ebx
;pop ecx
pushad
call ebp ;eax ;process
popad
;push ecx
;push ebx
add edi,ebx
dec ecx
jnz ap_read_next
pop ebx
pop ecx
ret
end_ap:
end if
}
; This macro iterates through an array of elements,
; processing each element using the specified process
; if object finded ina array macro returned
; with CF=0 and address of element in edi.
; if object not finded macro return CF=1
; process must be return CF=0 if value euqal finded value
; and CF=1 if value not equal
; modificate eax,{ebx},{ecx},edx,esi,[edi],[ebp]
macro array_find object_array,process
{
movt edi,object_array
movt ebp,process
call array_find_proc
if ~ defined array_find_used
array_find_used equ 1
jmp end_af
array_find_proc:
push ecx
push ebx
mov ecx,[edi] ; dword contain quantity of elements
mov ebx,[edi+4] ; dword contain size of each element
add edi,8
af_read_next:
pushad
call ebp ;eax ;process
popad
jnc af_finded
add edi,ebx
dec ecx
jnz af_read_next
; not finded
stc ; if not finded CF = 1
af_finded: ; if finded CF = 0
pop ebx
pop ecx
ret
end_af:
end if
}
;
; process may get offests of elements from registers.
macro compmas object_array_1,object_array_2,process
{
local loo,loo2
;lea,[oa+8]
mov esi,object_array_2 ; current position
add esi,8
mov ecx,[object_array_2] ; dword contain quantity of elements
mov ebx,[object_array_2+4] ; dword contain size of each element
mov eax,0
loo2:
push eax
mov edi,object_array_1 ; current position
add edi,8
mov ebp,[object_array_1] ; dword contain quantity of elements
mov edx,[object_array_1+4] ; dword contain size of each element
mov eax,0 ;count
loo:
pushad
call process
popad
add edi,edx
inc eax
cmp eax,ebp
jne loo
add esi,ebx
pop eax
inc eax
cmp eax,ecx
jne loo2
}
macro array_processing_nocall object_array,process
{
local read_next
lea edi,[object_array+8]
mov ecx,[object_array] ; dword contain quantity of elements
read_next:
pushad
call process
popad
add edi,[object_array+4] ; edi = edi + size of one element
dec ecx
jnz read_next
}
macro array_find_nocall object_array,process
{
local read_next,finded
lea edi,[object_array+8] ; edi = current position
mov ecx,[object_array] ; dword contain quantity of elements
read_next:
pushad
call process
popad
jnc finded
add edi,[object_array+4] ; dword contain size of each element
dec ecx
jnz read_next
; not finded
stc ; if not finded CF = 1
finded: ; if finded CF = 0
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB