Skip to content

Instantly share code, notes, and snippets.

@Loevland
Created January 21, 2024 14:37
Show Gist options
  • Save Loevland/efc2d241bce6d5484298a9b46106f54c to your computer and use it in GitHub Desktop.
Save Loevland/efc2d241bce6d5484298a9b46106f54c to your computer and use it in GitHub Desktop.
% STD RAS:0
; Read input radius
;!ICO ? NIP <- #HLT
; Read a word from the input and write it to
; the printer
;radius <- IDA
radius <- #25
RAC <- #14
circle:
MUX <- radius
MUY <- radius
radius <- UPL
; Start at 0,0
RAP <- #0
;RAX <- #100
;RAY <- #100
; Distance check
loop:
point_x <- RAX
point_y <- RAY
; Quick check
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
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 <- color_in
NIP <- #check
outside:
RAP <- INC <- RAP
NIP <- #check
check:
RAP ? NIP <- #loop
RAX <- center
RAY <- center
RAW <- color_in
NIP <- #stop
stop:
counter <- DEC <- counter
counter ? NIP <- #reset
RAD <- #0
NIP <- #HLT
reset:
ALX <- counter
ALY <- #13
EQU ? NIP <- #new13
ALX <- counter
ALY <- #12
EQU ? NIP <- #new12
ALX <- counter
ALY <- #11
EQU ? NIP <- #new11
ALX <- counter
ALY <- #10
EQU ? NIP <- #new10
ALX <- counter
ALY <- #9
EQU ? NIP <- #new9
ALX <- counter
ALY <- #8
EQU ? NIP <- #new8
ALX <- counter
ALY <- #7
EQU ? NIP <- #new7
ALX <- counter
ALY <- #6
EQU ? NIP <- #new6
ALX <- counter
ALY <- #5
EQU ? NIP <- #new5
ALX <- counter
ALY <- #4
EQU ? NIP <- #new4
ALX <- counter
ALY <- #3
EQU ? NIP <- #new3
ALX <- counter
ALY <- #2
EQU ? NIP <- #new2
ALX <- counter
ALY <- #1
EQU ? NIP <- #new1
new4:
color_in <- DEC <- color_in
center <- #196
radius <- #40
NIP <- #circle
new3:
color_in <- DEC <- color_in
center <- #163
radius <- #25
NIP <- #circle
new2:
color_in <- DEC <- color_in
center <- #64
radius <- #10
NIP <- #circle
new1:
color_in <- DEC <- color_in
center <- #6
radius <- #5
NIP <- #circle
new5:
color_in <- DEC <- color_in
center <- #48
radius <- #24
NIP <- #circle
new6:
color_in <- DEC <- color_in
center <- #79
radius <- #8
NIP <- #circle
new7:
color_in <- DEC <- color_in
center <- #98
radius <- #10
NIP <- #circle
new8:
color_in <- DEC <- color_in
center <- #115
radius <- #30
NIP <- #circle
new9:
color_in <- DEC <- color_in
center <- #146
radius <- #35
NIP <- #circle
new10:
color_in <- DEC <- color_in
center <- #170
radius <- #23
NIP <- #circle
new11:
color_in <- DEC <- color_in
center <- #190
radius <- #27
NIP <- #circle
new12:
color_in <- DEC <- color_in
center <- #201
radius <- #28
NIP <- #circle
new13:
color_in <- DEC <- color_in
center <- #210
radius <- #4
NIP <- #circle
new14:
color_in <- DEC <- color_in
center <- #218
radius <- #22
NIP <- #circle
color_in: 14
color_out: 0
counter: 13
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