Created
January 21, 2024 14:29
-
-
Save Loevland/c844104b16a2c632bbe5694a02e72591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% STD RAS:0 | |
; Read input radius | |
!ICO ? NIP <- #HLT | |
; Read a word from the input and write it to | |
; the printer | |
radius <- IDA | |
MUX <- radius | |
MUY <- radius | |
radius <- UPL | |
; Start at 0,0 | |
RAP <- #0 | |
; Distance check | |
loop: | |
point_x <- RAX | |
point_y <- RAY | |
; Quick check if we are at the border of the image, | |
; as these pixels are always outside the circle | |
checkx: | |
ALX <- point_x | |
ALY <- #255 | |
EQU ? NIP <- #outside | |
ALX <- point_x | |
ALY <- #0 | |
EQU ? NIP <- #outside | |
NIP <- #checky | |
checky: | |
ALX <- point_y | |
ALY <- #255 | |
EQU ? NIP <- #outside | |
ALX <- point_y | |
ALY <- #0 | |
EQU ? NIP <- #outside | |
NIP <- #cont | |
; Had some issues with different calculations results when | |
; pixel locations were < center and > center, so divided this in two parts | |
; so that I didn't have to debug the issue | |
cont: | |
ALX <- point_x | |
ALY <- center | |
UGT ? NIP <- #sub_x_large | |
NIP <- #sub_x_small | |
sub_x_small: ; x <= 128 | |
ALX <- center | |
ALY <- point_x | |
dist_x <- DIF ; 128 - x | |
NIP <- #sub_x | |
sub_x_large: ; x > 128 | |
ALX <- point_x | |
ALY <- center | |
dist_x <- DIF ; x - 128 | |
NIP <- #sub_x | |
sub_x: ; sub x is done | |
FPX <- FIF <- dist_x | |
FPY <- FIF <- #2 | |
dist_x <- FFI <- FEX | |
ALX <- point_y | |
ALY <- center | |
UGT ? NIP <- #sub_y_large | |
NIP <- #sub_y_small | |
sub_y_small: ; y <= 128 | |
ALX <- center | |
ALY <- point_y | |
dist_y <- DIF ; 128 - y | |
NIP <- #sub_y | |
sub_y_large: ; y > 128 | |
ALX <- point_y | |
ALY <- center | |
dist_y <- DIF | |
NIP <- #sub_y | |
sub_y: ; sub y is done | |
FPX <- FIF <- dist_y | |
FPY <- FIF <- #2 | |
dist_y <- FFI <- FEX | |
NIP <- #square | |
square: | |
ALX <- dist_x | |
ALY <- dist_y | |
dist <- SUM | |
ALX <- dist | |
ALY <- #0 | |
EQU ? NIP <- #outside | |
ALX <- dist | |
ALY <- radius | |
ULT ? NIP <- #inside | |
NIP <- #outside | |
inside: | |
RAI <- #12 | |
NIP <- #check | |
outside: | |
RAI <- #0 | |
NIP <- #check | |
check: | |
RAP ? NIP <- #loop | |
RAX <- center | |
RAY <- center | |
RAW <- #12 | |
RAD <- #0 | |
NIP <- #HLT | |
center: 128 | |
dist: 0 | |
dist_x: 0 | |
dist_y: 0 | |
radius: 0 | |
point_x: 0 | |
point_y: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment