zSea - positioning for background "proportional stretching with cropping"

git-svn-id: svn://kolibrios.org@2188 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2011-09-15 21:49:56 +00:00
parent baa5810af4
commit 4450fd18c0
3 changed files with 325 additions and 45 deletions

View File

@ -78,10 +78,6 @@ background:
mov ebx,[screen_high] mov ebx,[screen_high]
call integer_division call integer_division
mov [stretch_img_width],eax mov [stretch_img_width],eax
mov ebx,[img_width]
sub ebx,eax
shr ebx,1
mov [stretch_start_coordinates.x],bx
jmp .continue jmp .continue
@@: @@:
; X = Ximg ; X = Ximg
@ -93,11 +89,18 @@ background:
mov ebx,[screen_width] mov ebx,[screen_width]
call integer_division call integer_division
mov [stretch_img_high],eax mov [stretch_img_high],eax
mov ebx,[img_high]
sub ebx,eax
shr ebx,1
mov [stretch_start_coordinates.y],bx
.continue: .continue:
mov eax,[Stretch_Crop_Corner]
mov ebx,eax
shr eax,16
shl eax,2
mov eax,[eax+call_to_calculate_stretch_start_coordinates_Y]
call eax
and ebx,0xffff
shl ebx,2
mov ebx,[ebx+call_to_calculate_stretch_start_coordinates_X]
call ebx
mov ebx,[screen_width] mov ebx,[screen_width]
shl ebx,16 shl ebx,16
add ebx,[screen_high] add ebx,[screen_high]
@ -119,6 +122,52 @@ background:
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
call_to_calculate_stretch_start_coordinates_X:
dd calculate_stretch_start_coordinates_XL
dd calculate_stretch_start_coordinates_XC
dd calculate_stretch_start_coordinates_XR
;---------------------------------------------------------------------
call_to_calculate_stretch_start_coordinates_Y:
dd calculate_stretch_start_coordinates_YU
dd calculate_stretch_start_coordinates_YC
dd calculate_stretch_start_coordinates_YD
;---------------------------------------------------------------------
calculate_stretch_start_coordinates_XC:
xor ecx,ecx
.1:
mov eax,[img_width]
sub eax,[stretch_img_width]
test ecx,ecx
jnz @f
shr eax,1
@@:
mov [stretch_start_coordinates.x],ax
calculate_stretch_start_coordinates_XL:
ret
;---------------------------------------------------------------------
calculate_stretch_start_coordinates_XR:
xor ecx,ecx
inc ecx
jmp calculate_stretch_start_coordinates_XC.1
;---------------------------------------------------------------------
calculate_stretch_start_coordinates_YC:
xor ecx,ecx
.1:
mov eax,[img_high]
sub eax,[stretch_img_high]
test ecx,ecx
jnz @f
shr eax,1
@@:
mov [stretch_start_coordinates.y],ax
calculate_stretch_start_coordinates_YU:
ret
;---------------------------------------------------------------------
calculate_stretch_start_coordinates_YD:
xor ecx,ecx
inc ecx
jmp calculate_stretch_start_coordinates_YC.1
;---------------------------------------------------------------------
;.stretch_inscribe: ;.stretch_inscribe:
; ret ; ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------

View File

