phat code In theory, there is no difference between theory and practice. But, in practice...
Main

Projects

Downloads

Articles

Links

Forum

 

View Message

Back to Messages
Rel Mon Apr 3 2006 at 8:42 am
FASM roxxors!!!!
 
 
Spent an hour trying to figure out how to ode in it and here's the tunnel:

[code]
;************************************* ****************************
; tunnel by rel
; Assemble with fasm
;       Http://Rel.Betterwebber. com
;*********************************** ******************************

diameter         equ 64
diamxscale       equ 64 * diameter
scale            equ 256
scx              equ 160
scy              equ 100

org 100h


frame     dw  0
ishort    dw  0
short_var 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:

        inc [frame]
        ;===========tunnel
        mov dx,200
        mov di, 0
      tunnel_yloop:
        mov cx,320
      tunnel_xloop:

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

        mov [short_var], scx
        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

        mov   ax, 004ch
        int   21h               ; return to dos


[/code]
 
 
 
 

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.