c64-livecoding/wip-hugo/routines/circle/circle.s
2025-06-26 22:38:11 +02:00

50 lines
975 B
ArmAsm

;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.proc circle
.include "circle.inc"
;; We use the algorithm jerkos method
;; https://schwarzers.com/algorithms/
;; 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:
jsr pixel_draw
INC Y_pos ; y++
;;t1 += y
CLC
LDA t1
ADC Y_pos
STA t1
;; t2 = t1 - x
SEC
LDA t2
SBC X_pos
STA t2
;; if t2 < 0 then skip to endif
CMP #$00
BMI endif
if:
DEC X_pos ; x--
STA t1 ; t1 = t2
endif:
;; repeat if X > Y
LDA X_pos
CMP Y_pos
JMP while_x_bigger_then_y
;BNE while_x_bigger_then_y
.endproc