@ -893,7 +893,7 @@ op1 option_box option_group1,60,40,6,12,0xFFFFFF,0,0xffffff,op_text.1,op_text.e1
op2 option_box option_group1,60,55,6,12,0xFFFFFF,0,0xffffff,op_text.2,op_text.e2-op_text.2 op2 option_box option_group1,60,55,6,12,0xFFFFFF,0,0xffffff,op_text.2,op_text.e2-op_text.2
op3 option_box option_group1,60,70,6,12,0xFFFFFF,0,0xffffff,op_text.3,op_text.e3-op_text.3 op3 option_box option_group1,60,70,6,12,0xFFFFFF,0,0xffffff,op_text.3,op_text.e3-op_text.3
op4 option_box option_group1,60,85,6,12,0xFFFFFF,0,0xffffff,op_text.4,op_text.e4-op_text.4 op4 option_box option_group1,60,85,6,12,0xFFFFFF,0,0xffffff,op_text.4,op_text.e4-op_text.4
option_boxes_bcgr_end: ;option_boxes_bcgr_end:
op_text: op_text:
.1 db 'Tiled' .1 db 'Tiled'
@ -908,6 +908,26 @@ op_text:
option_group1 dd op1 option_group1 dd op1
option_boxes_bcgr: dd op1,op2,op3,op4,0 option_boxes_bcgr: dd op1,op2,op3,op4,0
;---------------------------------------------------------------------
align 4
op_UL option_box option_group3,200,40,20,20,0xFFFFFF,0,0xffffff,0,0
op_UC option_box option_group3,223,40,20,20,0xFFFFFF,0,0xffffff,0,0
op_UR option_box option_group3,246,40,20,20,0xFFFFFF,0,0xffffff,0,0
op_CL option_box option_group3,200,63,20,20,0xFFFFFF,0,0xffffff,0,0
op_CC option_box option_group3,223,63,20,20,0xFFFFFF,0,0xffffff,0,0
op_CR option_box option_group3,246,63,20,20,0xFFFFFF,0,0xffffff,0,0
op_DL option_box option_group3,200,86,20,20,0xFFFFFF,0,0xffffff,0,0
op_DC option_box option_group3,223,86,20,20,0xFFFFFF,0,0xffffff,0,0
op_DR option_box option_group3,246,86,20,20,0xFFFFFF,0,0xffffff,0,0
;option_boxes_bcgr_end:
option_group3 dd op_CC
Stretch_Crop_Corner dd 1 shl 16+1
option_boxes_SCC: dd op_UL,op_UC,op_UR,op_CL,op_CC,op_CR,op_DL,op_DC,op_DR,0
bcgr_group_pointer db 0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
;option_boxes_sort: ;option_boxes_sort:

View File

