Nick Glencross wrote: > Here's a nice little Jako example which draws a circle (oval, strickly > speaking!) using VT100 control codes, which means that it should work > in xterms, gnome-terminals, consoles and konsoles.
I've been on holiday, so have only just got around to posting my reworked version of this using pure assembler. Enjoy, Nick # # circle.pasm Nick Glencross <[EMAIL PROTECTED]> # # # Draw a circle on a VT100-compatible screen, using only # simple integer arithmetic operations # # The algorithm is based on: # # cos(theta+delta) = # cos(theta) - # [alpha*cos(theta) + beta*sin(theta)] # # and # # sin(theta+delta) = # sin(theta) - # [alpha*sin(theta) - beta*cos(theta)] # # where # # alpha = 2*sin^2(delta/2) and beta = sin(delta) # # (See Numerical Recipes in C) # # In this program the value of delta is chosen to be 1/(1<<n) such # that it is small enough that # # alpha is approx. 0 # and # beta is approx. delta # # # Screen Width and Height set I10, 80 set I11, 24 # Calculate scaling and offsetting constants shr I6, I10, 1 shr I7, I11 , 1 div I8, 140000, I10 div I9, 140000, I11 # Clear the screen print "\033[H\033[2J" # Initial values set I0, 65536 set I1, 0 # Loop counter set I2, 0 PIXEL_LOOP: # Scale, offset and then plot Pixel div I3, I1, I8 div I4, I0, I9 add I3, I3, I6 add I4, I4, I7 print "\033[" print I4 print ";" print I3 print "H*" # Compute next position shr I3, I1, 6 shr I4, I0, 6 sub I0, I0, I3 add I1, I1, I4 # Loop again inc I2 lt I2, 404, PIXEL_LOOP # Place cursor back at bottom of screen print "\033[" print I11 print ";0H" # Done! end