ANNOUNCE: ATALAN - new programming language for 6502

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Post by BigEd »

Interesting - pdf link here. I think their idea is to use quadratic interpolation and therefore have smaller lookup tables than needed for linear interpolation (with a second idea of minimising the length of the coefficients and a third idea of using squaring hardware to speed up the interpolation)

Moving slightly back towards integer arithmetic and plotting of a sine curve, there's an old trick due to Minsky which is a close approximation, and uses only add and shift. In fact, maybe not even a shift because a shift by 8 is just picking off a different byte:

Image

At first this was drawing spirals, but it turned out I was using floating point division: it draws near-circles if integer division is used.

Code: Select all

   10 A%=256                            
   20 C%=32768                          
   30 S%=A%                             
   40 FOR I%=0 TO 8000                  
   50   C%=C%-S% DIV A%                 
   60   S%=S%+C% DIV A%                 
   70   PLOT69,S%/128+600,C%/128+600    
   80   PLOT69,I%,S%/128+300            
   90   PLOT69,I%,C%/128+300            
  100   NEXT                            
(Lots of other interesting tricks in the Hakmem memo.)
Last edited by BigEd on Wed Mar 27, 2019 9:20 pm, edited 2 times in total.
ElEctric_EyE
Posts: 3260
Joined: 02 Mar 2009
Location: OH, USA

Post by ElEctric_EyE »

Fascinating. That is awesome info!
User avatar
Arlet
Posts: 2353
Joined: 16 Nov 2010
Location: Gouda, The Netherlands
Contact:

Post by Arlet »

Marvin's trick to draw circles was used as an example program in the Acorn Atom user manual: "Atomic theory and practice". An excellent book full little bits of useful code.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Post by BigEd »

Nice! Code on Page 86 - picture on next page.

(I wish I'd been able to post those graphics as an ATALAN example... an exercise for the reader?)
Post Reply