@ -35,30 +35,58 @@ thread4: ; start of bgrd thread
jmp .still jmp .still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.mouse: .mouse:
mov eax,option_group1
mov ecx,[eax]
push dword option_boxes_bcgr push dword option_boxes_bcgr
call [option_box_mouse] call [option_box_mouse]
cmp ecx,[eax]
je .option_boxes_SCC
cmp [option_group1],op1 mov ebx,bgrmode
cmp [eax],dword op1
jne @f jne @f
mov [bgrmode],dword 1 mov [ebx],dword 1
jmp .still jmp .option_group1_color_set
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@@: @@:
cmp [option_group1],op2 cmp [eax],dword op2
jne @f jne @f
mov [bgrmode],dword 2 mov [ebx],dword 2
jmp .still jmp .option_group1_color_set
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@@: @@:
cmp [option_group1],op3 cmp [eax],dword op3
jne @f jne @f
mov [bgrmode],dword 3 mov [ebx],dword 3
jmp .still jmp .option_group1_color_set
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
@@: @@:
; cmp [option_group1],op4 cmp [eax],dword op4
; jne .still jne .option_boxes_SCC
mov [bgrmode],dword 4 mov [ebx],dword 4
.option_group1_color_set:
mov [bcgr_group_pointer],0
call .option_boxes_redraw
jmp .still
;---------------------------------------------------------------------
.option_boxes_SCC:
mov eax,[option_group3]
push dword option_boxes_SCC
call [option_box_mouse]
cmp eax,[option_group3]
je .still
call .convert_1
mov [bcgr_group_pointer],1
call .option_boxes_redraw
jmp .still
;---------------------------------------------------------------------
.tab:
mov al,[bcgr_group_pointer]
inc al
and al,1
mov [bcgr_group_pointer],al
call .option_boxes_redraw
jmp .still jmp .still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.key: .key:
@ -69,56 +97,215 @@ thread4: ; start of bgrd thread
cmp ah,13 cmp ah,13
je .kok je .kok
cmp ah,9
je .tab
cmp [bcgr_group_pointer],1
je .key_option_group3
;---------------------------------------------------------------------
.key_option_group1:
mov ebx,bgrmode
cmp ah,178 ;up cmp ah,178 ;up
jne .nofup jne .nofup
cmp dword [bgrmode],1 cmp [ebx],dword 1
je .fdn je .fdn
.fup: .fup:
dec dword [bgrmode] dec dword [ebx]
jmp .flagcont jmp .flagcont
;--------------------------------------------------------------------- ;--------------------------------------
.nofup: .nofup:
cmp ah,177 ;down cmp ah,177 ;down
jne .still jne .still
cmp dword [bgrmode],4 cmp [ebx],dword 4
je .fup je .fup
.fdn: .fdn:
inc dword [bgrmode] inc dword [ebx]
.flagcont: .flagcont:
cmp [bgrmode],dword 1 mov eax,option_group1
cmp [ebx],dword 1
jne @f jne @f
mov [option_group1],op1 mov [eax],dword op1
call .draw_opt_boxes call .draw_opt_boxes_bcgr
jmp .still jmp .still
;--------------------------------------------------------------------- ;---------------------------------------
@@: @@:
cmp [bgrmode],dword 2 cmp [ebx],dword 2
jne @f jne @f
mov [option_group1],op2 mov [eax],dword op2
call .draw_opt_boxes call .draw_opt_boxes_bcgr
jmp .still jmp .still
;--------------------------------------------------------------------- ;----------------------------------------
@@: @@:
cmp [bgrmode],dword 3 cmp [ebx],dword 3
jne @f jne @f
mov [option_group1],op3 mov [eax],dword op3
call .draw_opt_boxes call .draw_opt_boxes_bcgr
jmp .still
;-----------------------------------------
@@:
mov [eax],dword op4
call .draw_opt_boxes_bcgr
jmp .still jmp .still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.key_option_group3:
push eax
call .convert_1
pop eax
cmp ah,178 ;up
jne @f
dec word [ebx+2]
jmp .flagcont_1
;------------------------------------------
@@: @@:
mov [option_group1],op4 cmp ah,177 ;down
call .draw_opt_boxes jne @f
inc word [ebx+2]
jmp .flagcont_1
;------------------------------------------
@@:
cmp ah,176 ;left
jne @f
dec word [ebx]
jmp .flagcont_1
;------------------------------------------
@@:
cmp ah,179 ;right
jne .still
inc word [ebx]
;------------------------------------------
.flagcont_1:
call .convert_2
call .convert_1 ;for additional check
call .draw_opt_boxes_SCC
jmp .still jmp .still
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.convert_1:
mov eax,option_group3
mov ebx,Stretch_Crop_Corner
cmp [eax],dword op_UL
jne @f
mov [ebx],dword 0 shl 16+0
jmp .option_group3_color_set
;----------------------------------------
@@:
cmp [eax],dword op_UC
jne @f
mov [ebx],dword 0 shl 16+1
jmp .option_group3_color_set
;-----------------------------------------
@@:
cmp [eax],dword op_UR
jne @f
mov [ebx],dword 0 shl 16+2
jmp .option_group3_color_set
;-----------------------------------------
@@:
cmp [eax],dword op_CL
jne @f
mov [ebx],dword 1 shl 16+0
jmp .option_group3_color_set
;------------------------------------------
@@:
cmp [eax],dword op_CC
jne @f
mov [ebx],dword 1 shl 16+1
jmp .option_group3_color_set
;-------------------------------------------
@@:
cmp [eax],dword op_CR
jne @f
mov [ebx],dword 1 shl 16+2
jmp .option_group3_color_set
;--------------------------------------------
@@:
cmp [eax],dword op_DL
jne @f
mov [ebx],dword 2 shl 16+0
jmp .option_group3_color_set
;--------------------------------------------
@@:
cmp [eax],dword op_DC
jne @f
mov [ebx],dword 2 shl 16+1
jmp .option_group3_color_set
;--------------------------------------------
@@:
cmp [eax],dword op_DR
jne .option_group3_color_set
mov [ebx],dword 2 shl 16+2
.option_group3_color_set:
ret
;---------------------------------------------------------------------
.convert_2:
mov eax,Stretch_Crop_Corner
mov ebx,option_group3
cmp [eax],dword 0 shl 16+0
jne @f
mov [ebx],dword op_UL
jmp .Stretch_Crop_Corner_set
;----------------------------------------
@@:
cmp [eax],dword 0 shl 16+1
jne @f
mov [ebx],dword op_UC
jmp .Stretch_Crop_Corner_set
;-----------------------------------------
@@:
cmp [eax],dword 0 shl 16+2
jne @f
mov [ebx],dword op_UR
jmp .Stretch_Crop_Corner_set
;-----------------------------------------
@@:
cmp [eax],dword 1 shl 16+0
jne @f
mov [ebx],dword op_CL
jmp .Stretch_Crop_Corner_set
;------------------------------------------
@@:
cmp [eax],dword 1 shl 16+1
jne @f
mov [ebx],dword op_CC
jmp .Stretch_Crop_Corner_set
;-------------------------------------------
@@:
cmp [eax],dword 1 shl 16+2
jne @f
mov [ebx],dword op_CR
jmp .Stretch_Crop_Corner_set
;--------------------------------------------
@@:
cmp [eax],dword 2 shl 16+0
jne @f
mov [ebx],dword op_DL
jmp .Stretch_Crop_Corner_set
;--------------------------------------------
@@:
cmp [eax],dword 2 shl 16+1
jne @f
mov [ebx],dword op_DC
jmp .Stretch_Crop_Corner_set
;--------------------------------------------
@@:
cmp [eax],dword 2 shl 16+2
jne .Stretch_Crop_Corner_set
mov [ebx],dword op_DR
.Stretch_Crop_Corner_set:
ret
;---------------------------------------------------------------------
.button: ; button .button: ; button
mov eax,17 ; get id mcall 17 ; get id
mcall
cmp ah,1 ; button id=1 ? cmp ah,1 ; button id=1 ?
jne .noclose jne .noclose
.close: .close:
@ -141,18 +328,42 @@ thread4: ; start of bgrd thread
mcall 12,1 mcall 12,1
xor eax,eax xor eax,eax
xor esi,esi xor esi,esi
mcall ,<100,200>,<100,200>,0x13909090,,labelt4 mcall ,<100,300>,<100,150>,0x13909090,,labelt4
mcall 8,<70,40>,<110,20>,4,0xdddddd mcall 8,<70,40>,<110,20>,4,0xdddddd
mcall 4,<46,28>,0xffffff,bgrdtext,bgrdtext.size mcall 4,<46,28>,0xffffff,bgrdtext,bgrdtext.size
add ebx,40*65536+88 add ebx,40*65536+88
xor ecx,ecx xor ecx,ecx
mcall ,,,ok_btn,ok_btn.size mcall ,,,ok_btn,ok_btn.size
call .draw_opt_boxes call .option_boxes_redraw
; mcall 47,0x80000,[PID4],<200, 5>,0xffffff ; mcall 47,0x80000,[PID4],<200, 5>,0xffffff
mcall 12,2 mcall 12,2
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.draw_opt_boxes: .option_boxes_redraw:
call .draw_opt_boxes_bcgr
call .draw_opt_boxes_SCC
ret
;---------------------------------------------------------------------
.draw_opt_boxes_bcgr:
mov edx,0x13909090
cmp [bcgr_group_pointer],0
jne @f
mov edx,0xffff80
@@:
mcall 13,<59,14>,<39,59>,
push dword option_boxes_bcgr push dword option_boxes_bcgr
call [option_box_draw] call [option_box_draw]
ret
;---------------------------------------------------------------------
.draw_opt_boxes_SCC:
mov edx,0x13909090
cmp [bcgr_group_pointer],1
jne @f
mov edx,0xffff80
@@:
mcall 13,<198,70>,<38,70>,
push dword option_boxes_SCC
call [option_box_draw]
ret ret