Subversion Repositories Kolibri OS

Rev

Rev 6196 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6196 Rev 7786
1
include '../../../../proc32.inc'
1
include '../../../../proc32.inc'
2
 
2
 
3
struc system_colors
3
struc system_colors
4
{
4
{
5
  .frame            dd ?
5
  .frame            dd ?
6
  .grab             dd ?
6
  .grab             dd ?
7
  .work_3d_dark      dd ?
7
  .work_dark        dd ?
8
  .work_3d_light dd ?
8
  .work_light       dd ?
9
  .grab_text        dd ?
9
  .grab_text        dd ?
10
  .work             dd ?
10
  .work             dd ?
11
  .work_button      dd ?
11
  .work_button      dd ?
12
  .work_button_text dd ?
12
  .work_button_text dd ?
13
  .work_text        dd ?
13
  .work_text        dd ?
14
  .work_graph       dd ?
14
  .work_graph       dd ?
15
}
15
}
16
 
16
 
17
macro _read_file path, offset, data, count
17
macro _read_file path, offset, data, count
18
{
18
{
19
   mov eax, dword path
19
   mov eax, dword path
20
   mov ebx, dword data
20
   mov ebx, dword data
21
   mov ecx, dword offset
21
   mov ecx, dword offset
22
   mov edx, dword count
22
   mov edx, dword count
23
 
23
 
24
   push 0
24
   push 0
25
   push 0
25
   push 0
26
   mov [esp+1], eax
26
   mov [esp+1], eax
27
   push ebx
27
   push ebx
28
   push edx
28
   push edx
29
   push 0
29
   push 0
30
   push ecx
30
   push ecx
31
   push 0
31
   push 0
32
   mov ebx, esp
32
   mov ebx, esp
33
   mov eax, 70
33
   mov eax, 70
34
   int 0x40
34
   int 0x40
35
   add esp, 28
35
   add esp, 28
36
}
36
}
37
 
37
 
38
use32
38
use32
39
 
39
 
40
db 'MENUET01'
40
db 'MENUET01'
41
dd 1
41
dd 1
42
dd start
42
dd start
43
dd i_end
43
dd i_end
44
dd mem
44
dd mem
45
dd mem
45
dd mem
46
dd 0
46
dd 0
47
dd app_path
47
dd app_path
48
 
48
 
49
include 'pixlib.inc'
49
include 'pixlib.inc'
50
 
50
 
51
align 4
51
align 4
52
start:
52
start:
53
           fix_cwd app_path
53
           fix_cwd app_path
54
 
54
 
55
           call load_pxlib
55
           call load_pxlib
56
           test eax, eax
56
           test eax, eax
57
           jz .fail
57
           jz .fail
58
 
58
 
59
           mov  eax,48                      ; get system colors
59
           mov  eax,48                      ; get system colors
60
           mov  ebx,3
60
           mov  ebx,3
61
           mov  ecx,sc
61
           mov  ecx,sc
62
           mov  edx,10*4
62
           mov  edx,10*4
63
           int 0x40
63
           int 0x40
64
 
64
 
65
           CreatePixmap 640, 384, ARGB32, PX_MEM_LOCAL   ; animation
65
           CreatePixmap 640, 384, ARGB32, PX_MEM_LOCAL   ; animation
66
           mov [pix_0], eax
66
           mov [pix_0], eax
67
           test eax, eax
67
           test eax, eax
68
           jz .fail
68
           jz .fail
69
 
69
 
70
           CreatePixmap 64, 64, ARGB32, PX_MEM_LOCAL     ; saved screen
70
           CreatePixmap 64, 64, ARGB32, PX_MEM_LOCAL     ; saved screen
71
           mov [pix_1], eax
71
           mov [pix_1], eax
72
           test eax, eax
72
           test eax, eax
73
           jz .fail
73
           jz .fail
74
 
74
 
75
           CreatePixmap 64, 64, ARGB32, PX_MEM_LOCAL     ; back buffer
75
           CreatePixmap 64, 64, ARGB32, PX_MEM_LOCAL     ; back buffer
76
           mov [pix_2], eax
76
           mov [pix_2], eax
77
 
77
 
78
           Blit [pix_1], 0,0, SCR_PIXMAP, 0,0, 64,64
78
           Blit [pix_1], 0,0, SCR_PIXMAP, 0,0, 64,64
79
 
79
 
80
           LockPixmap [pix_0]
80
           LockPixmap [pix_0]
81
              mov ebx, eax
81
              mov ebx, eax
82
              _read_file szfile, 128, ebx, 640*384*4
82
              _read_file szfile, 128, ebx, 640*384*4
83
           UnlockPixmap [pix_0]
83
           UnlockPixmap [pix_0]
84
 
84
 
85
 
85
 
86
.redraw:
86
.redraw:
87
           call draw_window
87
           call draw_window
88
 
88
 
89
.wait_event:
89
.wait_event:
90
 
90
 
91
           mov ebx, 2
91
           mov ebx, 2
92
           mov eax, 23
92
           mov eax, 23
93
           int 0x40
93
           int 0x40
94
 
94
 
95
 
95
 
96
           dec eax                  ;   if event = 1
96
           dec eax                  ;   if event = 1
97
           jz  .redraw              ;   jump to redraw handler
97
           jz  .redraw              ;   jump to redraw handler
98
           dec eax                  ;   else if event = 2
98
           dec eax                  ;   else if event = 2
