level 7
Stack Segment Stack dw 200 dup(?) Stack Ends Code Segment ; Code segment starts Assume cs:code,ds:code ; Let cs and ds point to code segment 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 tran: mov al,byte ptr [si] out dx,al inc si loop tran 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 === WaitVrt PROC ; 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 WaitVrt ENDP UpdateAngles PROC ; 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 UpdateAngles ENDP
2008年05月01日 10点05分