c64-livecoding/wip-hugo/routines/circle/circle.s

53 lines
953 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_rel = radius (share the same address)
;;Y_rel =0
LDA #$00
STA Y_rel
;; t1 = radius >> 4
LDA radius
LSR
LSR
LSR
LSR
STA t1
while_x_bigger_then_y:
JSR pixel_draw
INC Y_pos ; y++
INC Y_rel
;;t1 += y
CLC
LDA t1
ADC Y_rel
STA t1
;; t2 = t1 - x
SEC
LDA t1
SBC X_rel
STA t2
;; if t2 < 0 then skip to endif
CMP #$00
BMI endif
if:
DEC X_pos ; x--
DEC X_rel
LDA t2
STA t1 ; t1 = t2
endif:
;; repeat if X > Y
LDA X_rel
CMP Y_rel
BCS while_x_bigger_then_y
RTS
.endproc