phat code I hate when they fix a bug that I use.
Main

Projects

Downloads

Articles

Links

Forum

 

View Message

Back to Messages
rel Mon Apr 3 2006 at 6:50 pm
Just added a center displacement...
 
 
;*************************************** **************************
; tunnel by rel
; Assemble with fasm
;       Http://Rel.Betterwebber. com
;*********************************** ******************************

diameter  equ 64
diamxscale  equ 64 * diameter
scale  equ 256

org 100h


frame   dw  0
ishort   dw  0
short_var dw  0
scx   dw  0
scy   dw  0



;************************************* ****************************
;************************************* ****************************
;************************************* ****************************

   push word 0a000h
   pop es

   mov ax, 0013h ; mode 13h
   int 10h ; we are now in 320x200x256

   fninit

;====set palette
   mov dx, 03c8h ;palette write register
   out dx, al ;send value
   inc dx ;0x3c9(write RGB values)
   mov cx, 256 ;whole 256 colors
   fldpi ;st0 = pi
   mov [ishort], 180 ;st0 = 180, st1 = pi
   fild [ishort]
   palloop:
mov bx, 256
sub bx, cx
shl bx,1

mov [ishort], bx
fild [ishort] ;st0 = deg, st1 = 180, st2 = pi
fmul st0, st2
fdiv st0, st1
fsin ;st0 = sin(rad)
mov [ishort], 64
fimul [ishort]
fistp [ishort]

mov ax, [ishort]
out  dx, al ;red
shl al,1 ;blue

out  dx, al
shr al, 2
out  dx, al ;than green

   loop palloop ;go back if not 0
fstp st0
fstp st0
MainLoop:
mov [scx],160
mov [scy],100

inc [frame]

;displacement
fild [frame]
mov [ishort], 50
fidiv [ishort]
fsin
mov [ishort], 120
fimul [ishort]
fistp [ishort]
mov ax, [ishort]
add [scx], ax
fild [frame]
mov [ishort], 60
fidiv [ishort]
fsin
mov [ishort], 80
fimul [ishort]
fistp [ishort]
mov ax, [ishort]
add [scy], ax

;===========tunnel
mov dx,200
mov di, 0
      tunnel_yloop:
mov cx,320
      tunnel_xloop:

;atan2
fldpi ;st0 = pi
mov ax, [scy]
mov [short_var], ax
sub [short_var], dx
fild [short_var] ;st0 = dy, st1 = pi

mov ax, [scx]
mov [short_var], ax
sub [short_var], cx
fild [short_var] ;st0 = dx, st1 = dy, st2 = pi

fpatan ;st0 = atan(dy/dx) = atan(st1/st0)

mov [short_var], scale
fimul [short_var] ;atan(st0))*256/pi
fdiv st0, st1
fistp [short_var] ;short_var = scaledpi

mov ax, [scx]
sub ax, cx ;cmx
mov [ishort], ax
fild [ishort] ;st0 = cmx
fmul st0, st0 ;cmx * cmx
mov ax, [scy]
sub ax, dx
mov [ishort], ax
fild [ishort] ;st0 = cmy st1 = cmx*cmx
fmul st0, st0 ;cmy * cmy
fadd st0, st1 ;st0 cmx^2 + cmy^2
fsqrt ;sqrt st0
mov [ishort], diamxscale ;st0 = diamxscale st1 = sqrt(dist)
fild [ishort]
fdiv st0, st1
fistp [ishort]
fstp st0
fstp st0
fstp st0
mov ax, [ishort]
mov bx, [short_var]
add ax, [frame]
add bx, [frame]
xor ax, bx
mov [es:di], al

inc di
loop tunnel_xloop
dec dx
jnz tunnel_yloop



mov   ah, 01h ; check for keypress
int   16h ; is a key waiting in the buffer?
Jz MainLoop

;textmode
mov ax, 0003h
int 10h

mov   ax, 004ch
int   21h
 
 
 
 

Reply to this Message

Name
Subject
Message

No HTML is allowed, except for <code> <b> <i> <u> in the message only.
All URLs and email addresses will automatically be converted to hyperlinks.