Subversion Repositories Kolibri OS

Rev

Rev 2094 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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