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