;Should be run with around 50k cycles in DosBox
org 100h

push 0xa000
pop es
mov al,13h
int 10h

palloop:
mov ax,cx
mov dx,0x3c8
out dx,al    ; select palette color
inc dx
xor ax,dx
out dx,al    ; write red value (0..63)
out dx,al    ; write green value (0..63)
out dx,al    ; write blue value (0..63)
loop palloop

mainloop:
mov ax,0xCCCD
mul di

push dx
push bx
;Ring begin
mov al,dh
sub al,100
imul al
mov bx,ax

mov al,dl
sub al,128
imul al
add ax,bx
mov bx,20
add bx,si
and bx,127
imul bx,bx

inner_radius:
add bx,400
cmp ax,bx
jbe fill

end_ring:
;Ring end

cmp dl, 127
jae right
mov al,dl
sub al,dh
add al,bl
cmp dh,100
jae fill
mov al,dl
add al,dh
add al,bl
add al,bl
jmp fill

right:
mov al,dl
add al,dh
add al,bl
cmp dh,100
jae fill
mov ah,dl
sub ah,dh
add ah,bl
mov al,ah
cmp dh,100

fill:
pop bx
pop dx

add al,bl
stosb
loop mainloop
inc bl
in al,60h
dec al
jnz mainloop
ret
