Skip to content

Commit 42b5a69

Browse files
Implementado Graphics.DrawRectangle
1 parent 8ed18de commit 42b5a69

File tree

5 files changed

+1320
-196
lines changed

5 files changed

+1320
-196
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ install:
6868
mkdir -p /usr/lib/hcbasic/8086-kernel
6969
install Plataformas/8086-KERNEL/* /usr/lib/hcbasic/8086-kernel/
7070

71-
teste: all
71+
teste-hcb:
7272
Distro/Atual/hcbasic teste.hcb teste.asm Plataformas/8086-DOS / Plataformas/8086/
7373
nasm -f bin -o teste.com teste.asm
7474
dosbox -C "mount c: ." -C "c:" -C "teste.com"
75+
teste: all
76+
make teste-hcb
77+
7578
clean:
7679
-rm -Rf Distro/Atual
7780
-rm -Rf obj

Plataformas/8086/System.Drawing.hcb

Lines changed: 176 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,183 @@ Module CGA
184184
Throw NotImplementedError
185185
End
186186

187+
Sub ByteOr(mode as VideoMode, x as UInt16, y as UInt16, value as UInt8)
188+
asm "mov ax, 0xba00"
189+
asm "test word [bp+12], 1"
190+
asm "jne .par"
191+
asm "mov ax, 0xb800"
192+
asm ".par:"
193+
asm "mov es, ax"
194+
asm "mov ax, [bp+12]"
195+
asm "shr ax, 1"
196+
asm "mov bx, 80"
197+
asm "mul bx"
198+
asm "mov bx, [bp+10]"
199+
asm "shr bx, 1"
200+
asm "shr bx, 1"
201+
asm "shr bx, 1"
202+
asm "add ax, bx"
203+
asm "mov di, ax"
204+
asm "mov ax, [bp+14]"
205+
asm "es or [di], al"
206+
End
207+
208+
Sub ByteAnd(mode as VideoMode, x as UInt16, y as UInt16, value as UInt8)
209+
asm "mov ax, 0xba00"
210+
asm "test word [bp+12], 1"
211+
asm "jne .par"
212+
asm "mov ax, 0xb800"
213+
asm ".par:"
214+
asm "mov es, ax"
215+
asm "mov ax, [bp+12]"
216+
asm "shr ax, 1"
217+
asm "mov bx, 80"
218+
asm "mul bx"
219+
asm "mov bx, [bp+10]"
220+
asm "shr bx, 1"
221+
asm "shr bx, 1"
222+
asm "shr bx, 1"
223+
asm "add ax, bx"
224+
asm "mov di, ax"
225+
asm "mov ax, [bp+14]"
226+
asm "es and [di], al"
227+
End
228+
229+
Sub ByteAndOr(mode as VideoMode, x as UInt16, y as UInt16, valueAnd as UInt8, valueOr as UInt8)
230+
asm "mov ax, 0xba00"
231+
asm "test word [bp+12], 1"
232+
asm "jne .par"
233+
asm "mov ax, 0xb800"
234+
asm ".par:"
235+
asm "mov es, ax"
236+
asm "mov ax, [bp+12]"
237+
asm "shr ax, 1"
238+
asm "mov bx, 80"
239+
asm "mul bx"
240+
asm "mov bx, [bp+10]"
241+
asm "shr bx, 1"
242+
asm "shr bx, 1"
243+
asm "shr bx, 1"
244+
asm "add ax, bx"
245+
asm "mov di, ax"
246+
asm "mov ax, [bp+14]"
247+
asm "es and [di], al"
248+
asm "mov ax, [bp+16]"
249+
asm "es or [di], al"
250+
End
251+
252+
Sub ByteSet(mode as VideoMode, x as UInt16, y as UInt16, value as UInt8, len as UInt16)
253+
asm "mov ax, 0xba00"
254+
asm "test word [bp+12], 1"
255+
asm "jne .par"
256+
asm "mov ax, 0xb800"
257+
asm ".par:"
258+
asm "mov es, ax"
259+
asm "mov ax, [bp+12]"
260+
asm "shr ax, 1"
261+
asm "mov bx, 80"
262+
asm "mul bx"
263+
asm "mov bx, [bp+10]"
264+
asm "shr bx, 1"
265+
asm "shr bx, 1"
266+
asm "shr bx, 1"
267+
asm "add ax, bx"
268+
asm "mov di, ax"
269+
asm "mov ax, [bp+14]"
270+
asm "mov cx, [bp+16]"
271+
asm "cld"
272+
asm "rep stosb"
273+
End
274+
187275
Sub DrawRectangle(mode as VideoMode, x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, borderColor as UInt16, backgroundColor as UInt16)
188-
Throw NotImplementedError
276+
Dim y as UInt16
277+
Dim x as UInt16
278+
Dim tmp as UInt16
279+
Dim tmpor as UInt8
280+
Dim tmpand as UInt8
281+
tmpor = 0
282+
tmpand = 0xff
283+
tmp = 7 - (x1 and 7)
284+
For x = 0 to tmp
285+
If x == tmp Then
286+
If borderColor and 1 Then
287+
tmpand = tmpand or ((1 shl x))
288+
tmpor = tmpor or ((1 shl x))
289+
End
290+
Else
291+
If backgroundColor <> 0xffff Then
292+
If backgroundColor and 1 Then
293+
tmpand = tmpand or ((1 shl x))
294+
tmpor = tmpor or ((1 shl x))
295+
End
296+
End
297+
End
298+
End
299+
tmpand = not tmpand
300+
For y = y1 + 1 to y2 - 1
301+
ByteAndOr mode, x1, y, tmpand, tmpor
302+
End
303+
If backgroundColor <> 0xffff Then
304+
If backgroundColor and 1 Then
305+
tmpand = 0xff
306+
Else
307+
tmpand = 0
308+
End
309+
For y = y1 to y2
310+
ByteSet mode, x1 + 8, y, tmpand, (x2 - x1 - 8) SHR 3
311+
End
312+
End
313+
314+
tmpor = 0
315+
tmpand = 0xff
316+
tmp = x2 and 7
317+
For x = 0 to tmp
318+
If x == tmp Then
319+
If borderColor and 1 Then
320+
tmpand = tmpand or ((128 shr x))
321+
tmpor = tmpor or ((128 shr x))
322+
End
323+
Else
324+
If backgroundColor <> 0xffff Then
325+
If backgroundColor and 1 Then
326+
tmpand = tmpand or ((128 shr x))
327+
tmpor = tmpor or ((128 shr x))
328+
End
329+
End
330+
End
331+
End
332+
For y = y1 + 1 to y2 - 1
333+
ByteAndOr mode, x2, y, tmpand, tmpor
334+
End
335+
tmpor = 0
336+
tmpand = 0xff
337+
tmp = 7 - (x1 and 7)
338+
For x = 0 to tmp
339+
tmpand = tmpand or ((1 shl x))
340+
If borderColor and 1 Then
341+
tmpor = tmpor or ((1 shl x))
342+
End
343+
End
344+
ByteAndOr mode, x1, y1, tmpand, tmpor
345+
ByteAndOr mode, x1, y2, tmpand, tmpor
346+
tmpor = 0
347+
tmpand = 0xff
348+
tmp = x2 and 7
349+
For x = 0 to tmp
350+
tmpand = tmpand or ((128 shr x))
351+
If borderColor and 1 Then
352+
tmpor = tmpor or ((128 shr x))
353+
End
354+
End
355+
ByteAndOr mode, x2, y1, tmpand, tmpor
356+
ByteAndOr mode, x2, y2, tmpand, tmpor
357+
If borderColor and 1 Then
358+
tmpand = 0xff
359+
Else
360+
tmpand = 0
361+
End
362+
ByteSet mode, x1 + 8, y1, tmpand, (x2 - x1 - 8) SHR 3
363+
ByteSet mode, x1 + 8, y2, tmpand, (x2 - x1 - 8) SHR 3
189364
End
190365

191366
Sub ClearScreen(mode as VideoMode, color as UInt16)

0 commit comments

Comments
 (0)