• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >汇编语言 > 汇编源代码之一个旋转的3D箱子(动画)

汇编源代码之一个旋转的3D箱子(动画)

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2017-06-28

匿名通过本文主要向大家介绍了c语言推箱子源代码,java推箱子源代码,推箱子源代码,推箱子c 源代码,推箱子游戏源代码等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div> ;本程序由国外的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
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 汇编源代码之一个旋转的3D箱子(动画)

相关文章

  • 2017-06-17循环指令
  • 2017-06-17分支程序设计
  • 2017-06-17无条件转移指令
  • 2017-06-28驱动程序的编译和连接
  • 2017-06-28汇编源码系列之dossym
  • 2017-06-17存储单元的地址和内容
  • 2017-06-28对宏的再认识
  • 2017-06-28Win32汇编的环境和基础
  • 2017-06-28扩展Int 13H调用规范
  • 2017-06-28汇编语言上机过程指导及示例

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 汇编源码系列之showmem
    • 汇编语言的符号、标号和变量符号
    • 汇编源码系列之calc
    • 了解汇编命令行参数
    • 利用驱动程序读取硬盘序列号的汇编程序
    • 汇编教程之超类化
    • 汇编源码系列之circle
    • 除运算指令
    • 汇编源码系列之free
    • 什么是虚拟机管理器

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有