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