Subversion Repositories Kolibri OS

Rev

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

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