; The dots tunnel tables, computed by RASM at assembly time.
; Same names and memory map as tables.bas: rasm tables.asm writes
; tables-rasm.bin, identical byte for byte to TABLES.BIN from BASIC
; without its 128-byte AMSDOS header.

CX = 160
CY = 100
P = 90
R = 1
Z0 = 1
DZ = 0.15
DOTS = 16
AX = 72
AY = 50

        org #4000

; RASM's sin() and cos() take degrees: a full turn is 360, not 2*PI.
; floor(x+0.5) rounds like INT(x+0.5) in BASIC.

YLO:    repeat 256,y,0
        if y<200
          db ((y>>3)*80+(y&7)*2048)&255
        else
          db 0
        endif
        rend

YHI:    repeat 256,y,0
        if y<200
          db ((y>>3)*80+(y&7)*2048)>>8
        else
          db 0
        endif
        rend

CENTER: repeat 16,q,0
        repeat 64,phase,0
          db CX+floor(AX*q/15*sin(360*phase/64)+0.5)
          db CY+floor(AY*q/15*sin(720*phase/64+0.7*180/pi)+0.5)
        rend
        rend

SHAPE:  repeat 64,d,0
s = P*R/(Z0+d*DZ)
        repeat 4,rot,0
        repeat DOTS,k,0
angle = 360*(4*k+rot)/64
          db floor(s*cos(angle)+0.5)&255
          db floor(s*sin(angle)+0.5)&255
        rend
        rend
        rend

        save "tables-rasm.bin",YLO,$-YLO
