-
Notifications
You must be signed in to change notification settings - Fork 1
/
OS
196 lines (161 loc) · 2.96 KB
/
OS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
\ os classes for console only.
cr .( Loading OS support...)
code _OS_Byte_0_2
mov r0, tos
swi " OS_Byte"
stmfd sp !, { r2 }
mov tos, r1
next c;
: _textxy
134 _OS_Byte_0_2 ;
' _textxy is getxy
code vsync
mov r0, # 19
swi " OS_Byte"
next c;
\ Graphics
\ at y x do t
code OS_Plot ( y x t -- )
mov r0, tos
ldmfd sp !, { r1, r2, tos }
swi " OS_Plot"
next c;
code -swap ( n1 n2 n3 -- n2 n1 n3 )
ldmfd sp !, { r1, r2 }
mov r0, r2
mov r2, r1
mov r1, r0
stmfd sp !, { r1, r2 }
next c;
\ RISCOS uses plot to draw points lines
\ and shapes.
\ at x y do t
code os_plot_xy ( x y t -- )
mov r0, tos
ldmfd sp !, { r3, r4, tos }
mov r1, r4
mov r2, r3
swi " OS_Plot"
next c;
\ line from x y to x1 y1
code line ( x y x1 y1 -- )
mov r3, tos
ldmfd sp !, { r4, r5, r6, tos }
mov r0, # 4
mov r1, r4
mov r2, r3
swi " OS_Plot"
mov r1, r6
mov r2, r5
mov r0, # 5
swi " OS_Plot"
next c;
\ To plot a circle, move to centre
\ plot circle to a point on the circumference
code circle ( x y x1 y1 -- )
mov r3, tos
ldmfd sp !, { r4, r5, r6, tos }
mov r0, # 4
mov r1, r4
mov r2, r3
swi " OS_Plot"
mov r1, r6
mov r2, r5
mov r0, # 149
swi " OS_Plot"
next c;
\ To plot a circle, move to centre
\ plot circle to a point on the circumference
code fillcircle ( x y x1 y1 -- )
mov r3, tos
ldmfd sp !, { r4, r5, r6, tos }
mov r0, # 4
mov r1, r4
mov r2, r3
swi " OS_Plot"
mov r1, r6
mov r2, r5
mov r0, # 157
swi " OS_Plot"
next c;
\ move to x y
code plot1 ( x y -- )
mov r3, tos
ldmfd sp !, { r4, tos }
mov r0, # 4
mov r1, r4
mov r2, r3
swi " OS_Plot"
next c;
\ move to x y then x1 y1
code plot2 ( x y x1 y1 -- )
mov r3, tos
ldmfd sp !, { r4, r5, r6, tos }
mov r0, # 4
mov r1, r4
mov r2, r3
swi " OS_Plot"
mov r1, r6
mov r2, r5
mov r0, # 4
swi " OS_Plot"
next c;
\ draw rectangle from x y to x1 y1
code fillrect ( x y x1 y1 -- )
mov r3, tos
ldmfd sp !, { r4, r5, r6, tos }
mov r0, # 4
mov r1, r4
mov r2, r3
swi " OS_Plot"
mov r1, r6
mov r2, r5
mov r0, # 101
swi " OS_Plot"
next c;
\ square at x y of size w
code square ( x y w -- )
mov r3, tos
ldmfd sp !, { r4, r5, tos }
mov r0, # 4
mov r1, r5
mov r2, r4
swi " OS_Plot"
add r1, r5, r3
add r2, r4, r3
mov r0, # 101
swi " OS_Plot"
next c;
\ at x y finish triangle
code dotriangle ( x y -- )
mov r3, tos
ldmfd sp !, { r4, tos }
mov r0, # 85
mov r1, r4
mov r2, r3
swi " OS_Plot"
next c;
: clg 16 emit ;
: gcol 18 emit 0 emit emit ;
: colour 17 emit emit ;
: bcolour 17 emit 128 + emit ;
: bcol 18 emit 0 emit 128 + emit ;
: line ( x1 y1 x2 y2 )
4 os_plot_xy 5 os_plot_xy ;
: triangle
4 os_plot_xy 4 os_plot_xy 85 os_plot_xy ;
: fillrect ( x y x1 y1 -- )
4 os_plot_xy 101 os_plot_xy ;
: square ( x y w -- )
>r 2dup r> tuck + >r + r>
fillrect ;
code -32* ( n -- n' )
mov tos, tos, lsl # 5
rsb tos, tos, # 0
next c;
: exit-stuff ( -- )
bye-chain do-chain 0 &58454241 0 os_exit ;
' exit-stuff is bye
: .leaving
." Leaving..." cr ;
bye-chain chain-add .leaving