very cool but not working circle.
This commit is contained in:
parent
9e643e6c6d
commit
8b955a5007
4 changed files with 80 additions and 1 deletions
8
wip-hugo/routines/circle/circle.inc
Normal file
8
wip-hugo/routines/circle/circle.inc
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
.include "../pixel/pixel.inc"
|
||||||
|
;; public args
|
||||||
|
radius = ARGVEC + 3
|
||||||
|
;; private args
|
||||||
|
t1 = $E0
|
||||||
|
t2 = $E1
|
||||||
|
temp = $E2
|
60
wip-hugo/routines/circle/circle.s
Normal file
60
wip-hugo/routines/circle/circle.s
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
|
.proc circle
|
||||||
|
.include "circle.inc"
|
||||||
|
;; We use the algorithm jerkos method
|
||||||
|
;; https://schwarzers.com/algorithms/
|
||||||
|
LDY Y_pos
|
||||||
|
LDX X_pos
|
||||||
|
;; X_pos = X_pos + r (hack, should fix later ( xpos == ypos is not always true))
|
||||||
|
CLC
|
||||||
|
LDA X_pos
|
||||||
|
ADC radius
|
||||||
|
STA X_pos
|
||||||
|
|
||||||
|
|
||||||
|
;; t1 = radius >> 4
|
||||||
|
LDA radius
|
||||||
|
LSR
|
||||||
|
LSR
|
||||||
|
LSR
|
||||||
|
LSR
|
||||||
|
STA t1
|
||||||
|
while_x_bigger_then_y:
|
||||||
|
|
||||||
|
STY Y_pos
|
||||||
|
STX X_pos
|
||||||
|
STA temp
|
||||||
|
jsr pixel_draw
|
||||||
|
LDY Y_pos
|
||||||
|
LDX X_pos
|
||||||
|
LDA temp
|
||||||
|
|
||||||
|
|
||||||
|
INY ; y++
|
||||||
|
|
||||||
|
;;t1 += y
|
||||||
|
CLC
|
||||||
|
LDA t1
|
||||||
|
STY temp
|
||||||
|
ADC temp
|
||||||
|
STA t1
|
||||||
|
;; t2 = t1 -x
|
||||||
|
SEC
|
||||||
|
STX temp
|
||||||
|
SBC temp
|
||||||
|
|
||||||
|
;; if t2 < 0 then skip to endif
|
||||||
|
CMP #$00
|
||||||
|
BMI endif
|
||||||
|
if:
|
||||||
|
DEX; x--
|
||||||
|
STA t1; t1 = t2
|
||||||
|
endif:
|
||||||
|
;; repeat if X > Y
|
||||||
|
STX temp
|
||||||
|
TYA
|
||||||
|
CMP temp
|
||||||
|
JMP while_x_bigger_then_y
|
||||||
|
BEQ while_x_bigger_then_y
|
||||||
|
.endproc
|
9
wip-hugo/routines/circle/circle_test.s
Normal file
9
wip-hugo/routines/circle/circle_test.s
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.scope circle_test
|
||||||
|
.include "circle.inc"
|
||||||
|
LDA #$50
|
||||||
|
STA X_pos
|
||||||
|
STA Y_pos
|
||||||
|
LDA #$08
|
||||||
|
STA radius
|
||||||
|
JSR circle
|
||||||
|
.endscope
|
|
@ -9,7 +9,8 @@
|
||||||
;.include "dubbel_buffer/raster_irqs.s"
|
;.include "dubbel_buffer/raster_irqs.s"
|
||||||
|
|
||||||
;.include "routines/arithmatic/mult_test.s"
|
;.include "routines/arithmatic/mult_test.s"
|
||||||
.include "routines/arithmatic/div_test.s"
|
;.include "routines/arithmatic/div_test.s"
|
||||||
|
.include "routines/circle/circle_test.s"
|
||||||
;.include "routines/line/line_test.s"
|
;.include "routines/line/line_test.s"
|
||||||
;.include "routines/text/char_draw_test.s"
|
;.include "routines/text/char_draw_test.s"
|
||||||
;.include "routines/pixel/pixel_test.s"
|
;.include "routines/pixel/pixel_test.s"
|
||||||
|
@ -20,6 +21,7 @@ exit:
|
||||||
JMP exit
|
JMP exit
|
||||||
.include "../wip-duuqnd/public.inc"
|
.include "../wip-duuqnd/public.inc"
|
||||||
.include "routines/line/line.s"
|
.include "routines/line/line.s"
|
||||||
|
.include "routines/circle/circle.s"
|
||||||
.include "routines/triangle/triangle.s"
|
.include "routines/triangle/triangle.s"
|
||||||
.include "routines/pixel/pixel_draw.s"
|
.include "routines/pixel/pixel_draw.s"
|
||||||
.include "routines/text/char_draw.s"
|
.include "routines/text/char_draw.s"
|
||||||
|
|
Loading…
Add table
Reference in a new issue