99
           jz  .key                 ;   jump to key handler
99
           jz  .key                 ;   jump to key handler
100
           dec eax
100
           dec eax
101
           jz  .button
101
           jz  .button
102
 
102
 
103
           Blit   [pix_2], 0,0, [pix_1], 0,0, 64,64
103
           Blit   [pix_2], 0,0, [pix_1], 0,0, 64,64
104
 
104
 
105
           mov eax, [count]
105
           mov eax, [count]
106
           inc eax
106
           inc eax
107
           cmp eax, 60
107
           cmp eax, 60
108
           jb @F
108
           jb @F
109
           xor eax, eax
109
           xor eax, eax
110
@@:
110
@@:
111
           mov [count], eax
111
           mov [count], eax
112
 
112
 
113
           xor edx, edx
113
           xor edx, edx
114
           mov ebx, 10
114
           mov ebx, 10
115
           div ebx
115
           div ebx
116
 
116
 
117
           shl eax, 6
117
           shl eax, 6
118
           shl edx, 6
118
           shl edx, 6
119
 
119
 
120
           TransparentBlit [pix_2], 0,0, [pix_0], edx,eax, 64,64 ,0xFF000000
120
           TransparentBlit [pix_2], 0,0, [pix_0], edx,eax, 64,64 ,0xFF000000
121
           Blit SCR_PIXMAP, 0,0, [pix_2], 0, 0, 64,64
121
           Blit SCR_PIXMAP, 0,0, [pix_2], 0, 0, 64,64
122
 
122
 
123
           jmp .wait_event
123
           jmp .wait_event
124
 
124
 
125
.button:                               ; button event handler
125
.button:                               ; button event handler
126
           mov al, 17                  ;   get button identifier
126
           mov al, 17                  ;   get button identifier
127
           int 0x40
127
           int 0x40
128
 
128
 
129
           cmp ah, 1
129
           cmp ah, 1
130
           jne .wait_event             ;   return if button id != 1
130
           jne .wait_event             ;   return if button id != 1
131
.exit:
131
.exit:
132
                                       ; restore old screen and cleanup
132
                                       ; restore old screen and cleanup
133
 
133
 
134
           Blit SCR_PIXMAP, 0,0, [pix_1], 0, 0, 64,64
134
           Blit SCR_PIXMAP, 0,0, [pix_1], 0, 0, 64,64
135
 
135
 
136
           DestroyPixmap [pix_2]
136
           DestroyPixmap [pix_2]
137
           DestroyPixmap [pix_1]
137
           DestroyPixmap [pix_1]
138
           DestroyPixmap [pix_0]
138
           DestroyPixmap [pix_0]
139
.fail:
139
.fail:
140
           or eax, -1                  ;   exit application
140
           or eax, -1                  ;   exit application
141
           int 0x40
141
           int 0x40
142
.key:                                  ; key event handler
142
.key:                                  ; key event handler
143
           mov al, 2                   ;   get key code
143
           mov al, 2                   ;   get key code
144
           int 0x40
144
           int 0x40
145
 
145
 
146
           jmp .wait_event
146
           jmp .wait_event
147
 
147
 
148
draw_window:
148
draw_window:
149
           mov eax, 12                 ; start drawing
149
           mov eax, 12                 ; start drawing
150
           mov ebx, 1
150
           mov ebx, 1
151
           int 0x40
151
           int 0x40
152
 
152
 
153
           xor  eax, eax               ; create and draw the window
153
           xor  eax, eax               ; create and draw the window
154
           mov  ebx, 200*65536+200     ; (window_cx)*65536+(window_sx)
154
           mov  ebx, 200*65536+200     ; (window_cx)*65536+(window_sx)
155
           mov  ecx, 200*65536+100     ; (window_cy)*65536+(window_sy)
155
           mov  ecx, 200*65536+100     ; (window_cy)*65536+(window_sy)
156
           mov  edx, [sc.work]         ; work area color
156
           mov  edx, [sc.work]         ; work area color
157
           or   edx, 0x33000000        ; & window type 3
157
           or   edx, 0x33000000        ; & window type 3
158
           mov  edi, title             ; window title
158
           mov  edi, title             ; window title
159
           int  0x40
159
           int  0x40
160
 
160
 
161
           mov  eax, 12                ; finish drawing
161
           mov  eax, 12                ; finish drawing
162
           mov  ebx, 2
162
           mov  ebx, 2
163
           int  0x40
163
           int  0x40
164
 
164
 
165
           ret
165
           ret
166
 
166
 
167
align 4
167
align 4
168
 
168
 
169
count       dd  0
169
count       dd  0
170
 
170
 
171
title       db  'Transparent blit',0
171
title       db  'Transparent blit',0
172
 
172
 
173
szfile      db  'donut.dds',0
173
szfile      db  'donut.dds',0
174
 
174
 
175
i_end:
175
i_end:
176
 
176
 
177
align 4
177
align 4
178
 
178
 
179
pix_0       rd 1
179
pix_0       rd 1
180
pix_1       rd 1
180
pix_1       rd 1
181
pix_2       rd 1
181
pix_2       rd 1
182
 
182
 
183
sc   system_colors
183
sc   system_colors
184
 
184
 
185
 
185
 
186
align 4
186
align 4
187
 
187
 
188
app_path:
188
app_path:
189
 
189
 
190
rb 2048 ; stack
190
rb 2048 ; stack
191
mem:
191
mem: