unit fastmath

Fast Math

author: Cruzer/Camelot, Tebe/Madteam


https://codebase64.org/doku.php?id=base:6502_6510_maths https://dwheeler.com/6502/oneelkruns/asm1step.html

Constants:

name:value:description:
atan_tab: array [0..255] of byte(atan(2^(x/32))*128/pi
log2_tab : array [0..255] of byte(log2(x)*32
octant_adjust : array [0..7] of byte(

Interface:

name:description:
atan2

function atan2(x1,x2,y1,y2: byte): byte; assembler;


Calculate the angle, in a 256-degree circle, between two points. The trick is to use logarithmic division to get the y/x ratio and integrate the power function into the atan table. Some branching is avoided by using a table to adjust for the octants. In otherwords nothing new or particularily clever but nevertheless quite useful.
by Johan Forslöf (doynax) https://codebase64.org/doku.php?id=base:8bit_atan2_8-bit_angle
    parameters:
  • x1 - byte
  • x2 - byte
  • y1 - byte
  • y2 - byte
sqrt16

function sqrt16(a: word): byte; assembler;


Returns the 8-bit square root of the 16-bit number. https://codebase64.org/doku.php?id=base:16bit_and_24bit_sqrt
    parameters:
  • A - Word
FillSin

procedure FillSin(p: pointer; eor,add: byte); assembler;


https://codebase64.org/doku.php?id=base:generating_approximate_sines_in_assembly
    FillSinLow

    procedure FillSinLow(p: pointer);


    Sine value table ($7f, $08)
      parameters:
    • P - pointer to array (low address = 0)
    FillSinHigh

    procedure FillSinHigh(p: pointer);


    Sine value table ($ff, $10)
      parameters:
    • P - pointer to array (low address = 0)