-
Notifications
You must be signed in to change notification settings - Fork 0
/
Low Level Paint.asm
1951 lines (1723 loc) · 32.3 KB
/
Low Level Paint.asm
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
bits 16
org 0x7C00
cli
;WRITE YOUR CODE HERE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov ah ,0x02
mov al ,16
mov dl ,0x80
mov dh ,0
mov ch ,0
mov cl ,2
mov bx ,Start
int 0x13
jmp Start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
times (510 - ($ - $$)) db 0
db 0x55, 0xAA
;;;;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Start:
TheBigLoop:
xor eax , eax
mov edi, 0xB8000
mov esi, 0xB8000
xor ebx,ebx
mov edx, MainMenu
loopA:
mov al, [edx]
mov byte [edi], al
inc edi
inc edi
inc edx
inc bx
call cursor
cmp byte[edx],0
jne loopA;
checkStatus:
in al , 0x64
and al, 1
jz checkStatus
call cursor
in al, 0x60
FindKey:
;mov bl,al
cmp al , 0x02
je _activateMouse
cmp al , 0x82
je _activateMouse
cmp al , 0x03
je Activate_Keyboard
cmp al , 0x83
je Activate_Keyboard
jmp FindKey
;call Clear_Screen
jmp TheBigLoop
cursor:
pushad
mov al,0x0f
mov dx,0x03D4
out dx,al
mov al,bl
mov dx,0x03D5
out dx,al
xor eax,eax
mov al,0x0e
mov dx,0x03D4
out dx,al
mov al,bh
mov dx ,0x03D5
out dx,al
popad
ret
_activateMouse:
jmp Mouse
Clear_Screen:
cmp edi,0xB8000
je LET
loopC:
mov al,0x20
mov [edi],al
sub edi,2
cmp edi,0xB8000
jg loopC
LET:
xor ebx,ebx
;call cursor
ret
Activate_Keyboard:
call Clear_Screen
mov edx,ShapeMenu
LoopD:
mov al,[edx]
mov byte [edi],al
inc edi
inc edi
inc edx
inc ebx
call cursor
cmp byte[edx],0
jne LoopD
Check_Pressed_Key:
in al,0x64
and al,1
jz Check_Pressed_Key
call cursor
in al, 0x60
cmp al,0x02
je Square ;;;;;;;; Draw Square
cmp al,0x82
je Square ;;;;;;;; Draw Square
cmp al,0x03
je Circle ;;;;;;;; Draw Circle
cmp al,0x83
je Circle ;;;;;;;; Draw Circle
cmp al,0x04
je Pyramid ;;;;;;;; Draw Pyramid
cmp al,0x84
je Pyramid ;;;;;;;; Draw Pyramid
cmp al,0x05
je Rectangle ;;;;;;;; Draw Rectangle
cmp al,0x85
je Rectangle ;;;;;;;; Draw Rectangle
cmp al,0x06
je RigTriangle ;;;;;;;; Draw RigTriangle
cmp al,0x86
je RigTriangle ;;;;;;;; Draw RigTriangle
cmp al,0x07
je IsoTriangle ;;;;;;;; Draw IsoTriangle
cmp al,0x87
je IsoTriangle ;;;;;;;; Draw IsoTriangle
cmp al,0x08
je EquTriangle ;;;;;;;; Draw EquTriangle
cmp al,0x88
je EquTriangle ;;;;;;;; Draw EquTriangle
cmp al,0x09
je Trapizum ;;;;;;;; Draw Trapizum
cmp al,0x89
je Trapizum ;;;;;;;; Draw Trapizum
cmp al,0x0A
je Diamond ;;;;;;;; Draw Diamond
cmp al,0x8A
je Diamond ;;;;;;;; Draw Diamond
cmp al,0x1E
je FilledCircle ;;;;;;;; Draw FilledCircle
cmp al,0x9E
je FilledCircle ;;;;;;;; Draw FilledCircle
cmp al,0x30
je FilledRectangle ;;;;;;;; Draw FilledRectangle
cmp al,0xb0
je FilledRectangle ;;;;;;;; Draw FilledRectangle
cmp al,0x26
je Lines ;;;;;;;; Draw Lines
cmp al,0xa6
je Lines ;;;;;;;; Draw Lines
;call Clear_Screen
;jmp keyPress2
jmp Check_Pressed_Key
exit:
cli
mov ah , 0
mov al , 3h
int 0x10
call Clear_Screen
jmp TheBigLoop
MainMenu: db 'A.Press 1 for free drawing '
db'B.Press 2 for Shapes',0
ShapeMenu: db 'i.Press 1 for Square '
db 'ii.Press 2 for Circle '
db 'iii.Press 3 for Pyramid '
db 'iv.Press 4 for Rectangle '
db 'v.Press 5 for Rightangle Triangle '
db 'vi.Press 6 for IsoscelesTriangle '
db 'vii.Press 7 for EquilateralTriangle '
db 'viii.Press 8 for Trapizum '
db 'ix.Press 9 for Diamond '
db 'x.Press A for Filled Circle '
db 'xi.Press B for Filled Rectangle '
db 'xii.Press L for Lines '
db 'press ESC in ShapesMenu to return to MainMenu ',0
ColourMenu: db 'A.press 1 for black '
db 'B.press 2 for green '
db 'C.press 3 for red '
db 'D.press 4 for blue',0
color: dw 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Mouse:
mov al,13h
int 10h ;;;;;;; VGA Mode
;;;;;;;;;;; A little something Like A logo sun!!!!!!!!!
call Color_Screen_red ;;;; Color the screen red
call Halt ;;;; Halt the prgram for a split second
call Color_Screen_green ;;;; Color the screen green
call Halt
call Color_Screen_blue ;;;; Color the screen blue
call Halt
bigloop:
;;;;;;;; setups
call Color_Screen ;;;; Color the screen White for the drawing space
call Draw_Color_Menue
;;;;;;;; Enabling The mouse
call writecheck
mov al,0xf4
call writetomouse ;;;;;;;;;; enable
xor eax,eax
xor ecx,ecx
nokey:
in al, 0x64
and al, 0x20 ;;;;;;;;;;check if it's a mouse not a keyboard ,,, bit number 5 is always 1 in case of the mouse
jz nokey
call readfrommouse;;;; status
and al,11b
mov [status],al
cmp al,0
je nothing ;;;;;;;; Do nothing , neither buttons are clicked
cmp al,01h
je draw ;;;;;;;; Right button is clicked ,,,, draw a point at the pixel
jmp delete ;;;;;;;;;;; left button is clicked
delete:
mov ah,0Ch ;
mov al,[background_color]
mov cx,[x] ; x position
mov dx,[y] ; y position
int 10h
call readfrommouse ;;;;;; delta x
movsx dx,al
mov [deltax],dx
call readfrommouse ;;;;;; delta y
movsx ax,al
mov [deltay],ax
mov ax,[deltax]
add [x],ax
mov ax,[deltay]
sub [y],ax
call Check_Border
mov cx,[x]
cmp cx,319
jl noend_delete
mov dx,[y]
cmp dx,199
jge bigloop
noend_delete:
mov cx,[x]
cmp cx,60
jg same_delete
call color_menu_background
jmp next1_delete
same_delete:
mov ax,15
mov [background_color],ax
next1_delete:
mov al,58
mov ah,0ch
mov cx,[x]
mov dx,[y]
int 10h
call readfrommouse ;;;; scroll
jmp nokey
draw:
call readfrommouse ;;;;;; delta x
movsx dx,al
mov [deltax],dx
call readfrommouse ;;;;;; delta y
movsx ax,al
mov [deltay],ax
mov ax,[deltax]
add [x],ax
mov ax,[deltay]
sub [y],ax
call Check_Border
mov cx,[x]
cmp cx,60
jg same
call color_menu_background
jmp next1
same:
mov ax,15
mov [background_color],ax
next1:
mov al,[draw_color]
mov ah,0ch
mov cx,[x]
mov dx,[y]
int 10h
call readfrommouse ;;;; scroll
jmp nokey
nothing:
mov ah,0Ch ;
mov al,[background_color] ;
mov cx,[x] ; x position
mov dx,[y] ; y position
int 10h ;
call readfrommouse ;;;;;; delta x
movsx dx,al
mov [deltax],dx
call readfrommouse ;;;;;; delta y
movsx ax,al
mov [deltay],ax
mov ax,[deltax]
add [x],ax
mov ax,[deltay]
sub [y],ax
call Check_Border
mov cx,[x]
cmp cx,60
jg same1
call color_menu_background
jmp next2
same1:
mov ax,15
mov [background_color],ax
next2:
mov al,[draw_color]
mov ah,0ch
mov cx,[x]
mov dx,[y]
int 10h
call readfrommouse ;;;; scroll
jmp nokey
Check_Border:
mov ax,[x]
cmp ax,0
jge Check_Border_Left
mov ax,0
mov [x],ax
Check_Border_Left:
mov ax,[x]
cmp ax,319
jle Check_Border_Right
mov ax,319
mov [x],ax
Check_Border_Right:
mov ax,[y]
cmp ax,0
jge Check_Border_up
mov ax,0
mov [y],ax
Check_Border_up:
mov ax,[y]
cmp ax,199
jle Check_Border_down
mov ax,199
mov [y],ax
Check_Border_down:
ret
;;;;;;;;;;;;; Check if the mouse can be written to
writecheck:
mov ecx,1000
one:
in al,0x64
and al,02h ;;;;;;;;is there a something that can write to
jz nxt
loop one
nxt:
ret
;;;;;;;;;;;;;;;; check if the mouse can be read from
readcheck:
mov ecx,1000
two:
in al,0x64
and al,01h ;;;;;;;;is theresomething can read from
jnz nxxt
loop two
nxxt:
ret
;;;;;;;;;;;;;; send a massage to the mouse
writetomouse:
mov dh,al ;;;; al = 0xf4
call writecheck ;;;;can you w
mov al,0xd4 ;;;;; notify the mouse that its going to recive a msg from user
out 0x64,al
call writecheck
mov al,dh
out 0x60,al
call readcheck
in al,0x60 ;;;;;; read response
ret
;;;;;;;;;;;;; read a massage from the mouse
readfrommouse:
call readcheck
in al,0x60
ret
;;;;;;;;;;;;;; colors the screen white
Color_Screen:
mov cx,320
Color_Screen_cxloop:
mov dx,200
Color_Screen_dxloop:
mov al,15
mov ah,0ch
int 10h
dec dx
cmp dx,0
jl Color_Screen_dxdone
jmp Color_Screen_dxloop
Color_Screen_dxdone:
dec cx
cmp cx,0
jl Color_Screen_cxdone
jmp Color_Screen_cxloop
Color_Screen_cxdone:
ret
;;;;;;;;;;;; draws the left window to choose your color
Draw_Color_Menue:
mov cx,60
Draw_Color_Menue_cxloop:
mov dx,0
Draw_Color_Menue_dxloop:
mov al,1000b
mov ah,0ch
int 10h
inc dx
cmp dx,200
jge Draw_Color_Menue_dxdone
jmp Draw_Color_Menue_dxloop
Draw_Color_Menue_dxdone:
dec cx
cmp cx,0
jl Draw_Color_Menue_cxdone
jmp Draw_Color_Menue_cxloop
Draw_Color_Menue_cxdone:
;;;;;;;;;;; each color takes 40 and has 5 above and underneath and left and right
;;;;;;;;;;; x starts at 5 and ends at 55
;;;;;;;;;;; y starts at 5 and ends at 195
mov cx,5 ;;;;;;x start
mov si,55 ;;;;;;x end
mov dx,5 ;;;;;;;; y start
mov di,45 ;;;;;;;;y end
mov bx,0 ;;;;;;; black
call Draw_Square
mov cx,5 ;;;;;;x start
mov dx,55 ;;;;;;y start
mov di,95 ;;;;;;y end
mov bx,0100b ;;;;;; red
call Draw_Square
mov cx,5 ;;;;;;x start
mov dx,105 ;;;;;;y start
mov di,145 ;;;;;;y end
mov bx,0001b ;;;;;;;; blue
call Draw_Square
mov cx,5 ;;;;;;x start
mov dx,155 ;;;;;;y start
mov di,195 ;;;;;;y end
mov bl,0010b ;;;;;;;; green
call Draw_Square
ret
Draw_Square:
mov word[tmp],dx
Draw_Square_cxloop:
mov dx,[tmp]
Draw_Square_dxloop:
mov al,bl
mov ah,0ch
int 10h
inc dx
cmp dx,di
jge Draw_Square_dxdone
jmp Draw_Square_dxloop
Draw_Square_dxdone:
inc cx
cmp cx,si
jg Draw_Square_done
jmp Draw_Square_cxloop
Draw_Square_done:
ret
color_menu_background:
mov cx,[x]
mov dx,[y]
;;;;;; current X and Y position
cmp cx,5 ;;;; left border
jge forward
jmp now
forward:
cmp cx,55 ;;;; right border
jg now
cmp dx,5 ;;;; upper border
jge l
jmp now
l:
cmp dx,195 ;;;; lower border
jg now
black1:
cmp dx,44 ;;;;; end of black box
jg outofblack
mov ax,0
mov [background_color],ax
cmp word[status],1
je pressblack
jmp nopressblack
pressblack:
mov [draw_color],ax
nopressblack:
jmp color_menu_background_done
outofblack:
cmp dx,55 ;;; end of first middle border
jl border1
jmp red1
border1:
cmp dx,44 ;;;; begginig of first middle border
jg now
red1:
cmp dx,94 ;;;;; end of red box
jg outofred
mov ax,0100b
mov [background_color],ax
cmp word[status],1
je pressred
jmp nopressred
pressred:
mov [draw_color],ax
nopressred:
jmp color_menu_background_done
outofred:
cmp dx,105 ;;; end of second middle border
jl border2
jmp blue1
border2:
cmp dx,94 ;;; beggining of second middle border
jg now
blue1:
cmp dx,144 ;;;;; end of blue box
jg outofblue
mov ax,0001b
mov [background_color],ax
cmp word[status],1
je pressblue
jmp nopressblue
pressblue:
mov [draw_color],ax
nopressblue:
jmp color_menu_background_done
outofblue:
cmp dx,155 ;;; end of third middle border
jl border3
jmp green1
border3:
cmp dx,144 ;;; bigining of third middle border
jg now
green1:
cmp dx,194 ;;;;; end of black box
jg outofgreen
mov ax,0010b
mov [background_color],ax
cmp word[status],1
je pressgreen
jmp nopressgreen
pressgreen:
mov [draw_color],ax
nopressgreen:
jmp color_menu_background_done
outofgreen:
jmp now
color_menu_background_done:
ret
now:
mov ax,1000b
mov [background_color],ax
jmp color_menu_background_done
Color_Screen_red:
mov dx,200
Color_Screen_red_dxloop:
mov cx,320
Color_Screen_red_cxloop:
mov al,0100b
mov ah,0ch
int 10h
dec cx
cmp cx,0
jl Color_Screen_red_cxdone
jmp Color_Screen_red_cxloop
Color_Screen_red_cxdone:
dec dx
cmp dx,0
jl Color_Screen_red_dxdone
jmp Color_Screen_red_dxloop
Color_Screen_red_dxdone:
ret
Color_Screen_green:
mov cx,0
Color_Screen_green_cxloop:
mov dx,0
Color_Screen_green_dxloop:
mov al,0010b
mov ah,0ch
int 10h
inc dx
cmp dx,200
jg Color_Screen_green_dxdone
jmp Color_Screen_green_dxloop
Color_Screen_green_dxdone:
inc cx
cmp cx,320
jg Color_Screen_green_cxdone
jmp Color_Screen_green_cxloop
Color_Screen_green_cxdone:
ret
Color_Screen_blue:
mov dx,0
Color_Screen_blue_dxloop:
mov cx,0
Color_Screen_blue_cxloop:
mov al,0001b
mov ah,0ch
int 10h
inc cx
cmp cx,320
jg Color_Screen_blue_cxdone
jmp Color_Screen_blue_cxloop
Color_Screen_blue_cxdone:
inc dx
cmp dx,200
jg Color_Screen_blue_dxdone
jmp Color_Screen_blue_dxloop
Color_Screen_blue_dxdone:
ret
Halt:
mov esi,10000
Halt_loop:
mov ecx,1000
halt_loop:
nop
nop
nop
nop
loop halt_loop
dec esi
cmp esi,0
jle halt_done
jmp Halt_loop
halt_done:
ret
Lines:;
cli
jmp Drawlines
heightline: dw 100
widthline: dw 100
xlinebegin1: dw 15
ylinebegin1: dw 10
xlinebegin2: dw 15
ylinebegin2: dw 150
xlinebegin3: dw 200
ylinebegin3: dw 10
xlinebegin4: dw 260
ylinebegin4: dw 90
xlineend1: dw 15
ylineend1: dw 110
xlineend2: dw 150
ylineend2: dw 150
xlineend3: dw 300
ylineend3: dw 110
xlineend4: dw 160
ylineend4: dw 190
Drawlines:
call Activate_Keyboard2
videographicssquarel:
mov ah, 0
mov al , 0x13
int 0x10
call Color_Screen
linepixels:
mov ah,0ch
mov al, [color]
Drawlineloop:
getlineTrapizuml:
mov cx,[xlinebegin1]
mov dx,[ylinebegin1]
horizontal:
int 10h
inc dx
cmp dx, [ylineend1]
jnz horizontal
mov cx,[xlinebegin2]
mov dx,[ylinebegin2]
vertical:
int 10h
inc cx
cmp cx, [xlineend2]
jnz vertical
mov cx,[xlinebegin3]
mov dx,[ylinebegin3]
negslope:
int 10h
inc cx
inc dx
cmp cx, [xlineend3]
cmp dx, [ylineend3]
jnz negslope
mov cx,[xlinebegin4]
mov dx,[ylinebegin4]
posslope:
int 10h
dec cx
inc dx
cmp cx, [xlineend4]
cmp cx, [ylineend4]
jnz posslope
ret
;;;;;;;;;;;;;;color_menu
Activate_Keyboard2:
call Clear_Screen
mov edx,ColourMenu
LoopD2:
mov al,[edx]
mov byte [edi],al
inc edi
inc edi
inc edx
inc ebx
call cursor
cmp byte[edx],0
jne LoopD2
Check_Pressed_Key2:
in al,0x64
and al,1
jz Check_Pressed_Key2
call cursor
in al, 0x60
keyPress3:
cmp al,0x02 ;;1
je black
cmp al ,0x82
je black
cmp al,0x03 ;;2
je green
cmp al ,0x83
je green
cmp al,0x04 ;;3
je red
cmp al ,0x84
je red
cmp al,0x05 ;;4
je blue
cmp al ,0x85
je blue
jmp Check_Pressed_Key2
black:
mov dx,0
mov [color],dx
ret
green:
mov dx,2
mov [color],dx
ret
red:
mov dx,4
mov [color],dx
ret
blue:
mov dx,1
mov [color],dx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Circle:
cli
jmp Drawcircle
;;;;;;;;;;;;
radiusfc: dw 75
xcc: dw 160
ycc: dw 100
xc: dw 0
yc: dw 0
circleerror: dw 0
columnc: dw 0
rowc: dw 0
circlepixels:
mov ah,0ch
mov al, [color]
mov cx,[columnc]
mov dx,[rowc]
int 10h
ret
Drawcircle:
call Activate_Keyboard2
videographicsforcircle:
mov ah, 0
mov al , 0x13
int 0x10
call Color_Screen
Drawcircleloop:
mov bx, [radiusfc]
mov [xc],bx
Plotcirclepixels:
;condition is x>y
mov bx,[xc]
cmp bx,[yc]
jl donecircle
;(xc+x,yc+y)
mov cx, [xcc]
add cx, [xc]
mov [columnc],cx
mov dx, [ycc]
add dx,[yc]
mov [rowc], dx
call circlepixels
;(xc+x,yc-y)
mov cx, [xcc]
add cx, [xc]
mov [columnc],cx
mov dx, [ycc]
sub dx,[yc]
mov [rowc], dx
call circlepixels
;(xc-x,yc+y)
mov cx, [xcc]
sub cx, [xc]
mov [columnc],cx
mov dx, [ycc]
add dx,[yc]
mov [rowc], dx
call circlepixels
;(xc-x,yc-y)
mov cx, [xcc]
sub cx, [xc]
mov [columnc],cx
mov dx, [ycc]
sub dx,[yc]
mov [rowc], dx
call circlepixels
;(xc+y,yc+x)
mov cx, [xcc]
add cx, [yc]
mov [columnc],cx
mov dx, [ycc]
add dx,[xc]
mov [rowc], dx
call circlepixels
;(xc+y,yc-x)
mov cx, [xcc]
add cx, [yc]
mov [columnc],cx
mov dx, [ycc]
sub dx,[xc]
mov [rowc], dx
call circlepixels
;(xc-y,yc+x)
mov cx, [xcc]
sub cx, [yc]
mov [columnc],cx
mov dx, [ycc]
add dx,[xc]
mov [rowc], dx
call circlepixels
;(xc-y,yc-x)
mov cx, [xcc]
sub cx, [yc]
mov [columnc],cx
mov dx, [ycc]
sub dx,[xc]
mov [rowc], dx
call circlepixels
; Update state values and check error:
cmp word [circleerror], 0
jge greatercircle
inc word [yc]
mov ax ,[yc]
add ax,ax
inc ax
add ax,[circleerror]
mov [circleerror],ax
jmp Plotcirclepixels
greatercircle:
dec word [xc]
mov ax , [xc]
add ax,ax
neg ax
inc ax
add ax,[circleerror]
mov [circleerror],ax
jmp Plotcirclepixels
donecircle:
ret
;;;;;;;;;;;;;;;;
Diamond:
cli
jmp Drawdiamond
radiusdiam: dw 75
xdiamc: dw 160
ydiamc: dw 100
xdiam1: dw 0
ydiam1: dw 0
xdiam2: dw 0
ydiam2: dw 0
xdiam3: dw 0
ydiam3: dw 0
xdiam4: dw 0
ydiam4: dw 0
diamonderror: dw 0
Drawdiamond:; use the bresenhams algorithms
call Activate_Keyboard2
videographicsdiamond:
mov ah, 0
mov al , 0x13