Автор: zzz528
Дата сообщения: 06.10.2007 01:02
Umbrall
Если под windows то это довольно легко можно сделать через GDI.
[more]
мне монравилсаь эта задача захотел сам такое сделать
вот что получилось:
прога собираеться масмом:
ml -c -coff -Cp romb.asm
link -release -subsystem:windows -entry:start romb.obj
листниги inc файлов не включены
замените своими
Код:
;romb.asm
.486
.model flat
include kernel.inc
include user.inc
include gdi.inc
.code
public _start
_start:
push ebp
mov ebp,esp
xor ebx,ebx
push ebx
call GetModuleHandle
mov hinst,eax
mov rombik.hInstance,eax
push IDI_WINLOGO
push ebx
call LoadIcon
mov rombik.hIcon,eax
push IDC_ARROW
push ebx
call LoadCursor
mov rombik.hCursor,eax
push offset rombik
call RegisterClassEx
push ebx
push hinst
push ebx
push ebx
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push CW_USEDEFAULT
push WS_CAPTION+WS_VISIBLE+WS_SYSMENU
push offset name_romb
push offset name_romb
push ebx
call CreateWindowEx
cycl_msg:
push ebx
push ebx
push ebx
push offset romb_msg
call GetMessage
or eax,eax
jz end_cycl_msg
push offset romb_msg
call TranslateMessage
push offset romb_msg
call DispatchMessage
jmp cycl_msg
end_cycl_msg:
mov esp,ebp
pop ebp
ret
romb_main:
;-----
push ebp
mov ebp,esp
mov eax,[ebp+12]
cmp eax,WM_CREATE
je wmcreate
cmp eax,WM_DESTROY
je wmdestroy
cmp eax,WM_PAINT
je wmpaint
mov esp,ebp
pop ebp
jmp DefWindowProc
wmcreate:
assume edi:PTR RECT
mov directn,ebx
mov edi,offset client_rect
push edi
push [ebp+8]
call GetClientRect
mov esi,offset romb_vertices
mov ecx,[edi].right
shr ecx,1
mov eax,ecx
mov [esi+8],eax
mov [esi+24],eax
sub eax,50
mov [esi],eax
add ecx,50
mov [esi+16],ecx
mov ecx,[edi].bottom
shr ecx,1
mov eax,ecx
mov [esi+4],ecx
mov [esi+20],ecx
sub eax,70
mov [esi+12],eax
add ecx,70
mov [esi+28],ecx
push timer_proc
push 10
push 1
push [ebp+8]
call SetTimer
jmp exit_false
wmdestroy:
push 1
push [ebp+8]
call KillTimer
push ebx
call PostQuitMessage
jmp exit_wndproc
wmpaint:
sub esp,size PAINTSTRUCT
mov esi,esp
assume esi:PTR PAINTSTRUCT
push esi
push [ebp+8]
call BeginPaint
push 4
push offset romb_vertices
push eax
call Polygon
push esi
push [ebp+8]
call EndPaint
jmp exit_false
exit_false:
xor eax,eax
exit_wndproc:
mov esp,ebp
pop ebp
ret 16
timer_proc:
lea esi,romb_vertices
mov eax,10
cmp directn,1
jz move_right
sub dword ptr [esi],eax
sub dword ptr [esi+8],eax
sub dword ptr [esi+16],eax
sub dword ptr [esi+24],eax
cmp dword ptr [esi],0
jns @f
mov directn,1
@@:
jmp paint
move_right:
add dword ptr [esi],eax
add dword ptr [esi+8],eax
add dword ptr [esi+16],eax
add dword ptr [esi+24],eax
mov ecx,dword ptr client_rect+8
cmp ecx,dword ptr [esi+16]
ja @f
mov directn,0
@@:
paint:
mov eax,[esp+4]
push 1
push offset client_rect
push eax
call InvalidateRect
ret 16
.data
rombik WNDCLASSEX<size rombik,CS_HREDRAW+CS_VREDRAW,\
offset romb_main,0,0,0,0, \
0,COLOR_MENU+1,0,offset name_romb,0>
name_romb db 'Romb',0
.data?
romb_vertices dd 8 dup(?)
client_rect RECT<?>
directn dd ?
hinst dd ?
hwnd dd ?
romb_msg MSG<?>
end