Subversion Repositories Kolibri OS

Rev

Rev 2094 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
include "lang.inc"
2094 dunkaist 2
include "../../../macros.inc"
31 halyavin 3
 
4
WND_SIZE_X		= 320
5
WND_SIZE_Y		= 200
6
 
7
VC_DELTA = 1
8
HC_DELTA = 2
9
 
10
MEOS_APP_START
11
CODE
12
    fninit
13
    call init_sinus_table
14
    call init_background
15
    call init_palette
16
    mov eax,40
17
    mov ebx,101b
485 heavyiron 18
    mcall
31 halyavin 19
    jmp .paint_window
20
 
21
.event_loop:
22
    mov eax,23
23
    mov ebx,1
485 heavyiron 24
    mcall
31 halyavin 25
 
26
    test eax,eax
27
    je .draw_screen
28
    dec eax
29
    je .paint_window
30
 
31
    or  eax,-1
485 heavyiron 32
    mcall
31 halyavin 33
 
34
.draw_screen:
2094 dunkaist 35
    test [proc_info.wnd_state], 0x04
36
    jnz .event_loop
31 halyavin 37
    add word [ver_counter],VC_DELTA
38
    add word [hor_counter],HC_DELTA
39
    call handle_animation
2597 clevermous 40
    xor ebp,ebp
41
    mcall 65,virtual_screen_8,,<0,0>,8,_palette
31 halyavin 42
    jmp .event_loop
43
 
44
.paint_window:
2094 dunkaist 45
	mcall	9,proc_info,-1
31 halyavin 46
    mov eax,12
47
    mov ebx,1
485 heavyiron 48
    mcall
31 halyavin 49
 
2597 clevermous 50
    mcall 48,4 ; get skin height
51
    lea ecx,[eax + (100 shl 16) + WND_SIZE_Y+4]
485 heavyiron 52
    mov edi,title
2597 clevermous 53
    mcall 0,<100,WND_SIZE_X+9>,,0x74000000
31 halyavin 54
 
2094 dunkaist 55
    test [proc_info.wnd_state], 0x04
56
    jnz @f
57
 
2597 clevermous 58
    xor ebp,ebp
59
    mcall 65,virtual_screen_8,,<0,0>,8,_palette
2094 dunkaist 60
  @@:
31 halyavin 61
    mov eax,12
62
    mov ebx,2
485 heavyiron 63
    mcall
31 halyavin 64
 
65
    jmp .event_loop
66
 
67
init_palette:
68
    mov ecx,256
69
    mov edi,_palette
70
    xor eax,eax
71
.next_pal:
72
    mov al,ah
73
    shr al,2
74
    stosb
75
    stosb
76
    stosb
2597 clevermous 77
    stosb
31 halyavin 78
    inc ah
79
    loop .next_pal
80
    ret
81
 
82
init_sinus_table:
83
    sub esp,4
84
    mov ecx,256
85
    mov edi,sinetable
86
.sin_loop:
87
    fld dword [esp]
88
    fld st0
89
    fsin
90
    fmul [scale_sin]
91
    fistp word [edi]
92
    fadd [delta_angle]
93
    fstp dword [esp]
94
    add edi,2
95
    loop .sin_loop
96
    add esp,4
97
    ret
98
 
99
init_background:
100
    mov edi,background
101
    xor edx,edx
102
.ib_vertical:
103
    xor ecx,ecx
104
.ib_horizontal:
105
    mov eax,ecx
106
    xor eax,edx
107
    stosb
108
    inc ecx
109
    cmp ecx,256
110
    jne .ib_horizontal
111
    inc edx
112
    cmp edx,256
113
    jne .ib_vertical
114
    ret
115
 
116
s_OFFX		= 0
117
s_OFFY		= 2
118
 
119
handle_animation:
120
    sub esp,4
121
    mov ebx,[ver_counter]
122
    and ebx,255
123
    add ebx,ebx
124
    mov ax,[sinetable+ebx]
125
    mov [esp+s_OFFY],ax
126
    mov ebx,[hor_counter]
127
    and ebx,255
128
    add ebx,ebx
129
    mov ax,[sinetable+ebx]
130
    mov [esp+s_OFFX],ax
2597 clevermous 131
    mov edi,virtual_screen_8
31 halyavin 132
    mov edx,WND_SIZE_Y-1
133
.a_ver:
134
    mov ecx,WND_SIZE_X-1
135
    mov bx,[esp+s_OFFY]
136
    add bx,dx
137
    and ebx,255
138
    shl ebx,8
139
.a_hor:
140
    mov ax,[esp+s_OFFX]
141
    add ax,cx
142
    and eax,255
2597 clevermous 143
    mov al,[background+ebx+eax]
31 halyavin 144
    stosb
145
    dec ecx
146
    jge .a_hor
147
    dec edx
148
    jge .a_ver
149
    add esp,4
150
    ret
151
 
152
DATA
153
  delta_angle dd 0.0245436926066		; pi/128
154
  scale_sin dd 128.0
155
 
485 heavyiron 156
  title      db 'MoveBack',0
31 halyavin 157
 
158
UDATA
159
  ver_counter dd ?
160
  hor_counter dd ?
161
 
162
  _palette:	rd 256
163
 
2597 clevermous 164
  virtual_screen_8:
165
  	rb WND_SIZE_X*WND_SIZE_Y
31 halyavin 166
 
167
  background:
168
  	rb 256*256
169
 
170
  sinetable:
171
  	rw 256
172
 
2094 dunkaist 173
  proc_info	process_information
174
 
175
MEOS_APP_END