programmers resources
  http://www.intel-assembler.it/  (c)2017 intel-assembler.it   info@intel-assembler.it
 
Search :  
Lingua Italiana    English Language   
Index
 
just an empty assembly space
just an arrow Intel Platform
just an arrow Article & Guides
just an arrow Download Software


23/01/2009 Featured Article: How to remove Buzus Virus (permalink)




:::3058442:::
Bottone Scambio Directory Pubblicitaonline.it
Home Page | Articles & Guides | Download | Intel Platform | Contacts

Google
 


Bookmark and Share
Download 
Tell a friend



2D/3D Rotation asm demos

Source code for 2D and 3D rotation

(by ash [nlb/bd])

These two small asm sources contain the code for two dimensional and threedimensional rotation. Download contains .COM executables.
This article is online from 2704 days and has been seen 6192 times




------------------------
2DROT.ASM
3DROT.ASM
Coded by Ash [NLB/BD]
------------------------
2D/3D Rotation asm demos
------------------------

These two small asm sources contain the code for two dimensional and 
threedimensional rotation.

Download contains .COM executables.

     ____              ____
  __­___ |            |_   ­__
 ­00|    |_____  _____| ___|00­
 |BD|    |\___ \/_ __/|    |BD|
 |  |    | \    \   / |    |  |
 |  |    !_/    /   \_!    |  |
 |  !__________/\__________!  |
 |   ~~~~~~~~~~~~~~~~PiNO~~   |
 |                            |
 |      ASM-Sources for:      |
 |     3d & 2d rotation!!     |
 |                            |
 |  phun izda key to nowhere  |
 |    so let'z have phun!!    |
 |      cya all at x-95!      |
 |                            |
 !00________________________00!


---
;
; 2d Rotation, Coded by Ash [NLB/BD]
; Allmost no comments.. I'm sorry :(
;

p386
ideal

segment code
assume cs:code
org 100h

start:
                mov     ax,13h
                int     10h
                push    0a000h
                pop     es

mainloop:       call    docordz                         ; mainloop
                call    keyc
                call    vwait
                call    killthem
                jmp     mainloop

outnow:         mov     ax,3                            ; the end
                int     10h
                mov     ax,4c00h
                int     21h

docordz:        add     [angle],2
                and     [angle],255
                xor     bp,bp

                mov     si,[angle]                      ; get sin(a) & cos(a)
                movsx   ax,[sincos+si]
                mov     [sinval],ax
                add     si,64
                and     si,255
                movsx   ax,[sincos+si]
                mov     [cosval],ax

dumpnow:        mov     ax,[cordz+bp]                   ; x
                imul    [cosval]
                mov     di,ax
                mov     ax,[cordz+bp+2]                 ; y
                imul    [sinval]                        ; sin + angle
                sub     di,ax
                sar     di,7
                add     di,160
                mov     bx,di

                mov     ax,[cordz+bp]                   ; x
                imul    [sinval]
                mov     di,ax
                mov     ax,[cordz+bp+2]                 ; y
                imul    [cosval]
                add     di,ax
                sar     di,7
                add     di,100

                mov     ax,320
                imul    di
                add     ax,bx

                mov     di,ax
                mov     [deltable+bp],di
                mov     [byte es:di],15

                add     bp,4
                cmp     bp,points*4
                jne     dumpnow
                ret

killthem:       xor     bp,bp
mov cx,points
killem:         mov     di,[deltable+bp]
                mov     [byte es:di],0
                add     bp,4
                loop    killem
                ret

vwait:          mov     dx,3dah                         ; vertical retrace
                in      al,dx
                test    al,8
                jne     $-3
                in      al,dx
                test    al,8
                je      $-3
                ret

keyc:           in      al,60h                          ; last key scan
                cmp     al,1
                je      outnow
                ret


label           cordz word
                b = -50
                rept 12
                a = -55
                rept 12
                dw a,b
                a = a + 10
                endm
                b = b + 10
                endm


angle           dw 0
cosval          dw ?
sinval          dw ?

points          equ 12*12

include         "sincos.db"

deltable        dw points*4 dup (?)

ends code
end start

---


;
; 3d Rotation, coded by Ash [NLB/BD]
; Sorry that did'nt commented it too well :(
;


ideal
p386n

segment code
assume cs:code
org 100h

start:
                mov     ax,13h                  ; init vga
                int     10h
                push    0a000h
                pop     es

mainloop:       add     [xangle],1              ; increase x,y,z-angles
                and     [xangle],255
                add     [yangle],1
                and     [yangle],255
                add     [zangle],1
                and     [zangle],255

                mov     bx,[xangle]             ; get x,y,z,-sin/cos value
                movsx   bp,[sincos+bx]
                mov     [xsin],bp
                add     bx,64
                and     bx,255
                movsx   bp,[sincos+bx]
                mov     [xcos],bp
                mov     bx,[yangle]
                movsx   bp,[sincos+bx]
                mov     [ysin],bp
                add     bx,64
                and     bx,255
                movsx   bp,[sincos+bx]
                mov     [ycos],bp
                mov     bx,[zangle]
                movsx   bp,[sincos+bx]
                mov     [zsin],bp
                add     bx,64
                and     bx,255
                movsx   bp,[sincos+bx]
                mov     [zcos],bp

                xor     si,si
