Rev 2 | Rev 151 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | #include <ll/i386/hw-data.h> |
2 | #include <ll/i386/hw-instr.h> |
||
3 | #include <ll/i386/mem.h> |
||
4 | #include <ll/stdlib.h> |
||
5 | |||
6 | #include <drivers/gd.h> |
||
7 | |||
8 | #include "fun8.h" |
||
9 | |||
10 | #define fontaddr 0xffa6eL /* indirizzo set caratteri */ |
||
11 | extern DWORD flbaddr; |
||
12 | |||
13 | void RdWin_256(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
14 | { |
||
15 | WORD b_bank, b_offset, display_ptr; |
||
16 | int dx, len1, len2, bank_num, row, sx[12]; |
||
17 | /* int bank, enmem;*/ |
||
18 | DWORD end_of_line, display_offset; |
||
19 | WORD bytes_per_row; |
||
20 | LIN_ADDR p; |
||
21 | |||
22 | bytes_per_row = gd_getbpr(); |
||
23 | p = buf; |
||
24 | |||
25 | if (bytes_per_row == 1024) { |
||
26 | /* ClrWin_1024(x1,y1,x2,y2,color);*/ |
||
27 | Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank); |
||
28 | dx = (x2 - x1) + 1; |
||
29 | display_offset = b_offset; |
||
30 | bank_num = b_bank; |
||
31 | Load_Write_Bank_256(bank_num); |
||
32 | row = y1; |
||
33 | do { |
||
34 | display_ptr = display_offset; |
||
35 | /* Clr_Part(color, dx, display_ptr);*/ |
||
36 | memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), dx); |
||
37 | p += dx; |
||
38 | display_offset += bytes_per_row; |
||
39 | if (display_offset >= 65536L) { |
||
40 | bank_num++; |
||
41 | Load_Write_Bank_256(bank_num); |
||
42 | display_offset = x1; |
||
43 | } |
||
44 | row++; |
||
45 | } while (row <= y2); |
||
46 | Load_Write_Bank_256(0); |
||
47 | } else { |
||
48 | if (bytes_per_row == 640) { |
||
49 | sx[0] = 0; |
||
50 | sx[1] = 256; |
||
51 | sx[2] = 512; |
||
52 | sx[3] = 128; |
||
53 | sx[4] = 384; |
||
54 | sx[5] = 0; |
||
55 | } |
||
56 | if (bytes_per_row == 800) { |
||
57 | sx[0] = 0; |
||
58 | sx[1] = 736; |
||
59 | sx[2] = 672; |
||
60 | sx[3] = 608; |
||
61 | sx[4] = 544; |
||
62 | sx[5] = 480; |
||
63 | sx[6] = 416; |
||
64 | sx[7] = 352; |
||
65 | } |
||
66 | Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank); |
||
67 | dx = (x2 - x1) + 1; |
||
68 | row = y1; |
||
69 | display_offset = b_offset; |
||
70 | display_ptr = display_offset; |
||
71 | bank_num = b_bank; |
||
72 | Load_Write_Bank_256(bank_num); |
||
73 | do { |
||
74 | end_of_line = display_ptr + (x2 - x1); |
||
75 | if (end_of_line > 65536L) { |
||
76 | len2 = (1 + end_of_line - 65536L); |
||
77 | len1 = dx - len2; |
||
78 | /* Clr_Part(color, length_1, display_ptr);*/ |
||
79 | memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), len1); |
||
80 | p += len1; |
||
81 | bank_num++; |
||
82 | Load_Write_Bank_256(bank_num); |
||
83 | display_ptr = 0; |
||
84 | /* Clr_Part(color, length_2, display_ptr);*/ |
||
85 | memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), len2); |
||
86 | p += len2; |
||
87 | display_ptr = bytes_per_row - len1; |
||
88 | } else { |
||
89 | /* Clr_Part(color, dx, display_ptr);*/ |
||
90 | memcpy(p, (LIN_ADDR)(0xA0000 + display_ptr), dx); |
||
91 | p += dx; |
||
92 | display_offset = display_ptr + bytes_per_row; |
||
93 | if (display_offset > 65536L) { |
||
94 | bank_num++; |
||
95 | Load_Write_Bank_256(bank_num); |
||
96 | if (sx[bank_num] <= x1) { |
||
97 | display_ptr = x1 - sx[bank_num]; |
||
98 | } else { |
||
99 | display_ptr = x1 + (bytes_per_row - sx[bank_num]); |
||
100 | } |
||
101 | } else { |
||
102 | display_ptr += bytes_per_row; |
||
103 | } |
||
104 | } |
||
105 | row++; |
||
106 | } while (row <= y2); |
||
107 | Load_Write_Bank_256(0); |
||
108 | } |
||
109 | } |
||
110 | |||
111 | void WrWin_256(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
112 | { |
||
113 | WORD b_bank, b_offset, display_ptr; |
||
114 | int dx, len1, len2, bank_num, row, sx[12]; |
||
115 | /* int bank, enmem;*/ |
||
116 | DWORD end_of_line, display_offset; |
||
117 | WORD bytes_per_row; |
||
118 | LIN_ADDR p; |
||
119 | |||
120 | bytes_per_row = gd_getbpr(); |
||
121 | p = buf; |
||
122 | |||
123 | if (bytes_per_row == 1024) { |
||
124 | /* ClrWin_1024(x1,y1,x2,y2,color);*/ |
||
125 | Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank); |
||
126 | //dx = (x2 - x1); |
||
127 | dx = (x2 - x1 + 1); |
||
128 | display_offset = b_offset; |
||
129 | bank_num = b_bank; |
||
130 | Load_Write_Bank_256(bank_num); |
||
131 | row = y1; |
||
132 | do { |
||
133 | display_ptr = display_offset; |
||
134 | /* Clr_Part(color, dx, display_ptr);*/ |
||
135 | memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, dx); |
||
136 | p += dx; |
||
137 | display_offset += bytes_per_row; |
||
138 | if (display_offset >= 65536L) { |
||
139 | bank_num++; |
||
140 | Load_Write_Bank_256(bank_num); |
||
141 | display_offset = x1; |
||
142 | } |
||
143 | row++; |
||
144 | } while (row <= y2); |
||
145 | Load_Write_Bank_256(0); |
||
146 | } else { |
||
147 | if (bytes_per_row == 640) { |
||
148 | sx[0] = 0; |
||
149 | sx[1] = 256; |
||
150 | sx[2] = 512; |
||
151 | sx[3] = 128; |
||
152 | sx[4] = 384; |
||
153 | sx[5] = 0; |
||
154 | } |
||
155 | if (bytes_per_row == 800) { |
||
156 | sx[0] = 0; |
||
157 | sx[1] = 736; |
||
158 | sx[2] = 672; |
||
159 | sx[3] = 608; |
||
160 | sx[4] = 544; |
||
161 | sx[5] = 480; |
||
162 | sx[6] = 416; |
||
163 | sx[7] = 352; |
||
164 | } |
||
165 | Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank); |
||
166 | dx = (x2 - x1 + 1); |
||
167 | row = y1; |
||
168 | display_offset = b_offset; |
||
169 | display_ptr = display_offset; |
||
170 | bank_num = b_bank; |
||
171 | Load_Write_Bank_256(bank_num); |
||
172 | do { |
||
173 | end_of_line = display_ptr + (x2 - x1); |
||
174 | // if (end_of_line >= 65536L) { |
||
175 | if (end_of_line > 65536L) { |
||
176 | len2 = (1 + end_of_line - 65536L); |
||
177 | len1 = dx - len2; |
||
178 | /* Clr_Part(color, length_1, display_ptr);*/ |
||
179 | memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, len1); |
||
180 | p += len1; |
||
181 | bank_num++; |
||
182 | Load_Write_Bank_256(bank_num); |
||
183 | display_ptr = 0; |
||
184 | /* Clr_Part(color, length_2, display_ptr);*/ |
||
185 | memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, len2); |
||
186 | p += len2; |
||
187 | display_ptr = bytes_per_row - len1; |
||
188 | } else { |
||
189 | /* Clr_Part(color, dx, display_ptr);*/ |
||
190 | memcpy((LIN_ADDR)(0xA0000 + display_ptr), p, dx); |
||
191 | p += dx; |
||
192 | display_offset = display_ptr + bytes_per_row; |
||
193 | if (display_offset > 65536L) { |
||
194 | //if (display_offset >= 65536L) { |
||
195 | bank_num++; |
||
196 | Load_Write_Bank_256(bank_num); |
||
197 | if (sx[bank_num] <= x1) { |
||
198 | display_ptr = x1 - sx[bank_num]; |
||
199 | } else { |
||
200 | display_ptr = x1 + (bytes_per_row - sx[bank_num]); |
||
201 | } |
||
202 | } else { |
||
203 | display_ptr += bytes_per_row; |
||
204 | } |
||
205 | } |
||
206 | row++; |
||
207 | } while (row <= y2); |
||
208 | Load_Write_Bank_256(0); |
||
209 | } |
||
210 | } |
||
211 | |||
212 | void linGet8(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
213 | { |
||
214 | WORD bpr; |
||
215 | LIN_ADDR addr, p; |
||
216 | WORD dx, y; |
||
217 | |||
218 | bpr = gd_getbpr(); |
||
219 | p = buf; |
||
220 | addr = (void *)(flbaddr + x1 + bpr * y1); |
||
221 | //dx = x2 - x1; |
||
222 | dx = x2 - x1 +1; |
||
223 | |||
224 | for (y = y1; y <= y2; y++) { |
||
225 | memcpy(p, addr, dx); |
||
226 | p += dx; |
||
227 | addr += bpr; |
||
228 | } |
||
229 | } |
||
230 | |||
231 | void linPut8(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
232 | { |
||
233 | WORD bpr; |
||
234 | LIN_ADDR addr, p; |
||
235 | WORD dx, y; |
||
236 | |||
237 | bpr = gd_getbpr(); |
||
238 | p = buf; |
||
239 | addr = (void *)(flbaddr + x1 + bpr * y1); |
||
240 | dx = x2 - x1 +1; |
||
241 | |||
242 | for (y = y1; y <= y2; y++) { |
||
243 | memcpy(addr, p, dx); |
||
244 | p += dx; |
||
245 | addr += bpr; |
||
246 | } |
||
247 | } |
||
248 | |||
249 | void ClrWin_256(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
250 | { |
||
251 | WORD b_bank, b_offset, display_ptr; |
||
252 | int dx, len1, len2, bank_num, row, sx[12]; |
||
253 | /* int bank, enmem;*/ |
||
254 | DWORD end_of_line, display_offset; |
||
255 | WORD bytes_per_row; |
||
256 | |||
257 | bytes_per_row = gd_getbpr(); |
||
258 | |||
259 | if (bytes_per_row == 1024) { |
||
260 | /* ClrWin_1024(x1,y1,x2,y2,color);*/ |
||
261 | Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank); |
||
262 | dx = (x2 - x1) + 1; |
||
263 | display_offset = b_offset; |
||
264 | bank_num = b_bank; |
||
265 | Load_Write_Bank_256(bank_num); |
||
266 | row = y1; |
||
267 | do { |
||
268 | display_ptr = display_offset; |
||
269 | /* Clr_Part(color, dx, display_ptr);*/ |
||
270 | memset((LIN_ADDR)(0xA0000 + display_ptr), color, dx); |
||
271 | display_offset += bytes_per_row; |
||
272 | if (display_offset >= 65536L) { |
||
273 | bank_num++; |
||
274 | Load_Write_Bank_256(bank_num); |
||
275 | display_offset = x1; |
||
276 | } |
||
277 | row++; |
||
278 | } while (row <= y2); |
||
279 | Load_Write_Bank_256(0); |
||
280 | } else { |
||
281 | if (bytes_per_row == 640) { |
||
282 | sx[0] = 0; |
||
283 | sx[1] = 256; |
||
284 | sx[2] = 512; |
||
285 | sx[3] = 128; |
||
286 | sx[4] = 384; |
||
287 | sx[5] = 0; |
||
288 | } |
||
289 | if (bytes_per_row == 800) { |
||
290 | sx[0] = 0; |
||
291 | sx[1] = 736; |
||
292 | sx[2] = 672; |
||
293 | sx[3] = 608; |
||
294 | sx[4] = 544; |
||
295 | sx[5] = 480; |
||
296 | sx[6] = 416; |
||
297 | sx[7] = 352; |
||
298 | } |
||
299 | Seg_Off_256(x1, y1, bytes_per_row, &b_offset, &b_bank); |
||
300 | dx = (x2 - x1) + 1; |
||
301 | row = y1; |
||
302 | display_offset = b_offset; |
||
303 | display_ptr = display_offset; |
||
304 | bank_num = b_bank; |
||
305 | Load_Write_Bank_256(bank_num); |
||
306 | do { |
||
307 | end_of_line = display_ptr + (x2 - x1); |
||
308 | if (end_of_line >= 65536L) { |
||
309 | len2 = (1 + end_of_line - 65536L); |
||
310 | len1 = dx - len2; |
||
311 | /* Clr_Part(color, length_1, display_ptr);*/ |
||
312 | memset((LIN_ADDR)(0xA0000 + display_ptr), color, len1); |
||
313 | bank_num++; |
||
314 | Load_Write_Bank_256(bank_num); |
||
315 | display_ptr = 0; |
||
316 | /* Clr_Part(color, length_2, display_ptr);*/ |
||
317 | memset((LIN_ADDR)(0xA0000 + display_ptr), color, len2); |
||
318 | display_ptr = bytes_per_row - len1; |
||
319 | } else { |
||
320 | /* Clr_Part(color, dx, display_ptr);*/ |
||
321 | memset((LIN_ADDR)(0xA0000 + display_ptr), color, dx); |
||
322 | display_offset = display_ptr + bytes_per_row; |
||
323 | if (display_offset >= 65536L) { |
||
324 | bank_num++; |
||
325 | Load_Write_Bank_256(bank_num); |
||
326 | if (sx[bank_num] <= x1) { |
||
327 | display_ptr = x1 - sx[bank_num]; |
||
328 | } else { |
||
329 | display_ptr = x1 + (bytes_per_row - sx[bank_num]); |
||
330 | } |
||
331 | } else { |
||
332 | display_ptr += bytes_per_row; |
||
333 | } |
||
334 | } |
||
335 | row++; |
||
336 | } while (row <= y2); |
||
337 | Load_Write_Bank_256(0); |
||
338 | } |
||
339 | } |
||
340 | |||
341 | void linBox8(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
342 | { |
||
343 | WORD bpr; |
||
344 | DWORD addr; |
||
345 | WORD dx, y; |
||
346 | |||
347 | bpr = gd_getbpr(); |
||
348 | addr = flbaddr + x1 + bpr * y1; |
||
349 | dx = x2 - x1 + 1; |
||
350 | |||
351 | for (y = y1; y <= y2; y++) { |
||
352 | memset((LIN_ADDR)addr, color, dx); |
||
353 | addr += bpr; |
||
354 | } |
||
355 | } |
||
356 | |||
357 | void WrRect_256(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
358 | { |
||
359 | WORD bank, offs, ebank, eoffs; |
||
360 | WORD bpr; |
||
361 | WORD line_segment, len; |
||
362 | WORD y; |
||
363 | |||
364 | bpr = gd_getbpr(); |
||
365 | len = 1 + x2 - x1; |
||
366 | Seg_Off_256(x2, y1, bpr, &eoffs, &ebank); |
||
367 | Seg_Off_256(x1, y1, bpr, &offs, &bank); |
||
368 | Load_Write_Bank_256(bank); |
||
369 | if (bank == ebank) { |
||
370 | memset((LIN_ADDR)(0xA0000 + offs), color, len); |
||
371 | } else { |
||
372 | line_segment = 65536L - offs; |
||
373 | memset((LIN_ADDR)(0xA0000 + offs), color, line_segment); |
||
374 | Load_Write_Bank_256(ebank); |
||
375 | memset((LIN_ADDR)0xA0000, color, eoffs); |
||
376 | } |
||
377 | for (y = y1 + 1; y < y2 + 1; y++) { |
||
378 | Seg_Off_256(x1, y, bpr, &offs, &bank); |
||
379 | Load_Write_Bank_256(bank); |
||
380 | lmempokeb((LIN_ADDR)(0xA0000 + offs), color); |
||
381 | Seg_Off_256(x2, y, bpr, &offs, &bank); |
||
382 | Load_Write_Bank_256(bank); |
||
383 | lmempokeb((LIN_ADDR)(0xA0000 + offs), color); |
||
384 | } |
||
385 | Seg_Off_256(x2, y2, bpr, &eoffs, &ebank); |
||
386 | Seg_Off_256(x1, y2, bpr, &offs, &bank); |
||
387 | Load_Write_Bank_256(bank); |
||
388 | if (bank == ebank) { |
||
389 | memset((LIN_ADDR)(0xA0000 + offs), color, len); |
||
390 | } else { |
||
391 | line_segment = 65536L - offs; |
||
392 | memset((LIN_ADDR)(0xA0000 + offs), color, line_segment); |
||
393 | Load_Write_Bank_256(ebank); |
||
394 | memset((LIN_ADDR)0xA0000, color, eoffs); |
||
395 | } |
||
396 | } |
||
397 | |||
398 | void linRect8(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
399 | { |
||
400 | WORD bpr; |
||
401 | DWORD addr; |
||
402 | WORD dx, y; |
||
403 | |||
404 | bpr = gd_getbpr(); |
||
405 | addr = flbaddr + x1 + bpr * y1; |
||
406 | dx = x2 - x1; |
||
407 | |||
408 | memset((LIN_ADDR)addr, color, dx+1); |
||
409 | addr += bpr; |
||
410 | |||
411 | for (y = y1 + 1; y <= y2 - 1; y++) { |
||
412 | lmempokeb((LIN_ADDR)addr, color); |
||
413 | lmempokeb((LIN_ADDR)(addr + dx), color); |
||
414 | addr += bpr; |
||
415 | } |
||
416 | memset((LIN_ADDR)addr, color, dx+1); |
||
417 | } |
||
418 | |||
419 | void WrText_256(char *text, WORD x, WORD y, DWORD fg, DWORD bg) |
||
420 | { |
||
421 | DWORD fp; |
||
422 | WORD offs, bank; |
||
423 | WORD bpr; |
||
424 | int r, c, bits; |
||
425 | |||
426 | bpr = gd_getbpr(); |
||
427 | while (*text) { |
||
428 | fp = fontaddr + (8 * *(BYTE *)text); |
||
429 | for (r=0; r<8; r++) { |
||
430 | bits = lmempeekb((LIN_ADDR)(fp++)); |
||
431 | for (c=0; c<8; c++) |
||
432 | if (bits & (0x80>>c)) { |
||
433 | Seg_Off_256(x + c, y + r, bpr, &offs, &bank); |
||
434 | Load_Write_Bank_256(bank); |
||
435 | lmempokeb((LIN_ADDR)(0xA0000 + offs), fg); |
||
436 | } |
||
437 | /* lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), fg);*/ |
||
438 | /* vbe_putpixel((x+c),(y+r),fg);*/ |
||
439 | else { |
||
440 | Seg_Off_256(x + c, y + r, bpr, &offs, &bank); |
||
441 | Load_Write_Bank_256(bank); |
||
442 | lmempokeb((LIN_ADDR)(0xA0000 + offs), bg); |
||
443 | } |
||
444 | /* lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), bg);*/ |
||
445 | /* vbe_putpixel((x+c), (y+r), bg);*/ |
||
446 | } |
||
447 | text++; |
||
448 | x += 8; |
||
449 | } |
||
450 | } |
||
451 | |||
452 | void linText8(char *text, WORD x, WORD y, DWORD fg, DWORD bg) |
||
453 | { |
||
454 | DWORD fp, addr; |
||
455 | WORD bpr; |
||
456 | int r, c, bits; |
||
457 | |||
458 | bpr = gd_getbpr(); |
||
459 | addr = gd_getflb(); |
||
460 | while (*text) { |
||
461 | /*DOSSetAddr(fp, (fontaddr + (8 * *(BYTE *)text)));*/ |
||
462 | /*DOSSetAddr(fp, (fontaddr + (8 * *(BYTE *)text)));*/ |
||
463 | fp = fontaddr + (8 * *(BYTE *)text); |
||
464 | for (r=0; r<8; r++) { |
||
465 | bits = lmempeekb((LIN_ADDR)fp++); |
||
466 | for (c=0; c<8; c++) |
||
467 | if (bits & (0x80>>c)) |
||
468 | lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), fg); |
||
469 | /* vbe_putpixel((x+c),(y+r),fg);*/ |
||
470 | else |
||
471 | lmempokeb((LIN_ADDR)(addr + (y + r) * bpr + x + c), bg); |
||
472 | /* vbe_putpixel((x+c), (y+r), bg);*/ |
||
473 | } |
||
474 | text++; |
||
475 | x += 8; |
||
476 | } |
||
477 | } |
||
478 | |||
479 | void WrLine_256(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
480 | { |
||
481 | int dx, dy, incr1, incr2, d, x, y, xend, yend, yinc, xinc; |
||
482 | WORD bpr; |
||
483 | WORD bank, offs, ebank, eoffs; |
||
484 | WORD line_segment, len; |
||
485 | |||
486 | bpr = gd_getbpr(); |
||
487 | if (y2 == y1) { |
||
488 | y = y1; |
||
489 | if (x1 > x2) { |
||
490 | xend = x1; |
||
491 | x1 = x2; |
||
492 | x2 = xend; |
||
493 | } |
||
494 | /* WrHline_256(x1, x2, y1, color, bpr); */ |
||
495 | len = 1 + x2 - x1; |
||
496 | Seg_Off_256(x2, y, bpr, &eoffs, &ebank); |
||
497 | Seg_Off_256(x1, y, bpr, &offs, &bank); |
||
498 | Load_Write_Bank_256(bank); |
||
499 | if (bank == ebank) { |
||
500 | memset((LIN_ADDR)(0xA0000 + offs), color, len); |
||
501 | } else { |
||
502 | line_segment = 65536L - offs; |
||
503 | memset((LIN_ADDR)(0xA0000 + offs), color, line_segment); |
||
504 | Load_Write_Bank_256(ebank); |
||
505 | memset((LIN_ADDR)0xA0000, color, eoffs); |
||
506 | } |
||
507 | } else { |
||
508 | dx = abs(x2 - x1); |
||
509 | dy = abs(y2 - y1); |
||
510 | if (dx >= dy) { |
||
511 | if (x1 > x2) { |
||
512 | x = x2; |
||
513 | y = y2; |
||
514 | xend = x1; |
||
515 | if (dy == 0) { |
||
516 | yinc = 0; |
||
517 | } else { |
||
518 | if (y2 > y1) { |
||
519 | yinc = -1; |
||
520 | } else { |
||
521 | yinc = 1; |
||
522 | } |
||
523 | } |
||
524 | } else { |
||
525 | x = x1; |
||
526 | y = y1; |
||
527 | xend = x2; |
||
528 | if (dy == 0) { |
||
529 | yinc = 0; |
||
530 | } else { |
||
531 | if (y2 > y1) { |
||
532 | yinc =1; |
||
533 | } else { |
||
534 | yinc = -1; |
||
535 | } |
||
536 | } |
||
537 | } |
||
538 | incr1 = 2 * dy; |
||
539 | d = incr1 - dx; |
||
540 | incr2 = 2 * (dy - dx); |
||
541 | Seg_Off_256(x, y, bpr, &offs, &bank); |
||
542 | Load_Write_Bank_256(bank); |
||
543 | lmempokeb((LIN_ADDR)(0xA0000 + offs), color); |
||
544 | while (x < xend) { |
||
545 | x++; |
||
546 | if (d < 0) { |
||
547 | d += incr1; |
||
548 | } else { |
||
549 | y += yinc; |
||
550 | d += incr2; |
||
551 | } |
||
552 | Seg_Off_256(x, y, bpr, &offs, &bank); |
||
553 | Load_Write_Bank_256(bank); |
||
554 | lmempokeb((LIN_ADDR)(0xA0000 + offs), color); |
||
555 | } |
||
556 | } else { |
||
557 | if (y1 > y2) { |
||
558 | x = x2; |
||
559 | y = y2; |
||
560 | yend = y1; |
||
561 | if (dx == 0) { |
||
562 | xinc = 0; |
||
563 | } else { |
||
564 | if (x2 > x1) { |
||
565 | xinc = -1; |
||
566 | } else { |
||
567 | xinc = 1; |
||
568 | } |
||
569 | } |
||
570 | } else { |
||
571 | x = x1; |
||
572 | y = y1; |
||
573 | yend = y2; |
||
574 | if (dx == 0) { |
||
575 | xinc = 0; |
||
576 | } else { |
||
577 | if (x2 > x1) { |
||
578 | xinc = 1; |
||
579 | } else { |
||
580 | xinc = -1; |
||
581 | } |
||
582 | } |
||
583 | } |
||
584 | incr1 = 2 * dx; |
||
585 | d = incr1 - dy; |
||
586 | incr2 = 2 * (dx - dy); |
||
587 | Seg_Off_256(x, y, bpr, &offs, &bank); |
||
588 | Load_Write_Bank_256(bank); |
||
589 | lmempokeb((LIN_ADDR)(0xA0000 + offs), color); |
||
590 | while (y < yend) { |
||
591 | y++; |
||
592 | if (d < 0) { |
||
593 | d += incr1; |
||
594 | } else { |
||
595 | x += xinc; |
||
596 | d += incr2; |
||
597 | } |
||
598 | Seg_Off_256(x, y, bpr, &offs, &bank); |
||
599 | Load_Write_Bank_256(bank); |
||
600 | lmempokeb((LIN_ADDR)(0xA0000 + offs), color); |
||
601 | } |
||
602 | } |
||
603 | } |
||
604 | } |
||
605 | |||
606 | void linLine8(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
607 | { |
||
608 | register int t, distance; |
||
609 | register DWORD addr; |
||
610 | register WORD bpr; |
||
611 | int xerr=0, yerr=0, deltax, deltay; |
||
612 | int incx, incy; |
||
613 | |||
614 | bpr = gd_getbpr(); |
||
615 | addr = gd_getflb(); |
||
616 | deltax = x2 - x1; /* compute both distances */ |
||
617 | deltay = y2 - y1; |
||
618 | |||
619 | if (deltax > 0) /* compute increments */ |
||
620 | incx = 1; |
||
621 | else if (deltax == 0) |
||
622 | incx = 0; |
||
623 | else |
||
624 | incx = -1; |
||
625 | |||
626 | if (deltay > 0) |
||
627 | incy = 1; |
||
628 | else if (deltay == 0) |
||
629 | incy = 0; |
||
630 | else |
||
631 | incy = -1; |
||
632 | |||
633 | deltax = abs(deltax); /* determine greater distance */ |
||
634 | deltay = abs(deltay); |
||
635 | if (deltax > deltay) |
||
636 | distance = deltax; |
||
637 | else |
||
638 | distance = deltay; |
||
639 | |||
640 | for (t=0; t<=distance+1; t++) { /* draw the line */ |
||
641 | /* vbe_putpixel(x1, y1, colour);*/ |
||
642 | lmempokeb((LIN_ADDR)(addr + y1 * bpr + x1), color); |
||
643 | xerr += deltax; |
||
644 | yerr += deltay; |
||
645 | if (xerr > distance) { |
||
646 | xerr -= distance; |
||
647 | x1 += incx; |
||
648 | } |
||
649 | if (yerr > distance) { |
||
650 | yerr -= distance; |
||
651 | y1 += incy; |
||
652 | } |
||
653 | } |
||
654 | } |
||
655 | |||
656 | void WrPixel_256(WORD x, WORD y, DWORD color) |
||
657 | { |
||
658 | WORD bpr; |
||
659 | WORD bank, offs; |
||
660 | |||
661 | bpr = gd_getbpr(); |
||
662 | Seg_Off_256(x, y, bpr, &offs, &bank); |
||
663 | Load_Write_Bank_256(bank); |
||
664 | lmempokeb((LIN_ADDR)(0xA0000 + offs), color); |
||
665 | /* Load_Write_Bank_256(0);*/ |
||
666 | } |
||
667 | |||
668 | void linWr8(WORD x, WORD y, DWORD color) |
||
669 | { |
||
670 | WORD bpr; |
||
671 | |||
672 | bpr = gd_getbpr(); |
||
673 | lmempokeb((LIN_ADDR)(flbaddr + y * bpr + x), color); |
||
674 | } |
||
675 | |||
676 | DWORD RdPixel_256(WORD x, WORD y) |
||
677 | { |
||
678 | WORD bpr; |
||
679 | WORD bank, offs; |
||
680 | DWORD rv; |
||
681 | |||
682 | bpr = gd_getbpr(); |
||
683 | Seg_Off_256(x, y, bpr, &offs, &bank); |
||
684 | Load_Write_Bank_256(bank); |
||
685 | rv = lmempeekb((LIN_ADDR)(0xA0000 + offs)); |
||
686 | return rv; |
||
687 | } |
||
688 | |||
689 | DWORD linRd8(WORD x, WORD y) |
||
690 | { |
||
691 | WORD bpr; |
||
692 | DWORD rv; |
||
693 | |||
694 | bpr = gd_getbpr(); |
||
695 | rv = lmempeekb((LIN_ADDR)(flbaddr + y * bpr + x)); |
||
696 | return rv; |
||
697 | } |
||
698 |