]> icculus.org git repositories - crow/jumpnbump.git/blob - dos/gfx.S
Made type defines for map.
[crow/jumpnbump.git] / dos / gfx.S
1 [GLOBAL _get_block]
2 [GLOBAL _put_block]
3
4 [EXTERN ___djgpp_base_address]
5
6
7 [SECTION .text]
8
9
10 ; void get_block(char page, long x, long y, long width, long height, char *buffer);
11
12 _get_block
13         push    ebp
14         mov     ebp,esp
15         pusha
16
17         mov     eax,[ebp+12]
18         mov     [.x],eax
19         mov     eax,[ebp+16]
20         mov     [.y],eax
21         mov     eax,[ebp+20]
22         mov     [.draw_width],eax
23         mov     eax,[ebp+24]
24         mov     [.draw_height],eax
25         mov     eax,[ebp+28]
26         mov     [.buf_ptr],eax
27
28         mov     eax,[.x]
29         or      eax,eax
30         jns     .11
31
32         neg     eax
33         cmp     eax,[ebp+20]
34         jge     near .exit
35
36         mov     dword [.x],0
37         sub     [.draw_width],eax
38         add     [.buf_ptr],eax
39
40 .11
41         cmp     dword [.x],400
42         jge     near .exit
43
44         mov     eax,[.y]
45         or      eax,eax
46         jns     .12
47
48         neg     eax
49         cmp     eax,[ebp+24]
50         jge     near .exit
51
52         mov     dword [.y],0
53         sub     [.draw_height],eax
54         imul    dword [ebp+20]
55         add     [.buf_ptr],eax
56
57 .12
58         cmp     eax,256
59         jge     near .exit
60
61         mov     edi,0xa0000
62         sub     edi,[___djgpp_base_address]
63         xor     eax,eax
64         mov     al,[ebp+8]
65         shl     eax,15
66         add     edi,eax
67         mov     eax,100
68         imul    dword [.y]
69         add     edi,eax
70         mov     [.vga_ptr],edi
71
72         mov     dword [.c1],0
73
74 .1
75         mov     edx,0x3ce
76         mov     eax,[.x]
77         add     eax,[.c1]
78         shl     eax,8
79         and     ah,3
80         mov     al,4
81         out     dx,ax
82
83         mov     esi,[.vga_ptr]
84         mov     eax,[.x]
85         add     eax,[.c1]
86         sar     eax,2
87         add     esi,eax
88
89         mov     edi,[.buf_ptr]
90         add     edi,[.c1]
91
92         mov     ebx,[.draw_height]
93
94 .2
95         mov     ecx,[.draw_width]
96         add     ecx,3
97         sub     ecx,[.c1]
98         shr     ecx,2
99         mov     edx,ecx
100         cmp     ecx,0
101         jle     .4
102
103 .3
104         mov     al,[esi]
105         mov     [edi],al
106         inc     esi
107         add     edi,4
108         dec     cx
109         jnz     .3
110
111 .4
112         add     esi,100
113         sub     esi,edx
114
115         add     edi,[ebp+20]
116         mov     eax,edx
117         shl     eax,2
118         sub     edi,eax
119
120         dec     ebx
121         jnz     .2
122
123         inc     byte [.c1]
124         cmp     byte [.c1],4
125         jl      near .1
126
127 .exit
128         popa
129         pop     ebp
130         ret
131
132 .c1             dd      0
133 .vga_ptr        dd      0
134 .x              dd      0
135 .y              dd      0
136 .draw_width     dd      0
137 .draw_height    dd      0
138 .buf_ptr        dd      0
139
140
141 ; void put_block(char page, long x, long y, long width, long height, char *buffer);
142
143 _put_block
144         push    ebp
145         mov     ebp,esp
146         pusha
147
148         mov     eax,[ebp+12]
149         mov     [.x],eax
150         mov     eax,[ebp+16]
151         mov     [.y],eax
152         mov     eax,[ebp+20]
153         mov     [.draw_width],eax
154         mov     eax,[ebp+24]
155         mov     [.draw_height],eax
156         mov     eax,[ebp+28]
157         mov     [.buf_ptr],eax
158
159         mov     eax,[.x]
160         or      eax,eax
161         jns     .11
162
163         neg     eax
164         cmp     eax,[ebp+20]
165         jge     near .exit
166
167         mov     dword [.x],0
168         sub     [.draw_width],eax
169         add     [.buf_ptr],eax
170
171 .11
172         cmp     dword [.x],400
173         jge     near .exit
174
175         mov     eax,[.y]
176         or      eax,eax
177         jns     .12
178
179         neg     eax
180         cmp     eax,[ebp+24]
181         jge     near .exit
182
183         mov     dword [.y],0
184         sub     [.draw_height],eax
185         imul    dword [ebp+20]
186         add     [.buf_ptr],eax
187
188 .12
189         cmp     eax,256
190         jge     near .exit
191
192         mov     edi,0xa0000
193         sub     edi,[___djgpp_base_address]
194         xor     eax,eax
195         mov     al,[ebp+8]
196         shl     eax,15
197         add     edi,eax
198         mov     eax,100
199         imul    dword [.y]
200         add     edi,eax
201         mov     [.vga_ptr],edi
202
203         mov     dword [.c1],0
204
205 .1
206         mov     edx,0x3c4
207         mov     eax,0x100
208         mov     ecx,[.x]
209         add     ecx,[.c1]
210         and     ecx,3
211         shl     eax,cl
212         mov     al,2
213         out     dx,ax
214
215         mov     esi,[.buf_ptr]
216         add     esi,[.c1]
217
218         mov     edi,[.vga_ptr]
219         mov     eax,[.x]
220         add     eax,[.c1]
221         sar     eax,2
222         add     edi,eax
223
224         mov     ebx,[.draw_height]
225
226 .2
227         mov     ecx,[.draw_width]
228         add     ecx,3
229         sub     ecx,[.c1]
230         shr     ecx,2
231         mov     edx,ecx
232         cmp     ecx,0
233         jle     .4
234
235 .3
236         mov     al,[esi]
237         mov     [edi],al
238         add     esi,4
239         inc     edi
240         dec     ecx
241         jnz     .3
242
243 .4
244         add     esi,[ebp+20]
245         mov     eax,edx
246         shl     eax,2
247         sub     esi,eax
248
249         add     edi,100
250         sub     edi,edx
251
252         dec     ebx
253         jnz     .2
254
255         inc     byte [.c1]
256         cmp     byte [.c1],4
257         jl      near .1
258
259 .exit
260         popa
261         pop     ebp
262         ret
263
264 .c1             dd      0
265 .vga_ptr        dd      0
266 .x              dd      0
267 .y              dd      0
268 .draw_width     dd      0
269 .draw_height    dd      0
270 .buf_ptr        dd      0
271