morepoints:     mov     ax,[coords+si+2]        ; do calculations
                imul    [xcos]
                mov     bp,ax
                mov     ax,[coords+si+4]
                imul    [xsin]
                sub     bp,ax
                mov     [yt],bp
                mov     ax,[coords+si+2]
                imul    [xsin]
                mov     bp,ax
                mov     ax,[coords+si+4]
                imul    [xcos]
                add     bp,ax
                mov     [zt],bp
                mov     ax,[yt]
                sar     ax,7
                mov     [y],ax
                mov     ax,[zt]
                sar     ax,7
                mov     [z],ax

                mov     ax,[coords+si]
                imul    [ycos]
                mov     bp,ax
                mov     ax,[z]
                imul    [ysin]
                sub     bp,ax
                mov     [xt],bp
                mov     ax,[coords+si]
                imul    [ysin]
                mov     bp,ax
                mov     ax,[z]
                imul    [ycos]
                add     bp,ax
                mov     [zt],bp
                mov     ax,[xt]
                sar     ax,7
                mov     [x],ax
                mov     ax,[zt]
                sar     ax,7
                mov     [z],ax

                mov     ax,[x]
                imul    [zcos]
                mov     bp,ax
                mov     ax,[y]
                imul    [zsin]
                sub     bp,ax
                mov     [xt],bp
                mov     ax,[x]
                imul    [zsin]
                mov     bp,ax
                mov     ax,[y]
                imul    [zcos]
                add     bp,ax
                mov     [yt],bp
                mov     ax,[xt]
                sar     ax,7
                mov     [x],ax
                mov     ax,[yt]
                sar     ax,7
                mov     [y],ax

                mov     ax,200
                imul    [x]
                mov     bp,[z]
                add     bp,200
                idiv    bp
                add     ax,160
                mov     cx,ax

                mov     ax,200
                imul    [y]
                mov     bp,[z]
                add     bp,200
                idiv    bp
                add     ax,100

mov di,ax
shl di,8
shl ax,6
add di,ax
add di,cx

                mov     [erase+si],di
                mov     [byte es:di],15

                add     si,6
                cmp     si,points
                jne     morepoints

                mov     dx,3dah
                in      al,dx
                test    al,8
                jne     $-3
                in      al,dx
                test    al,8
                je      $-3

                xor     si,si                   ; erase the points again
killem:         mov     di,[erase+si]
                mov     [byte es:di],0
                add     si,6
                cmp     si,points
                jne     killem

                in      al,60h
                cmp     al,1
                jne     mainloop

                mov     ax,3
                int     10h
                mov     ax,4c00h
                int     21h


  points        equ 200*3

  xangle        dw 0
  yangle        dw 0
  zangle        dw 0

  xsin          dw ?
  xcos          dw ?
  ysin          dw ?
  ycos          dw ?
  zsin          dw ?
  zcos          dw ?

  xt            dw ?
  yt            dw ?
  zt            dw ?

  x             dw ?
  y             dw ?
  z             dw ?

  include       "sincos.db"
  include "coords.db"

  erase         dw points dup (?)

ends code
end start




Top
Download 
Tell a friend
Bookmark and Share



Similar Articles

3D Rotating Cube Assembler source
An improved asm code for 3d graphics
(by Arno W. Brouwer)

3D Texture Mapping theory and asm code
a mid-length text about texture logic and coding
(by Sean Barrett)

4K 3D Asm Demo
4096 byte 3D assembler graphical demo
(by Jari Kytöjoki)

Basic Introduction to 3D Programming
A short doc about howto plot in 3D
(by Synergist)

Math.inc: General 3D math functions
A library with many math functions for 3d graphics
(by John McCarthy)

Perspective Transforms
A two page document with the perspective formulas
(by Andre Yew)

REFRACTION 4k intro
Assembler graphic demo, 3D chessboard
(by G.O.D.)

Star Field
3D Assembly star field
(by VLA)

Three Dimensional Rotations For Computer Graphics
A short document on 3D rotation
(by VLA)

Three Dimensional Shading In Computer Graphics
A brief intro on 3d shading theory
(by VLA)

VGA Trainer Program
A course for graphic programming in Pascal/ASM
(by Grant Smith Denthor of ASPHYXIA)

VGOPHONG Phong lighting and specular highlights
Theory, practice of phong lightnin and shade model
(by TimJ/Vertigo)

X-Sharp 3-D animation package v22
3D ball demo with zoom, share and move
(by Michael Abrash)

Zed3D programming guide
A compact reference for 3d computer graphics
(by Sébastien Loisel)

 Tags: 3d


webmaster jes
writers rguru, tech-g, aiguru, drAx

site optimized for IE/Firefox/Chrome with 1024x768 resolution

Valid HTML 4.01 Transitional


ALL TRADEMARKS ® ARE PROPERTY OF LEGITTIMATE OWNERS.
© ALL RIGHTS RESERVED.

hosting&web - www.accademia3.it

grossocactus
find rguru on
http://www.twitter.com/sicurezza3/
... send an email ...
Your name

Destination email

Message

captcha! Code