Rev 2656 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2656 | Rev 3013 | ||
---|---|---|---|
1 | ;***************************************************************************** |
1 | ;***************************************************************************** |
2 | ; CROPFLAT - set limits of screen - for Kolibri OS |
2 | ; CROPFLAT - set limits of screen - for Kolibri OS |
3 | ; Copyright (c) 2012, Marat Zakiyanov aka Mario79, aka Mario |
3 | ; Copyright (c) 2012, Marat Zakiyanov aka Mario79, aka Mario |
4 | ; All rights reserved. |
4 | ; All rights reserved. |
5 | ; |
5 | ; |
6 | ; Redistribution and use in source and binary forms, with or without |
6 | ; Redistribution and use in source and binary forms, with or without |
7 | ; modification, are permitted provided that the following conditions are met: |
7 | ; modification, are permitted provided that the following conditions are met: |
8 | ; * Redistributions of source code must retain the above copyright |
8 | ; * Redistributions of source code must retain the above copyright |
9 | ; notice, this list of conditions and the following disclaimer. |
9 | ; notice, this list of conditions and the following disclaimer. |
10 | ; * Redistributions in binary form must reproduce the above copyright |
10 | ; * Redistributions in binary form must reproduce the above copyright |
11 | ; notice, this list of conditions and the following disclaimer in the |
11 | ; notice, this list of conditions and the following disclaimer in the |
12 | ; documentation and/or other materials provided with the distribution. |
12 | ; documentation and/or other materials provided with the distribution. |
13 | ; * Neither the name of the |
13 | ; * Neither the name of the |
14 | ; names of its contributors may be used to endorse or promote products |
14 | ; names of its contributors may be used to endorse or promote products |
15 | ; derived from this software without specific prior written permission. |
15 | ; derived from this software without specific prior written permission. |
16 | ; |
16 | ; |
17 | ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY |
17 | ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY |
18 | ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 | ; DISCLAIMED. IN NO EVENT SHALL |
20 | ; DISCLAIMED. IN NO EVENT SHALL |
21 | ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
26 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | ;***************************************************************************** |
27 | ;***************************************************************************** |
28 | ; |
28 | ; |
29 | ; Example run with parameters: |
29 | ; Example run with parameters: |
30 | ; CROPFLAT XS800 YS480 |
30 | ; CROPFLAT XS800 YS480 |
31 | ; |
31 | ; |
32 | ;------------------------------------------------------------------------------ |
32 | ;------------------------------------------------------------------------------ |
33 | use32 |
33 | use32 |
34 | org 0x0 |
34 | org 0x0 |
35 | 35 | ||
36 | db 'MENUET01' |
36 | db 'MENUET01' |
37 | dd 0x01 |
37 | dd 0x01 |
38 | dd START |
38 | dd START |
39 | dd IM_END |
39 | dd IM_END |
40 | dd I_END |
40 | dd I_END |
41 | dd stack_top |
41 | dd stack_top |
42 | dd boot_param |
42 | dd boot_param |
43 | dd 0x0 |
43 | dd 0x0 |
44 | 44 | ||
45 | include '../../macros.inc' |
45 | include '../../macros.inc' |
46 | ;include 'debug.inc' |
46 | ;include '../../debug.inc' |
47 | ;------------------------------------------------------------------------------ |
47 | ;------------------------------------------------------------------------------ |
48 | START: |
48 | START: |
49 | mcall 14 |
49 | mcall 14 |
50 | mov ebx,eax |
50 | mov ebx,eax |
51 | shr eax,16 |
51 | shr eax,16 |
52 | inc eax |
52 | inc eax |
53 | mov [x_size],eax |
53 | mov [x_size],eax |
54 | 54 | ||
55 | ; dps "CROPFLAT current X size: " |
55 | ; dps "CROPFLAT current X size: " |
56 | ; dpd eax |
56 | ; dpd eax |
57 | ; newline |
57 | ; newline |
58 | 58 | ||
59 | and ebx,0xffff |
59 | and ebx,0xffff |
60 | inc ebx |
60 | inc ebx |
61 | mov [y_size],ebx |
61 | mov [y_size],ebx |
62 | 62 | ||
63 | ; dps "CROPFLAT current Y size: " |
63 | ; dps "CROPFLAT current Y size: " |
64 | ; dpd ebx |
64 | ; dpd ebx |
65 | ; newline |
65 | ; newline |
66 | ;------------------------------------------------------------------------------ |
66 | ;------------------------------------------------------------------------------ |
67 | mov bx,word 'XS' |
67 | mov bx,word 'XS' |
68 | call find_value |
68 | call find_value |
69 | test eax,eax |
69 | test eax,eax |
70 | jnz .y |
70 | jnz .y |
71 | 71 | ||
72 | call convert_ASCII_to_BIN |
72 | call convert_ASCII_to_BIN |
73 | test ebx,ebx |
73 | test ebx,ebx |
74 | jz @f |
74 | jz @f |
75 | 75 | ||
76 | mov [x_size],ebx |
76 | mov [x_size],ebx |
77 | ;-------------------------------------- |
77 | ;-------------------------------------- |
78 | @@: |
78 | @@: |
79 | ; dps "CROPFLAT new X size: " |
79 | ; dps "CROPFLAT new X size: " |
80 | ; dpd ebx |
80 | ; dpd ebx |
81 | ; newline |
81 | ; newline |
82 | ;------------------------------------------------------------------------------ |
82 | ;------------------------------------------------------------------------------ |
83 | .y: |
83 | .y: |
84 | mov bx,word 'YS' |
84 | mov bx,word 'YS' |
85 | call find_value |
85 | call find_value |
86 | test eax,eax |
86 | test eax,eax |
87 | jnz .set |
87 | jnz .set |
88 | 88 | ||
89 | call convert_ASCII_to_BIN |
89 | call convert_ASCII_to_BIN |
90 | test ebx,ebx |
90 | test ebx,ebx |
91 | jz @f |
91 | jz @f |
92 | 92 | ||
93 | mov [y_size],ebx |
93 | mov [y_size],ebx |
94 | ;-------------------------------------- |
94 | ;-------------------------------------- |
95 | @@: |
95 | @@: |
96 | ; dps "CROPFLAT new Y size: " |
96 | ; dps "CROPFLAT new Y size: " |
97 | ; dpd ebx |
97 | ; dpd ebx |
98 | ; newline |
98 | ; newline |
99 | ;------------------------------------------------------------------------------ |
99 | ;------------------------------------------------------------------------------ |
100 | .set: |
100 | .set: |
101 | mcall 18,24,[x_size],[y_size] |
101 | mcall 18,24,[x_size],[y_size] |
102 | ;-------------------------------------- |
102 | ;-------------------------------------- |
103 | .exit: |
103 | .exit: |
104 | mcall -1 |
104 | mcall -1 |
105 | ;------------------------------------------------------------------------------ |
105 | ;------------------------------------------------------------------------------ |
106 | find_value: |
106 | find_value: |
107 | ; in: |
107 | ; in: |
108 | ; bx - word |
108 | ; bx - word |
109 | ; out: |
109 | ; out: |
110 | ; eax - 0 for valid value, -1 for invalid value |
110 | ; eax - 0 for valid value, -1 for invalid value |
111 | ; esi - ASCII value |
111 | ; esi - ASCII value |
112 | mov esi,boot_param |
112 | mov esi,boot_param |
113 | mov ecx,254 |
113 | mov ecx,254 |
114 | cld |
114 | cld |
115 | ;-------------------------------------- |
115 | ;-------------------------------------- |
116 | .loop: |
116 | .loop: |
117 | lodsw |
117 | lodsw |
118 | cmp ax,bx |
118 | cmp ax,bx |
119 | je @f |
119 | je @f |
120 | 120 | ||
121 | dec esi |
121 | dec esi |
122 | loop .loop |
122 | loop .loop |
123 | 123 | ||
124 | mov eax,-1 |
124 | mov eax,-1 |
125 | ret |
125 | ret |
126 | ;-------------------------------------- |
126 | ;-------------------------------------- |
127 | @@: |
127 | @@: |
128 | xor eax,eax |
128 | xor eax,eax |
129 | ret |
129 | ret |
130 | ;------------------------------------------------------------------------------ |
130 | ;------------------------------------------------------------------------------ |
131 | convert_ASCII_to_BIN: |
131 | convert_ASCII_to_BIN: |
132 | ; in: |
132 | ; in: |
133 | ; esi - ASCII value |
133 | ; esi - ASCII value |
134 | ; out: |
134 | ; out: |
135 | ; ebx - BIN value |
135 | ; ebx - BIN value |
136 | mov ecx,4 |
136 | mov ecx,4 |
137 | xor ebx,ebx |
137 | xor ebx,ebx |
138 | cld |
138 | cld |
139 | ;-------------------------------------- |
139 | ;-------------------------------------- |
140 | .loop: |
140 | .loop: |
141 | lodsb |
141 | lodsb |
142 | cmp al,0x30 ; 0 |
142 | cmp al,0x30 ; 0 |
143 | jb @f |
143 | jb @f |
144 | 144 | ||
145 | cmp al,0x39 ; 9 |
145 | cmp al,0x39 ; 9 |
146 | ja @f |
146 | ja @f |
147 | 147 | ||
148 | sub al,0x30 |
148 | sub al,0x30 |
149 | ; multiply by 10 |
149 | ; multiply by 10 |
150 | lea ebx,[ebx+ebx*4] ; multiply by 5 |
150 | lea ebx,[ebx+ebx*4] ; multiply by 5 |
151 | shl ebx,1 ; multiply by 2 |
151 | shl ebx,1 ; multiply by 2 |
152 | movzx eax,al |
152 | movzx eax,al |
153 | add ebx,eax |
153 | add ebx,eax |
154 | loop .loop |
154 | loop .loop |
155 | ;-------------------------------------- |
155 | ;-------------------------------------- |
156 | @@: |
156 | @@: |
157 | ret |
157 | ret |
158 | ;------------------------------------------------------------------------------ |
158 | ;------------------------------------------------------------------------------ |
159 | IM_END: |
159 | IM_END: |
160 | ;------------------------------------------------------------------------------ |
160 | ;------------------------------------------------------------------------------ |
161 | align 4 |
161 | align 4 |
162 | x_size rd 1 |
162 | x_size rd 1 |
163 | y_size rd 1 |
163 | y_size rd 1 |
164 | ;------------------------------------------------------------------------------ |
164 | ;------------------------------------------------------------------------------ |
165 | align 4 |
165 | align 4 |
166 | boot_param: |
166 | boot_param: |
167 | rb 256+1 ; +1 for reserve |
167 | rb 256+1 ; +1 for reserve |
168 | ;------------------------------------------------------------------------------ |
168 | ;------------------------------------------------------------------------------ |
169 | align 4 |
169 | align 4 |
170 | rb 512 |
170 | rb 512 |
171 | stack_top: |
171 | stack_top: |
172 | ;------------------------------------------------------------------------------ |
172 | ;------------------------------------------------------------------------------ |
173 | I_END: |
173 | I_END: |
174 | ;------------------------------------------------------------------------------ |
174 | ;------------------------------------------------------------------------------ |