Skip to content

Commit 8ed18de

Browse files
Correção na soma e subtração, e inicio da Biblioteca System.Drawing
1 parent 06556ac commit 8ed18de

File tree

38 files changed

+2800
-228
lines changed

38 files changed

+2800
-228
lines changed

Distro/Atual/hcbasic.dll

512 Bytes
Binary file not shown.

Distro/Atual/hcbasic.pdb

120 Bytes
Binary file not shown.
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
Imports System
2+
3+
Structure VideoMode
4+
Dim Width as UInt16
5+
Dim Height as UInt16
6+
Dim Colors as UInt16
7+
Dim DrawPixel as Action(Of VideoMode, UInt16, UInt16, UInt16)
8+
Dim DrawRectangle as Action(Of VideoMode, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
9+
Dim DrawEllipse as Action(Of VideoMode, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
10+
Dim DrawLine as Action(Of VideoMode, UInt16, UInt16, UInt16, UInt16, UInt16)
11+
Dim ClearScreen as Action(Of VideoMode, UInt16)
12+
End
13+
14+
Module Graphics
15+
Dim Active as UInt16
16+
Dim Video as VideoMode
17+
18+
Public Sub DrawPixel(x as UInt16, y as UInt16, color as UInt16)
19+
If Active == 0 Then Throw AccessDeniedError
20+
Video.DrawPixel.Invoke x, y, color
21+
End
22+
23+
Public Sub DrawLine(x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, color as UInt16)
24+
If Active == 0 Then Throw AccessDeniedError
25+
Video.DrawLine.Invoke x1, y1, x2, y2, color
26+
End
27+
28+
Public Sub DrawRectangle(x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, borderColor as UInt16, backgroundColor as UInt16)
29+
If Active == 0 Then Throw AccessDeniedError
30+
Video.DrawRectangle.Invoke x1, y1, x2, y2, borderColor, backgroundColor
31+
End
32+
33+
Public Sub DrawEllipse(x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, borderColor as UInt16, backgroundColor as UInt16)
34+
If Active == 0 Then Throw AccessDeniedError
35+
Video.DrawEllipse.Invoke x1, y1, x2, y2, borderColor, backgroundColor
36+
End
37+
38+
Public Sub ClearScreen(color as UInt16)
39+
If Active == 0 Then Throw AccessDeniedError
40+
Video.ClearScreen.Invoke color
41+
End
42+
43+
Public Function GetActive() as UInt16
44+
Return Active
45+
End
46+
47+
Public Function GetWidth() as UInt16
48+
If Active == 0 Then Throw AccessDeniedError
49+
Return Video.Width
50+
End
51+
52+
Public Function GetHeight() as UInt16
53+
If Active == 0 Then Throw AccessDeniedError
54+
Return Video.Height
55+
End
56+
57+
Public Function GetColors() as UInt16
58+
If Active == 0 Then Throw AccessDeniedError
59+
Return Video.Colors
60+
End
61+
62+
Public Sub Mode80x25x16
63+
Active = 0
64+
asm "mov ax, 3"
65+
asm "int 0x10"
66+
End
67+
68+
Public Sub ModeManual(newMode as VideoMode)
69+
Active = 1
70+
#Video = #newMode
71+
@Video = @newMode
72+
End
73+
74+
End
75+
76+
Module CGA
77+
Dim Video as VideoMode
78+
79+
Public Sub Mode640x200x2
80+
asm "mov ax, 0x6"
81+
asm "int 0x10"
82+
Video.Width = 640
83+
Video.Height = 200
84+
Video.Colors = 2
85+
Video.DrawPixel = AddressOf(DrawPixel)
86+
Video.DrawLine = AddressOf(DrawLine)
87+
Video.DrawEllipse = AddressOf(DrawEllipse)
88+
Video.DrawRectangle = AddressOf(DrawRectangle)
89+
Video.ClearScreen = AddressOf(ClearScreen)
90+
Graphics.ModeManual Video
91+
End
92+
93+
Sub DrawPixel(mode as VideoMode, x as UInt16, y as UInt16, color as UInt16)
94+
asm "mov ax, 0xba00"
95+
asm "test word [bp+12], 1"
96+
asm "jne .par"
97+
asm "mov ax, 0xb800"
98+
asm ".par:"
99+
asm "mov es, ax"
100+
asm "mov ax, [bp+12]"
101+
asm "shr ax, 1"
102+
asm "mov bx, 80"
103+
asm "mul bx"
104+
asm "mov bx, [bp+10]"
105+
asm "shr bx, 1"
106+
asm "shr bx, 1"
107+
asm "shr bx, 1"
108+
asm "add ax, bx"
109+
asm "mov di, ax"
110+
asm "mov cx, [bp+10]"
111+
asm "and cx, 7"
112+
asm "inc cx"
113+
asm "mov ax, [bp+14]"
114+
asm "and ax, 1"
115+
asm "je .inverte"
116+
asm "ror al, cl"
117+
asm "es or [di], al"
118+
asm "jmp .fim"
119+
asm ".inverte:"
120+
asm "ror al, cl"
121+
asm "not ax"
122+
asm "es and [di], al"
123+
asm ".fim:"
124+
End
125+
126+
Sub DrawLine(mode as VideoMode, x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, color as UInt16)
127+
Dim inc as Int16
128+
Dim inc1 as Int16
129+
Dim inc2 as Int16
130+
Dim dx as Int16
131+
Dim dy as Int16
132+
Dim d as Int16
133+
Dim x as UInt16
134+
Dim y as UInt16
135+
If x1 > x2 Then
136+
x = x1
137+
x1 = x2
138+
x2 = x
139+
y = y1
140+
y1 = y2
141+
y2 = y
142+
End
143+
If y2 > y1 Then
144+
inc = 1
145+
Else
146+
inc = -1
147+
End
148+
x = x1
149+
y = y1
150+
dx = x2 - x1
151+
dy = y2 - y1
152+
If dx > dy Then
153+
d = (dy SHL 1) - dx
154+
inc1 = (dy-dx) SHL 1
155+
inc2 = dy SHL 1
156+
DrawPixel mode, x, y, color
157+
For x = x1 + 1 To x2
158+
If d >= 0 Then
159+
y = y + inc
160+
d = d + inc1
161+
Else
162+
d = d + inc2
163+
End
164+
DrawPixel mode, x, y, color
165+
End
166+
Else
167+
d = (dx SHL 1) - dy
168+
inc1 = (dx-dy) SHL 1
169+
inc2 = dx SHL 1
170+
DrawPixel mode, x, y, color
171+
For y = y1 + 1 To y2
172+
If d >= 0 Then
173+
x = x + inc
174+
d = d + inc1
175+
Else
176+
d = d + inc2
177+
End
178+
DrawPixel mode, x, y, color
179+
End
180+
End
181+
End
182+
183+
Sub DrawEllipse(mode as VideoMode, x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, borderColor as UInt16, backgroundColor as UInt16)
184+
Throw NotImplementedError
185+
End
186+
187+
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
189+
End
190+
191+
Sub ClearScreen(mode as VideoMode, color as UInt16)
192+
Throw NotImplementedError
193+
End
194+
End

Distro/Linux64/hcbasic.dll

512 Bytes
Binary file not shown.

Distro/Linux64/hcbasic.pdb

172 Bytes
Binary file not shown.
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
Imports System
2+
3+
Structure VideoMode
4+
Dim Width as UInt16
5+
Dim Height as UInt16
6+
Dim Colors as UInt16
7+
Dim DrawPixel as Action(Of VideoMode, UInt16, UInt16, UInt16)
8+
Dim DrawRectangle as Action(Of VideoMode, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
9+
Dim DrawEllipse as Action(Of VideoMode, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
10+
Dim DrawLine as Action(Of VideoMode, UInt16, UInt16, UInt16, UInt16, UInt16)
11+
Dim ClearScreen as Action(Of VideoMode, UInt16)
12+
End
13+
14+
Module Graphics
15+
Dim Active as UInt16
16+
Dim Video as VideoMode
17+
18+
Public Sub DrawPixel(x as UInt16, y as UInt16, color as UInt16)
19+
If Active == 0 Then Throw AccessDeniedError
20+
Video.DrawPixel.Invoke x, y, color
21+
End
22+
23+
Public Sub DrawLine(x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, color as UInt16)
24+
If Active == 0 Then Throw AccessDeniedError
25+
Video.DrawLine.Invoke x1, y1, x2, y2, color
26+
End
27+
28+
Public Sub DrawRectangle(x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, borderColor as UInt16, backgroundColor as UInt16)
29+
If Active == 0 Then Throw AccessDeniedError
30+
Video.DrawRectangle.Invoke x1, y1, x2, y2, borderColor, backgroundColor
31+
End
32+
33+
Public Sub DrawEllipse(x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, borderColor as UInt16, backgroundColor as UInt16)
34+
If Active == 0 Then Throw AccessDeniedError
35+
Video.DrawEllipse.Invoke x1, y1, x2, y2, borderColor, backgroundColor
36+
End
37+
38+
Public Sub ClearScreen(color as UInt16)
39+
If Active == 0 Then Throw AccessDeniedError
40+
Video.ClearScreen.Invoke color
41+
End
42+
43+
Public Function GetActive() as UInt16
44+
Return Active
45+
End
46+
47+
Public Function GetWidth() as UInt16
48+
If Active == 0 Then Throw AccessDeniedError
49+
Return Video.Width
50+
End
51+
52+
Public Function GetHeight() as UInt16
53+
If Active == 0 Then Throw AccessDeniedError
54+
Return Video.Height
55+
End
56+
57+
Public Function GetColors() as UInt16
58+
If Active == 0 Then Throw AccessDeniedError
59+
Return Video.Colors
60+
End
61+
62+
Public Sub Mode80x25x16
63+
Active = 0
64+
asm "mov ax, 3"
65+
asm "int 0x10"
66+
End
67+
68+
Public Sub ModeManual(newMode as VideoMode)
69+
Active = 1
70+
#Video = #newMode
71+
@Video = @newMode
72+
End
73+
74+
End
75+
76+
Module CGA
77+
Dim Video as VideoMode
78+
79+
Public Sub Mode640x200x2
80+
asm "mov ax, 0x6"
81+
asm "int 0x10"
82+
Video.Width = 640
83+
Video.Height = 200
84+
Video.Colors = 2
85+
Video.DrawPixel = AddressOf(DrawPixel)
86+
Video.DrawLine = AddressOf(DrawLine)
87+
Video.DrawEllipse = AddressOf(DrawEllipse)
88+
Video.DrawRectangle = AddressOf(DrawRectangle)
89+
Video.ClearScreen = AddressOf(ClearScreen)
90+
Graphics.ModeManual Video
91+
End
92+
93+
Sub DrawPixel(mode as VideoMode, x as UInt16, y as UInt16, color as UInt16)
94+
asm "mov ax, 0xba00"
95+
asm "test word [bp+12], 1"
96+
asm "jne .par"
97+
asm "mov ax, 0xb800"
98+
asm ".par:"
99+
asm "mov es, ax"
100+
asm "mov ax, [bp+12]"
101+
asm "shr ax, 1"
102+
asm "mov bx, 80"
103+
asm "mul bx"
104+
asm "mov bx, [bp+10]"
105+
asm "shr bx, 1"
106+
asm "shr bx, 1"
107+
asm "shr bx, 1"
108+
asm "add ax, bx"
109+
asm "mov di, ax"
110+
asm "mov cx, [bp+10]"
111+
asm "and cx, 7"
112+
asm "inc cx"
113+
asm "mov ax, [bp+14]"
114+
asm "and ax, 1"
115+
asm "je .inverte"
116+
asm "ror al, cl"
117+
asm "es or [di], al"
118+
asm "jmp .fim"
119+
asm ".inverte:"
120+
asm "ror al, cl"
121+
asm "not ax"
122+
asm "es and [di], al"
123+
asm ".fim:"
124+
End
125+
126+
Sub DrawLine(mode as VideoMode, x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, color as UInt16)
127+
Dim inc as Int16
128+
Dim inc1 as Int16
129+
Dim inc2 as Int16
130+
Dim dx as Int16
131+
Dim dy as Int16
132+
Dim d as Int16
133+
Dim x as UInt16
134+
Dim y as UInt16
135+
If x1 > x2 Then
136+
x = x1
137+
x1 = x2
138+
x2 = x
139+
y = y1
140+
y1 = y2
141+
y2 = y
142+
End
143+
If y2 > y1 Then
144+
inc = 1
145+
Else
146+
inc = -1
147+
End
148+
x = x1
149+
y = y1
150+
dx = x2 - x1
151+
dy = y2 - y1
152+
If dx > dy Then
153+
d = (dy SHL 1) - dx
154+
inc1 = (dy-dx) SHL 1
155+
inc2 = dy SHL 1
156+
DrawPixel mode, x, y, color
157+
For x = x1 + 1 To x2
158+
If d >= 0 Then
159+
y = y + inc
160+
d = d + inc1
161+
Else
162+
d = d + inc2
163+
End
164+
DrawPixel mode, x, y, color
165+
End
166+
Else
167+
d = (dx SHL 1) - dy
168+
inc1 = (dx-dy) SHL 1
169+
inc2 = dx SHL 1
170+
DrawPixel mode, x, y, color
171+
For y = y1 + 1 To y2
172+
If d >= 0 Then
173+
x = x + inc
174+
d = d + inc1
175+
Else
176+
d = d + inc2
177+
End
178+
DrawPixel mode, x, y, color
179+
End
180+
End
181+
End
182+
183+
Sub DrawEllipse(mode as VideoMode, x1 as UInt16, y1 as UInt16, x2 as UInt16, y2 as UInt16, borderColor as UInt16, backgroundColor as UInt16)
184+
Throw NotImplementedError
185+
End
186+
187+
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
189+
End
190+
191+
Sub ClearScreen(mode as VideoMode, color as UInt16)
192+
Throw NotImplementedError
193+
End
194+
End

Distro/LinuxARM32/hcbasic.dll

512 Bytes
Binary file not shown.

Distro/LinuxARM32/hcbasic.pdb

172 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)