forked from Samiha-Sadek/Microprocessor-Simulation-Game
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowCirc.inc
More file actions
114 lines (71 loc) · 1.18 KB
/
ShowCirc.inc
File metadata and controls
114 lines (71 loc) · 1.18 KB
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
.286
ShowCirc MACRO X, Y,R, colour
Local Columny
Local Rowx
Local checkinside
Local draw
Local Ddraw
Local lop
;X,Y,Rd
;X, Y are the center pixel
pusha
mov cx,X ;Column
mov dx,Y ;Row
sub cx,R
sub dx, R
mov ax,colour ;Pixel color ;changed to ax to avoid some error
mov ah,0ch ;Draw Pixel Command
Columny:
mov cx,X
sub cx,R
mov bx,X
add bx,R
Rowx:
;here check first before drawing
pusha
checkinside: ;checks if it satisfies r^2= x^2 + y^2
mov ax,X
sub ax,cx
call axchk
mov si,ax ;si = |X|
push dx ;to preserve its current value
mul si
pop dx
mov si,ax ;si = X^2
mov ax,Y
sub ax,dx
call axchk
mov di,ax ;di = |Y|
push dx ;to preserve its current value
mul di
pop dx
mov di,ax ;di = Y^2
add di,si ;di = X^2 + Y^2
mov ax,R
push dx
mul ax
pop dx
mov si,ax ;si = R^2
cmp di,si
je draw
jl draw
jnle Ddraw
draw:
popa
int 10h
jmp lop
;don't draw
Ddraw:
popa
lop:
inc cx
cmp cx, bx ;Bx = X+R
jnz Rowx
inc dx
; cmp dx,di
mov bx, Y
add bx, R
cmp dx,bx ;Bx = Y+R
jnz Columny
popa
ENDM