Movback: Added support window resizing
Some checks failed
Build system / Check kernel codestyle (pull_request) Successful in 34s
Build system / Build (pull_request) Failing after 39s

This commit is contained in:
2025-03-17 00:43:15 +02:00
parent 1869449309
commit 34093cd781
2 changed files with 174 additions and 126 deletions

View File

@@ -1,7 +1,2 @@
if tup.getconfig("NO_FASM") ~= "" then return end if tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR") tup.rule("movback.asm", FASM .. " %f %o " .. tup.getconfig("KPACK_CMD"), "movback")
tup.include(HELPERDIR .. "/use_fasm.lua")
add_include(tup.getvariantdir())
tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "en_US" or tup.getconfig("LANG")) .. " > %o", {"lang.inc"})
tup.rule({"movback.asm", extra_inputs = {"lang.inc"}}, FASM .. " %f %o " .. tup.getconfig("KPACK_CMD"), "movback")

View File

@@ -7,166 +7,219 @@
include "../../macros.inc" include "../../macros.inc"
include "../../KOSfuncs.inc" include "../../KOSfuncs.inc"
WND_SIZE_X = 320 KOS_APP_START
WND_SIZE_Y = 200
Screen_W dd 600-10 ;10 px for borders
Screen_H dd 400
VC_DELTA = 1 VC_DELTA = 1
HC_DELTA = 2 HC_DELTA = 2
MEOS_APP_START
CODE CODE
fninit mcall SF_SYS_MISC,SSF_HEAP_INIT
call init_sinus_table call OnResize
call init_background fninit
call init_palette call init_sinus_table
mcall SF_SET_EVENTS_MASK, 101b call init_background
jmp .paint_window call init_palette
mcall SF_SET_EVENTS_MASK, 101b
jmp .paint_window
align 4
.event_loop: .event_loop:
mcall SF_WAIT_EVENT_TIMEOUT, 1 mcall SF_WAIT_EVENT_TIMEOUT, 1
test eax,eax test eax,eax
je .draw_screen je .draw_screen
dec eax dec eax
je .paint_window je .paint_window
mcall SF_TERMINATE_PROCESS mcall SF_TERMINATE_PROCESS
.draw_screen: .draw_screen:
test [proc_info.wnd_state], 0x04 test [proc_info.wnd_state], 0x04
jnz .event_loop jnz .event_loop
add word [ver_counter],VC_DELTA add word [ver_counter],VC_DELTA
add word [hor_counter],HC_DELTA add word [hor_counter],HC_DELTA
call handle_animation call handle_animation
xor ebp,ebp xor ebp,ebp
mcall SF_PUT_IMAGE_EXT, virtual_screen_8,<WND_SIZE_X,WND_SIZE_Y>,<0,0>,8,_palette mov ecx,[Screen_W]
jmp .event_loop shl ecx,16
add ecx,[Screen_H]
mcall SF_PUT_IMAGE_EXT, [virtual_screen_8],,<0,0>,8,_palette
jmp .event_loop
.paint_window: .paint_window:
mcall SF_THREAD_INFO, proc_info,-1 mcall SF_THREAD_INFO, proc_info,-1
mcall SF_REDRAW, SSF_BEGIN_DRAW cmp dword[proc_info.box.height],0
je .resize_end
mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
add eax,4
sub eax,[proc_info.box.height]
neg eax
cmp eax,[Screen_H]
je .end_h
cmp eax,32 ;min height
jge @f
mov eax,32
@@:
mov [Screen_H],eax
xor eax,eax
mov [Screen_W],eax
.end_h:
mov eax,[proc_info.box.width]
sub eax,9
cmp eax,[Screen_W]
je .resize_end
cmp eax,64 ;min width
jge @f
mov eax,64
@@:
mov [Screen_W],eax
mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT call OnResize
lea ecx,[eax + (100 shl 16) + WND_SIZE_Y+4] .resize_end:
mov edi,title
mcall SF_CREATE_WINDOW, <100,WND_SIZE_X+9>,,0x74000000
test [proc_info.wnd_state], 0x04 mcall SF_REDRAW, SSF_BEGIN_DRAW
jnz @f
xor ebp,ebp mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
mcall SF_PUT_IMAGE_EXT, virtual_screen_8,<WND_SIZE_X,WND_SIZE_Y>,<0,0>,8,_palette lea ecx,[eax + (100 shl 16) +4]
@@: add ecx,[Screen_H]
mcall SF_REDRAW, SSF_END_DRAW mov edi,title
mov ebx,(100 shl 16)+9
add ebx,[Screen_W]
mcall SF_CREATE_WINDOW,,,0x73000000
jmp .event_loop test [proc_info.wnd_state], 0x04
jnz @f
xor ebp,ebp
mov ecx,[Screen_W]
shl ecx,16
add ecx,[Screen_H]
mcall SF_PUT_IMAGE_EXT, [virtual_screen_8],,<0,0>,8,_palette
@@:
mcall SF_REDRAW, SSF_END_DRAW
jmp .event_loop
init_palette: init_palette:
mov ecx,256 mov ecx,256
mov edi,_palette mov edi,_palette
xor eax,eax xor eax,eax
.next_pal: .next_pal:
mov al,ah mov al,ah
shr al,2 shr al,2
stosb stosb
stosb stosb
stosb stosb
stosb stosb
inc ah inc ah
loop .next_pal loop .next_pal
ret ret
init_sinus_table: init_sinus_table:
sub esp,4 sub esp,4
mov ecx,256 mov ecx,256
mov edi,sinetable mov edi,sinetable
.sin_loop: .sin_loop:
fld dword [esp] fld dword [esp]
fld st0 fld st0
fsin fsin
fmul [scale_sin] fmul [scale_sin]
fistp word [edi] fistp word [edi]
fadd [delta_angle] fadd [delta_angle]
fstp dword [esp] fstp dword [esp]
add edi,2 add edi,2
loop .sin_loop loop .sin_loop
add esp,4 add esp,4
ret ret
init_background: init_background:
mov edi,background mov edi,background
xor edx,edx xor edx,edx
.ib_vertical: .ib_vertical:
xor ecx,ecx xor ecx,ecx
.ib_horizontal: .ib_horizontal:
mov eax,ecx mov eax,ecx
xor eax,edx xor eax,edx
stosb stosb
inc ecx inc ecx
cmp ecx,256 cmp ecx,256
jne .ib_horizontal jne .ib_horizontal
inc edx inc edx
cmp edx,256 cmp edx,256
jne .ib_vertical jne .ib_vertical
ret ret
s_OFFX = 0 align 4
s_OFFY = 2 OnResize:
mov ecx,[Screen_W]
imul ecx,[Screen_H]
mcall SF_SYS_MISC,SSF_MEM_REALLOC,,[virtual_screen_8]
mov [virtual_screen_8],eax
ret
s_OFFX = 0
s_OFFY = 2
handle_animation: handle_animation:
sub esp,4 sub esp,4
mov ebx,[ver_counter] mov ebx,[ver_counter]
and ebx,255 and ebx,255
add ebx,ebx add ebx,ebx
mov ax,[sinetable+ebx] mov ax,[sinetable+ebx]
mov [esp+s_OFFY],ax mov [esp+s_OFFY],ax
mov ebx,[hor_counter] mov ebx,[hor_counter]
and ebx,255 and ebx,255
add ebx,ebx add ebx,ebx
mov ax,[sinetable+ebx] mov ax,[sinetable+ebx]
mov [esp+s_OFFX],ax mov [esp+s_OFFX],ax
mov edi,virtual_screen_8 mov edi,[virtual_screen_8]
mov edx,WND_SIZE_Y-1 mov edx,[Screen_H]
dec edx
.a_ver: .a_ver:
mov ecx,WND_SIZE_X-1 mov ecx,[Screen_W]
mov bx,[esp+s_OFFY] dec ecx
add bx,dx mov bx,[esp+s_OFFY]
and ebx,255 add bx,dx
shl ebx,8 and ebx,255
shl ebx,8
.a_hor: .a_hor:
mov ax,[esp+s_OFFX] mov ax,[esp+s_OFFX]
add ax,cx add ax,cx
and eax,255 and eax,255
mov al,[background+ebx+eax] mov al,[background+ebx+eax]
stosb stosb
dec ecx dec ecx
jge .a_hor jge .a_hor
dec edx dec edx
jge .a_ver jge .a_ver
add esp,4 add esp,4
ret ret
DATA DATA
delta_angle dd 0.0245436926066 ; pi/128 delta_angle dd 0.0245436926066 ; pi/128
scale_sin dd 128.0 scale_sin dd 128.0
title db 'MoveBack',0 title db 'MoveBack',0
UDATA UDATA
ver_counter dd ? ver_counter dd ?
hor_counter dd ? hor_counter dd ?
_palette: rd 256 _palette: rd 256
virtual_screen_8: virtual_screen_8 dd ?
rb WND_SIZE_X*WND_SIZE_Y
background: background:
rb 256*256 rb 256*256
sinetable: sinetable:
rw 256 rw 256
proc_info process_information proc_info process_information
MEOS_APP_END KOS_APP_END