-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathgraphics_lib.asm
4131 lines (4020 loc) · 76 KB
/
graphics_lib.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
#include "..\..\..\include\relocation.inc"
#include "..\..\..\include\ti84pce.inc"
.libraryName "GRAPHX" ; Name of library
.libraryVersion 2 ; Version information (1-255)
;-------------------------------------------------------------------------------
; v1 functions - Can no longer move/delete
;-------------------------------------------------------------------------------
.function "gfx_Begin",_Begin
.function "gfx_End",_End
.function "gfx_SetColor",_SetColor
.function "gfx_SetDefaultPalette",_SetDefaultPalette
.function "gfx_SetPalette",_SetPalette
.function "gfx_FillScreen",_FillScreen
.function "gfx_SetPixel",_SetPixel
.function "gfx_GetPixel",_GetPixel
.function "gfx_GetDraw",_GetDraw
.function "gfx_SetDraw",_SetDraw
.function "gfx_SwapDraw",_SwapDraw
.function "gfx_Blit",_Blit
.function "gfx_BlitLines",_BlitLines
.function "gfx_BlitArea",_BlitArea
.function "gfx_PrintChar",_PrintChar
.function "gfx_PrintInt",_PrintInt
.function "gfx_PrintUInt",_PrintUInt
.function "gfx_PrintString",_PrintString
.function "gfx_PrintStringXY",_PrintStringXY
.function "gfx_SetTextXY",_SetTextXY
.function "gfx_SetTextBGColor",_SetTextBGColorC
.function "gfx_SetTextFGColor",_SetTextFGColorC
.function "gfx_SetTextTransparentColor",_SetTextTransparentColorC
.function "gfx_SetCustomFontData",_SetCustomFontData
.function "gfx_SetCustomFontSpacing",_SetCustomFontSpacing
.function "gfx_SetMonospaceFont",_SetMonospaceFont
.function "gfx_GetStringWidth",_GetStringWidth
.function "gfx_GetCharWidth",_GetCharWidth
.function "gfx_GetTextX",_GetTextX
.function "gfx_GetTextY",_GetTextY
.function "gfx_Line",_Line
.function "gfx_HorizLine",_HorizLine
.function "gfx_VertLine",_VertLine
.function "gfx_Circle",_Circle
.function "gfx_FillCircle",_FillCircle
.function "gfx_Rectangle",_Rectangle
.function "gfx_FillRectangle",_FillRectangle
.function "gfx_Line_NoClip",_Line_NoClip
.function "gfx_HorizLine_NoClip",_HorizLine_NoClip
.function "gfx_VertLine_NoClip",_VertLine_NoClip
.function "gfx_FillCircle_NoClip",_FillCircle_NoClip
.function "gfx_Rectangle_NoClip",_Rectangle_NoClip
.function "gfx_FillRectangle_NoClip",_FillRectangle_NoClip
.function "gfx_SetClipRegion",_SetClipRegion
.function "gfx_GetClipRegion",_GetClipRegion
.function "gfx_ShiftDown",_ShiftDown
.function "gfx_ShiftUp",_ShiftUp
.function "gfx_ShiftLeft",_ShiftLeft
.function "gfx_ShiftRight",_ShiftRight
.function "gfx_Tilemap",_Tilemap
.function "gfx_Tilemap_NoClip",_Tilemap_NoClip
.function "gfx_TransparentTilemap",_TransparentTilemap
.function "gfx_TransparentTilemap_NoClip",_TransparentTilemap_NoClip
.function "gfx_TilePtr",_TilePtr
.function "gfx_TilePtrMapped",_TilePtrMapped
.function "gfx_LZDecompress",_LZDecompress
.function "gfx_AllocSprite",_AllocSprite
.function "gfx_Sprite",_Sprite
.function "gfx_TransparentSprite",_TransparentSprite
.function "gfx_Sprite_NoClip",_Sprite_NoClip
.function "gfx_TransparentSprite_NoClip",_TransparentSprite_NoClip
.function "gfx_GetSprite_NoClip",_GetSprite_NoClip
.function "gfx_ScaledSprite_NoClip",_ScaledSprite_NoClip
.function "gfx_ScaledTransparentSprite_NoClip",_ScaledTransparentSprite_NoClip
.function "gfx_FlipSpriteY",_FlipSpriteY
.function "gfx_FlipSpriteX",_FlipSpriteX
.function "gfx_RotateSpriteC",_RotateSpriteC
.function "gfx_RotateSpriteCC",_RotateSpriteCC
.function "gfx_RotateSpriteHalf",_RotateSpriteHalf
.function "gfx_Polygon",_Polygon
.function "gfx_Polygon_NoClip",_Polygon_NoClip
.function "gfx_FillTriangle",_FillTriangle
.function "gfx_FillTriangle_NoClip",_FillTriangle_NoClip
;-------------------------------------------------------------------------------
; v2 functions
;-------------------------------------------------------------------------------
.function "gfx_LZDecompressSprite",_LZDecompressSprite
.function "gfx_SetTextScale",_SetTextScale
;-------------------------------------------------------------------------------
.beginDependencies
.endDependencies
;-------------------------------------------------------------------------------
; Used throughout the library
lcdSize equ lcdWidth*lcdHeight
currDrawBuffer equ 0E30014h
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
_AllocSprite:
; Allocates space for a new sprite
; Arguments:
; arg0 : width
; arg1 : height
; arg2 : pointer to malloc routine
ld iy,0
add iy,sp
ld l,(iy+3)
ld h,(iy+6)
ld iy,(iy+9)
push hl
mlt hl
inc hl
inc hl
push hl
call __indcall
pop de
pop de
ld (hl),e
inc hl
ld (hl),d
dec hl
ret
;-------------------------------------------------------------------------------
_SetClipRegion:
; Sets the clipping for clipped routines
; Arguments:
; arg0 : Xmin
; arg1 : Ymin
; arg2 : Xmax
; arg3 : Ymax
; Must be within (0,0,320,240)
; Returns:
; None
call _SetFullScreenClipping_ASM \.r ; clip against the actual LCD screen
ld iy,0
add iy,sp
call _ClipRectangularRegion_ASM \.r ; iy points to the start of the arguments
lea hl,iy
ret c
ld de,_xmin \.r ; copy the variables in
ld bc,12
ldir
ret
;-------------------------------------------------------------------------------
_SetColor:
; Sets the global color index for all routines
; Arguments:
; arg0 : Color Index
; Returns:
; Previous global color index
pop hl
pop de
push de
push hl
ld hl,color1 \.r
ld d,(hl)
ld a,e
ld (hl),a
ld (color2),a \.r
ld (color3),a \.r
ld (color4),a \.r
ld (color5),a \.r
ld a,d
ret
;-------------------------------------------------------------------------------
_Begin:
; Sets up the graphics canvas (8bpp, default palette)
; Arguments:
; None
; Returns:
; None
call _boot_ClearVRAM ; clear the screen
ld hl,tmpWidth
ld bc,11
call _MemClear
ld hl,currDrawBuffer
ld a,lcdBpp8
_: ld de,vram
ld (hl),de ; set the current draw to the screen
ld hl,mpLcdCtrl
ld (hl),a
ld l,mpLcdIcr&$FF
ld (hl),4 ; allow interrupts status for double buffering
jr _SetDefaultPalette ; setup the default palette
;-------------------------------------------------------------------------------
_End:
; Closes the graphics library and sets up for the TI-OS
; Arguments:
; None
; Returns:
; None
call _boot_ClearVRAM ; clear the screen
ld hl,mpLcdBase
ld a,lcdBpp16 ; restore the screen mode
jr -_
;-------------------------------------------------------------------------------
_SetDefaultPalette:
; Sets up the default palette where H=L
; Arguments:
; None
; Returns:
; None
ld de,mpLcdPalette
ld b,e
_: ld a,b
rrca
xor a,b
and a,%11100000
xor a,b
ld (de),a
inc de
ld a,b
rra
ld (de),a
inc de
inc b
jr nz,-_
ret
;-------------------------------------------------------------------------------
_FillScreen:
; Fills the screen with the specified color index
; Arguments:
; arg0 : Color Index
; Returns:
; None
ld hl,3
add hl,sp
ld a,(hl) ; get the color index to use
ld bc,lcdSize-1
ld de,(currDrawBuffer)
sbc hl,hl
add hl,de
inc de
ld (hl),a
ldir
ret
;-------------------------------------------------------------------------------
_SetPalette:
; Sets the palette starting at 0x00 index and onward
; Arguments:
; arg0 : Pointer to palette
; arg1 : Size of palette in bytes
; arg2 : Offset at which to start inserting the palette
; Returns:
; None
ld iy,0
add iy,sp
sbc hl,hl
ld l,(iy+9) ; offset in palette
add hl,hl
ld de,mpLcdPalette
add hl,de
ex de,hl
ld hl,(iy+3) ; pointer to input palette
ld bc,(iy+6) ; size of input palette
ldir ; copy the palette in
ret
;-------------------------------------------------------------------------------
_GetPixel:
; Gets the color index of a pixel
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; Returns:
; Color index of X,Y Coord
ld hl,3
add hl,sp
ld bc,(hl) ; x coordinate
inc hl
inc hl
inc hl
ld de,0
ld e,(hl) ; y coordinate
call _PixelPtr_ASM \.r
ret c
ld a,(hl) ; get the actual pixel
ret
;-------------------------------------------------------------------------------
_SetPixel:
; Sets the color pixel to the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; Returns:
; None
ld hl,3
add hl,sp
ld bc,(hl) ; x coordinate
inc hl
inc hl
inc hl
ld de,0
ld e,(hl) ; y coordinate
_SetPixel_ASM:
call _PixelPtr_ASM \.r
ret c
color1 =$+1
ld (hl),0 ; get the actual pixel
ret
;-------------------------------------------------------------------------------
_FillRectangle:
; Draws an unclipped rectangle with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Width
; arg3 : Height
; Returns:
; None
ld iy,0
add iy,sp
ld hl,(iy+9) ; hl = width
ld de,(iy+3) ; de = x coordinate
add hl,de
ld (iy+9),hl
ld hl,(iy+12) ; hl = height
ld de,(iy+6) ; de = y coordinate
add hl,de
ld (iy+12),hl
call _ClipRectangularRegion_ASM \.r
ret c ; return if offscreen
ld de,(iy+3)
ld hl,(iy+9)
sbc hl,de ; make sure that the width is not 0
ret z
push hl
ld de,(iy+6)
ld hl,(iy+12)
sbc hl,de
pop bc ; bc = new width
ret z
ld a,l ; a = new height
ld hl,(iy+3) ; hl = new x, de = new y
jr _FillRectangle_NoClip_ASM
;-------------------------------------------------------------------------------
_FillRectangle_NoClip:
; Draws an unclipped rectangle with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Width
; arg3 : Height
; Returns:
; None
ld iy,0
add iy,sp
ld a,(iy+12) ; a = height
or a,a
ret z ; make sure height is not 0
ld bc,(iy+9) ; bc = width
sbc hl,hl
adc hl,bc
ret z ; make sure width is not 0
ld hl,(iy+3) ; hl = x coordinate
ld e,(iy+6) ; e = y coordinate
_FillRectangle_NoClip_ASM:
ld d,lcdWidth/2
mlt de
add hl,de
add hl,de
ld de,(currDrawBuffer)
add hl,de
ex de,hl ; de -> place to begin drawing
push de
ld (_RectangleWidth1_SMC),bc \.r
ld (_RectangleWidth2_SMC),bc \.r
ld hl,color1 \.r
ldi ; check if we only need to draw 1 pixel
pop hl
jp po,_Rectangle_NoClip_Skip \.r
ldir
_Rectangle_NoClip_Skip:
dec a
ret z
inc b
ld c,$40 ; = slightly faster "ld bc,lcdWidth"
_Rectangle_Loop_NoClip:
add hl,bc
dec de
ex de,hl
_RectangleWidth1_SMC =$+1
ld bc,0
lddr
dec a
ret z
ld bc,2*lcdWidth+1
add hl,bc
inc de
ex de,hl
_RectangleWidth2_SMC =$+1
ld bc,0
ldir
ld bc,2*lcdWidth-1
dec a
jr nz,_Rectangle_Loop_NoClip
ret
;-------------------------------------------------------------------------------
_Rectangle:
; Draws an clipped rectangle outline with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Width
; arg3 : Height
; Returns:
; None
push ix ; need to use ix because lines use iy
ld ix,0
add ix,sp
ld hl,(ix+6)
ld de,(ix+9)
ld bc,(ix+12)
push bc
push de
push hl
call _HorizLine \.r ; top horizontal line
ld sp,ix
ld hl,(ix+6)
ld de,(ix+9)
ld bc,(ix+15)
push bc
push de
push hl
call _VertLine \.r ; left vertical line
ld sp,ix
ld hl,(ix+6)
ld de,(ix+9)
ld bc,(ix+12)
add hl,bc ; add x and width
dec hl
ld bc,(ix+15)
push bc
push de
push hl
call _VertLine \.r ; right vertical line
ld sp,ix
ld de,(ix+6)
ld hl,(ix+9)
ld bc,(ix+15)
add hl,bc
dec hl ; add y and height
ld bc,(ix+12)
push bc
push hl
push de
call _HorizLine \.r ; bottom horizontal line
ld sp,ix
pop ix
ret
;-------------------------------------------------------------------------------
_Rectangle_NoClip:
; Draws an unclipped rectangle outline with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Width
; arg3 : Height
; Returns:
; None
ld iy,0
add iy,sp
ld hl,(iy+3)
ld e,(iy+6)
ld bc,(iy+9)
ld d,(iy+12)
push bc
push hl
push de
call _RectHoriz_ASM \.r ; top horizontal line
pop bc
push bc
call _RectVert_ASM \.r ; left vertical line
pop bc
pop hl
ld e,c
call _VertLine_ASM \.r ; right vertical line
pop bc
jp _MemSet_ASM \.r ; bottom horizontal line
;-------------------------------------------------------------------------------
_HorizLine:
; Draws an clipped horizontal line with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Length
; Returns:
; None
ld iy,0
add iy,sp
ld de,(_ymin) \.r
ld hl,(iy+6)
call _SignedCompare_ASM \.r ; compare y coordinate <-> ymin
ret c
ld hl,(_ymax) \.r
ld de,(iy+6)
call _SignedCompare_ASM \.r ; compare y coordinate <-> ymax
ret c
ld hl,(iy+9)
ld de,(iy+3)
add hl,de
ld (iy+9),hl
ld hl,(_xmin) \.r
call _Max_ASM \.r
ld (iy+3),hl ; save maximum x value
ld hl,(_xmax) \.r
ld de,(iy+9)
call _Min_ASM \.r
ld (iy+9),hl ; save minimum x value
ld de,(iy+3)
call _SignedCompare_ASM \.r
ret c
ld hl,(iy+9)
sbc hl,de
push hl
pop bc ; bc = length
ld e,(iy+6) ; e = y coordinate
jr _RectHoriz_ASM
;-------------------------------------------------------------------------------
_HorizLine_NoClip:
; Draws an unclipped horizontal line with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Length
; Returns:
; None
ld iy,0
add iy,sp
ld e,(iy+6) ; y coordinate
ld bc,(iy+9) ; x coordinate
_RectHoriz_ASM:
sbc hl,hl
adc hl,bc
ret z ; make sure the width is not 0
ld hl,(iy+3)
_HorizLine_NoClip_ASM:
ld d,lcdWidth/2
mlt de
add hl,de
add hl,de
ld de,(currDrawBuffer)
add hl,de ; hl -> place to draw
color2 =$+1
ld a,0 ; color index to use
_MemSet_ASM:
ld (hl),a
push hl
cpi
ex de,hl
pop hl
ret po
ldir
ret
;-------------------------------------------------------------------------------
_VertLine:
; Draws an clipped vertical line with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Length
; Returns:
; None
ld iy,0
add iy,sp
ld hl,(_xmax) \.r
ld de,(iy+3)
inc de
call _SignedCompare_ASM \.r
ret c ; return if x > xmax
ld hl,(iy+3)
ld de,(_xmin) \.r
call _SignedCompare_ASM \.r
ret c ; return if x < xmin
ld hl,(iy+9)
ld de,(iy+6)
add hl,de
ld (iy+9),hl
ld hl,(_ymin) \.r
call _Max_ASM \.r ; get minimum y
ld (iy+6),hl
ld hl,(_ymax) \.r
ld de,(iy+9)
call _Min_ASM \.r ; get maximum y
ld (iy+9),hl
ld de,(iy+6)
call _SignedCompare_ASM \.r
ret c ; return if not within y bounds
ld hl,(iy+9)
sbc hl,de
ld b,l
inc b
ld hl,(iy+3)
jr _VertLine_ASM ; jump to unclipped version
;-------------------------------------------------------------------------------
_VertLine_NoClip:
; Draws an unclipped vertical line with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Length
; Returns:
; None
ld iy,0
add iy,sp
ld hl,(iy+3) ; x
ld e,(iy+6) ; y
ld b,(iy+9) ; length
_VertLine_ASM:
xor a
or b
ret z
ld d,lcdWidth/2
mlt de
add.s hl,de
add hl,de
ld de,(currDrawBuffer)
add hl,de ; hl -> drawing location
_RectVert_ASM:
ld de,lcdWidth
color3 =$+1
ld a,0
_: ld (hl),a ; loop for height
add hl,de
djnz -_
ret
;-------------------------------------------------------------------------------
_SetDraw:
; Forces drawing routines to operate on the offscreen buffer
; or to operate on the visible screen
; Arguments:
; arg0: buffer or screen
; Returns:
; None
pop hl
pop bc
push bc
push hl
ld hl,(mpLcdBase)
ld de,vram
ld a,c
or a,a
jr z,+++_
sbc hl,de
jr nz,++_ ; if not the same, swap
_: ld de,vram+lcdSize
_: ld (currDrawBuffer),de
ret
_: sbc hl,de
jr z,--_ ; if the same, swap
jr ---_
;-------------------------------------------------------------------------------
_SwapDraw:
; Safely swap the vram buffer pointers for double buffered output
; Arguments:
; None
; Returns:
; None
ld hl,vram
ld de,(mpLcdBase)
or a,a
sbc hl,de
add hl,de
jr nz,+_
ld hl,vram+lcdSize
_: ld (currDrawBuffer),de ; set up the new buffer location
ld (mpLcdBase),hl ; set the new pointer location
ld hl,mpLcdIcr
set 2,(hl) ; clear the previous intrpt set
ld l,mpLcdRis&$ff
_: bit 2,(hl) ; wait until the interrupt triggers
jr z,-_
ret
;-------------------------------------------------------------------------------
_GetDraw:
; Gets the current drawing state
; Arguments:
; None
; Returns:
; Returns true if drawing on the buffer
ld hl,(currDrawBuffer)
ld de,(mpLcdBase)
xor a,a
sbc hl,de
ret z ; drawing to screen
inc a
ret ; drawing to buffer
;-------------------------------------------------------------------------------
_Circle:
; Draws a clipped circle outline
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Radius
; Returns:
; None
ld iy,0
add iy,sp
lea hl,iy+-9
ld sp,hl
sbc hl,sp
ld (iy+-3),hl
ld bc,(iy+9)
ld (iy+-6),bc
inc hl
sbc hl,bc
ld (iy+-9),hl
jp l_4 \.r
l_5: ld bc,(iy+3)
ld hl,(iy+-6)
add hl,bc
push hl
push hl
pop bc
ld de,(iy+6)
ld hl,(iy+-3)
add hl,de
ex de,hl
push de
call _SetPixel_ASM \.r
ld bc,(iy+6)
ld hl,(iy+-6)
add hl,bc
ex de,hl
push de
ld bc,(iy+3)
ld hl,(iy+-3)
add hl,bc
push hl
push hl
pop bc
call _SetPixel_ASM \.r
ld bc,(iy+-6)
ld hl,(iy+6)
or a,a
sbc hl,bc
ex de,hl
pop bc
push de
call _SetPixel_ASM \.r
pop de
ld bc,(iy+-3)
ld hl,(iy+3)
or a,a
sbc hl,bc
push hl
push hl
pop bc
call _SetPixel_ASM \.r
pop bc
pop de
call _SetPixel_ASM \.r
pop de
ld bc,(iy+-6)
ld hl,(iy+3)
or a,a
sbc hl,bc
push hl
push hl
pop bc
call _SetPixel_ASM \.r
ld bc,(iy+-3)
ld hl,(iy+6)
or a,a
sbc hl,bc
ex de,hl
pop bc
push de
call _SetPixel_ASM \.r
pop de
pop bc
call _SetPixel_ASM \.r
ld bc,(iy+-3)
inc bc
ld (iy+-3),bc
ld bc,(iy+-9)
or a,a
sbc hl,hl
sbc hl,bc
jp m,l__2 \.r
jp pe,l_3 \.r
jr l__3
l__2: jp po,l_3 \.r
l__3: ld hl,(iy+-3)
add hl,hl
inc hl
ld bc,(iy+-9)
add hl,bc
ld (iy+-9),hl
jr l_4
l_3: ld bc,(iy+-6)
dec bc
ld (iy+-6),bc
ld hl,(iy+-3)
ld de,(iy+-9)
or a,a
sbc hl,bc
add hl,hl
inc hl
add hl,de
ld (iy+-9),hl
l_4: ld bc,(iy+-3)
ld hl,(iy+-6)
or a,a
sbc hl,bc
jp p,l__4 \.r
jp pe,l_5 \.r
jr +_
l__4: jp po,l_5 \.r
_: ld sp,iy
ret
;-------------------------------------------------------------------------------
_FillCircle:
; Draws an clipped circle
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Radius
; Returns:
; None
push ix
ld ix,0
add ix,sp
lea hl,ix+-9
ld sp,hl
sbc hl,hl
ld (ix+-3),hl
ld bc,(ix+12)
ld (ix+-6),bc
inc hl
sbc hl,bc
ld (ix+-9),hl
jp b_4 \.r
_FillCircleSectors:
ld hl,(ix+-3)
add hl,hl
push hl
ld bc,(ix+-6)
ld hl,(ix+9)
add hl,bc
push hl
ld bc,(ix+-3)
ld hl,(ix+6)
or a,a
sbc hl,bc
push hl
call _HorizLine \.r
lea hl,ix+-9
ld sp,hl
ld hl,(ix+-3)
add hl,hl
push hl
ld bc,(ix+-6)
ld hl,(ix+9)
or a,a
sbc hl,bc
push hl
ld bc,(ix+-3)
ld hl,(ix+6)
or a,a
sbc hl,bc
push hl
call _HorizLine \.r
lea hl,ix+-9
ld sp,hl
ld hl,(ix+-6)
add hl,hl
push hl
ld bc,(ix+-3)
ld hl,(ix+9)
add hl,bc
push hl
ld bc,(ix+-6)
ld hl,(ix+6)
or a,a
sbc hl,bc
push hl
call _HorizLine \.r
lea hl,ix+-9
ld sp,hl
ld hl,(ix+-6)
add hl,hl
push hl
ld bc,(ix+-3)
ld hl,(ix+9)
or a,a
sbc hl,bc
push hl
ld bc,(ix+-6)
ld hl,(ix+6)
or a,a
sbc hl,bc
push hl
call _HorizLine \.r
lea hl,ix+-9
ld sp,hl
ld bc,(ix+-3)
inc bc
ld (ix+-3),bc
ld bc,(ix+-9)
or a,a
sbc hl,hl
sbc hl,bc
jp m,b__2 \.r
jp pe,b_3 \.r
jr b__3
b__2: jp po,b_3 \.r
b__3: ld hl,(ix+-3)
add hl,hl
inc hl
ld bc,(ix+-9)
add hl,bc
ld (ix+-9),hl
jr b_4
b_3: ld bc,(ix+-6)
dec bc
ld (ix+-6),bc
ld hl,(ix+-3)
ld de,(ix+-9)
or a,a
sbc hl,bc
add hl,hl
inc hl
add hl,de
ld (ix+-9),hl
b_4: ld bc,(ix+-3)
ld hl,(ix+-6)
or a,a
sbc hl,bc
jp p,+_ \.r
jp pe,_FillCircleSectors \.r
ld sp,ix
pop ix
ret
_: jp po,_FillCircleSectors \.r
ld sp,ix
pop ix
ret
;-------------------------------------------------------------------------------
_FillCircle_NoClip:
; Draws an unclipped circle
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Radius
; Returns:
; None
push ix
ld ix,0
add ix,sp
lea hl,ix+-9
ld sp,hl
sbc hl,hl
ld (ix+-3),hl
ld bc,(ix+12)
ld (ix+-6),bc
inc hl
sbc hl,bc
ld (ix+-9),hl
jp k_4 \.r
_FillCircle_NoClipSectors:
ld hl,(ix+-3)
add hl,hl
push hl
ld bc,(ix+-6)
ld hl,(ix+9)
add hl,bc
push hl
ld bc,(ix+-3)
ld hl,(ix+6)
or a,a
sbc hl,bc
push hl
call _HorizLine_NoClip \.r
lea hl,ix+-9
ld sp,hl
ld hl,(ix+-3)