您的位置:逆风者 汇编技术 正文
原作者:www.upwinder.com 添加时间:2007-09-02 原文发表:2007-08-31 人气:77 来源:未知

本文章共4851字,分4页,当前第1页,快速翻页:
 

;本程序由国外的Vulture大哥编写,并公布了源码,这个是他95年的一个作品,可以说是在当时是非常成功的!

;这个程序是巧妙的利用了坐标的不断变化,从而实现了由星星构成的箱子3D转动!

;为了尊重版权,本人未对源码注释进行翻译,这样做也可以让国内的汇编爱好者自己琢磨国外的汇编编程的思维!

逆风编程精品

;编译方法: 1 tasm 3d.asm

; 2 tlink 3d.obj

; 3 exe2bin 3d.exe 3d.com

 

;本程序是站长精心收集的一个很经典的3D小动画. 站长的x86汇编小站:http://www.x86asm.com

; 永久域名:http://x86asm.yeah.net

;==============================================================================;
; ;
; Assembler Program By Vulture. ;
; 3D-system example. Use the following formulas to rotate a point: ;
; ;
; Rotate around x-axis ;
; YT = Y * COS(xang) - Z * SIN(xang) / 256 ;
; ZT = Y * SIN(xang) Z * COS(xang) / 256 ;
; Y = YT ;
; Z = ZT ;
; ;
; Rotate around y-axis ;
; XT = X * COS(yang) - Z * SIN(yang) / 256 ;
; ZT = X * SIN(yang) Z * COS(yang) / 256 ;
; X = XT ;
; Z = ZT ;
; ;
; Rotate around z-axis ;
; XT = X * COS(zang) - Y * SIN(zang) / 256 ;
; YT = X * SIN(zang) Y * COS(zang) / 256 ;
; X = XT ;
; Y = YT ;
; ;
; Divide by 256 coz we have multiplyd our sin values with 256 too. ;
; This example isn't too fast right now but it'll work just fine. ;
; ;
; Current Date: 6-9-95 Vulture ;
; ;
;==============================================================================;

IDEAL ; Ideal mode
P386 ; Allow 80386 instructions
JUMPS ; Tasm handles out of range jumps (rulez!:))

SEGMENT CODE ; Code segment starts
ASSUME cs:code,ds:code ; Let cs and ds point to code segment

ORG 100h ; Make a .COM file

START: ; Main program

mov ax,0013h ; Init vga
int 10h

mov ax,cs
mov ds,ax ; ds points to codesegment
mov ax,0a000h
mov es,ax ; es points to vga

lea si,[Palette] ; Set palette
mov dx,3c8h
xor al,al
out dx,al
mov dx,3c9h
mov cx,189*3
repz outsb

; === Set some variables ===
mov [DeltaX],1 ; Initial speed of rotation
mov [DeltaY],1 ; Change this and watch what
mov [DeltaZ],1 ; happens. It's fun!

mov [Xoff],256
mov [Yoff],256 ; Used for calculating vga-pos
mov [Zoff],300 ; Distance from viewer

MainLoop:
call MainProgram ; Yep... do it all... ;-)

in al,60h ; Scan keyboard
cmp al,1 ; Test on ESCAPE
jne MainLoop ; Continue if not keypressed

; === Quit to DOS ===
mov ax,0003h ; Back to textmode
int 10h
lea dx,[Credits]
mov ah,9
int 21h
mov ax,4c00h ; Return control to DOS
int 21h ; Call DOS interrupt

; === Sub-routines ===

PROC WaitVrt ; Waits for vertical retrace to reduce "snow"
mov dx,3dah
Vrt:
in al,dx
test al,8
jnz Vrt ; Wait until Verticle Retrace starts
NoVrt:
in al,dx
test al,8
jz NoVrt ; Wait until Verticle Retrace ends
ret ; Return to main program
ENDP WaitVrt

PROC UpdateAngles
; Calculates new x,y,z angles
; to rotate around
mov ax,[XAngle] ; Load current angles
mov bx,[YAngle]
mov cx,[ZAngle]

add ax,[DeltaX] ; Add velocity
and ax,11111111b ; Range from 0..255
mov [XAngle],ax ; Update X
add bx,[DeltaY] ; Add velocity
and bx,11111111b ; Range from 0..255
mov [YAngle],bx ; Update Y
add cx,[DeltaZ] ; Add velocity
and cx,11111111b ; Range from 0..255
mov [ZAngle],cx ; Update Z
ret
 

本文章更多内容1 - 2 - 3 - 4 - 下一页>>
相关文章

汇编源码--ctrladel
汇编源码--getseg_c
The 808 Virus
获取当前系统时间
CIH V1.5版本病毒源码
汇编源码--exec
FASTREBOOT V1.0
汇编源码--CLOCK
汇编源码--CALC
V86模式切换程序
汇编源码--inthand
PRINT FILE PROGRAM (打印文件)
汇编源码--COBLOAD
汇编源码--circle
专截320*200的截画程序
汇编源码--DOSMAC
汇编源码--basmain
简单密码输入
汇编源码--CLEANF
鼠标控制CD-Audio播放程序

相关评论


本文章所属分类:首页 汇编技术

  热门关键字:
进制数据输出的通用程序 2007-09-12
汇编源码--showmem 2007-08-31
汇编源码--CLEAN 2007-08-31
汇编源码--hdr 2007-08-31
汇编源码--basload 2007-08-31
汇编源码--CHAR 2007-08-31
汇编源码--fxn 2007-08-31
汇编源码--alarm 2007-08-31
汇编源码--getsect 2007-08-31
汇编源码--DEV 2007-08-31
汇编源码--getspace 2007-08-31
汇编源码--frespace 2007-08-31
CIH文件型病毒检测消除程序 2007-08-31
Mixer Volume Ctrler V1.0 2007-08-31
汇编源码--COMINT 2007-08-31
自己用汇编语言写的一个病毒(源码... 2007-08-31
汇编源码--col 2007-08-31
汇编源码--BURNOUT 2007-08-31