;本程序由国外的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
ENDP UpdateAngles
PROC GetSinCos
; Needed : bx=angle (0..255)
; Returns: ax=Sin bx=Cos
push bx ; Save angle (use as pointer)
shl bx,1 ; Grab a word so bx=bx*2
mov ax,[SinCos + bx] ; Get sine
pop bx ; Restore pointer into bx
push ax ; Save sine on stack
add bx,64 ; Add 64 to get cosine
and bx,11111111b ; Range from 0..255
shl bx,1 ; *2 coz it's a word
mov ax,[SinCos + bx] ; Get cosine
mov bx,ax ; Save it bx=Cos
pop ax ; Restore ax=Sin
ret
ENDP GetSinCos
PROC SetRotation
; Set sine & cosine of x,y,z
mov bx,[XAngle] ; Grab angle
call GetSinCos ; Get the sine&cosine
mov [Xsin],ax ; Save sin
mov [Xcos],bx ; Save cos
mov bx,[Yangle]
call GetSinCos
mov [Ysin],ax
mov [Ycos],bx
mov bx,[Zangle]
call GetSinCos
mov [Zsin],ax
mov [Zcos],bx
ret
ENDP SetRotation
PROC RotatePoint ; Rotates the point around x,y,z
; Gets original x,y,z values
; This can be done elsewhere
movsx ax,[Cube+si] ; si = X (movsx coz of byte)
mov [X],ax
movsx ax,[Cube+si+1] ; si+1 = Y
mov [Y],ax
movsx ax,[Cube+si+2] ; si+2 = Z
mov [Z],ax
; Rotate around x-axis
; YT = Y * COS(xang) - Z * SIN(xang) / 256
; ZT = Y * SIN(xang) + Z * COS(xang) / 256
; Y = YT
; Z = ZT
mov ax,[Y]
mov bx,[XCos]
imul bx ; ax = Y * Cos(xang)
mov bp,ax
mov ax,[Z]
mov bx,[XSin]
imul bx ; ax = Z * Sin(xang)
sub bp,ax ; bp = Y * Cos(xang) - Z * Sin(xang)
sar bp,8 ; bp = Y * Cos(xang) - Z * Sin(xang) / 256
mov [Yt],bp
mov ax,[Y]
mov bx,[XSin]
imul bx ; ax = Y * Sin(xang)
mov bp,ax
mov ax,[Z]
mov bx,[XCos]
imul bx ; ax = Z * Cos(xang)
add bp,ax ; bp = Y * SIN(xang) + Z
没有合适的资源?快使用搜索试试~ 我知道了~
dos下汇编语言小程序,大杂烩2
共390个文件
bmp:100个
exe:96个
obj:88个
需积分: 1 0 下载量 160 浏览量
2023-08-16
16:28:58
上传
评论
收藏 6.81MB ZIP 举报
温馨提示
dos下汇编语言小程序,大杂烩,请仔细看看,说不定会发现惊喜。
资源推荐
资源详情
资源评论
收起资源包目录
dos下汇编语言小程序,大杂烩2 (390个子文件)
wav.asm 88KB
finger.asm 82KB
WIN6.ASM 63KB
LIUNUX.ASM 33KB
LIUNUX.ASM 33KB
WIN9.ASM 17KB
MOUSE4.ASM 17KB
CLOCK6.ASM 16KB
SHOWBMP.ASM 15KB
CLOCK0.ASM 14KB
MOUSE3.ASM 14KB
KEYDRV0.ASM 12KB
usb.asm 12KB
clock5.asm 11KB
HDINFO.ASM 11KB
HDINFO1.ASM 11KB
AC97.ASM 11KB
snake.asm 10KB
Page.asm 9KB
NET.ASM 8KB
CLOCK7.ASM 8KB
EXE1.ASM 8KB
CLOCK7.ASM 8KB
AC971.ASM 8KB
HD0.ASM 7KB
VIDEO.ASM 7KB
CLOCK2.ASM 7KB
VIDEO2.ASM 7KB
cd.asm 7KB
HD.ASM 6KB
CLOCK1.ASM 6KB
KEYDRV.ASM 6KB
readfile.asm 6KB
sd0.asm 6KB
COP.ASM 5KB
keepvideo.asm 5KB
AC00.ASM 5KB
cdrom.asm 5KB
HDINT.ASM 5KB
fash.asm 4KB
sd.asm 4KB
CLOCK3.ASM 4KB
ATAPI.ASM 4KB
UART.ASM 4KB
BEEP.ASM 4KB
sd1.asm 4KB
HDDMA.ASM 4KB
BEEP1.ASM 4KB
hd2.asm 4KB
OPENEXE.ASM 3KB
OPENEXE1.ASM 3KB
dma2.asm 3KB
sd4.asm 3KB
INT4BH.ASM 3KB
DISK.ASM 3KB
ring.asm 3KB
MSCD.ASM 3KB
sd2.asm 3KB
PCIDEV.ASM 3KB
MOUSE1.ASM 3KB
MOUSE.ASM 2KB
system.asm 2KB
BMP3.ASM 2KB
COM.ASM 2KB
INDOS.ASM 2KB
ziku.asm 2KB
M.ASM 2KB
AC01.ASM 2KB
NMI.ASM 2KB
DEV.ASM 1KB
BMP.ASM 1KB
VGA2.ASM 1KB
M6.ASM 1KB
Search.asm 1KB
BMP1.ASM 1KB
fm.asm 1KB
OC.ASM 1KB
OPENBMP.ASM 971B
NT.ASM 938B
M5.ASM 910B
VGA4.ASM 738B
PCI.ASM 719B
kb10.asm 554B
circle.asm 520B
char.asm 446B
CURSOR.ASM 159B
INT0.ASM 130B
WIN9.BAK 17KB
AC97.BAK 10KB
CLOCK0.BAK 5KB
MOUSE.BAK 2KB
BMP.BAK 1KB
BMP3.BAK 1KB
DISK.BAK 665B
FINGER.BIN 800B
b57.bmp 1.25MB
b57.bmp 1.25MB
cattom.bmp 900KB
b54.bmp 769KB
b53.bmp 769KB
共 390 条
- 1
- 2
- 3
- 4
资源评论
satadriver
- 粉丝: 660
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功