Archived

This topic is now archived and is closed to further replies.

noob2asm

rotating 3d cube in assembly

Recommended Posts

Hey there, im lookin for the source code for a 3d rotating cube in assembly ? Know of links for reference or source code etc?

Share this post


Link to post
Share on other sites
ummmm, why are you going to do it in assembly. if you using windows, it would be much easier to do it in DirectX ya know.

o yeah, sorry i didn''t actually answer your question

Share this post


Link to post
Share on other sites
Do you want a wireframe cube or a filled cube? Flat shaded? Gouraud? Phong? Texture mapped? There are quite a few sources around the net for this stuff. Some names to look out for are VLA and OTM (two demo groups who wrote some docs about this stuff). I''m sure there''s something on gamedev about it..

cheers
sam

Share this post


Link to post
Share on other sites
my current knowledge is null,just thought it would be fun to do it in assembly.

that link is that for assembly ?

[edited by - noob2asm on April 21, 2004 12:23:45 PM]

Share this post


Link to post
Share on other sites
"my current knowledge is null,just thought it would be fun to do it in assembly."

It certainly IS null if you think doing it in assembly would be fun.

Try it first in a high level language.

Learn the techniques for displaying something, anything, using whatever API you have to hand (I wrote my first spinning cube in Delphi, just using the Timage and Ttimer components).

Then learn basic animation techniques.

When you have a spinning cube working in a high level language, you will then be ready to do it in assembler.

Don’t lose your ambition, just learn to walk before trying to fly.




Stevie

Don''t follow me, I''m lost.

Share this post


Link to post
Share on other sites
Even if you were to write the demo in assembly, you would probably still use GDI functions just like in C/C++ if you were creating a Win32 application. Other than the language syntax, it wouldn''t be a whole lot different than doing it in C, especially if the code was written with higher level MASM32 directives.

Share this post


Link to post
Share on other sites
I would write a rotating cube in asm just for fun, I love assembler , but I think you''re going about programming the wrong way and doing this for you would be a waste of time. Go learn an easier language than assembler for starters

Share this post


Link to post
Share on other sites
;  _   _   _   _
; s u ( u b u s this source code is written to be compiled by NASM
; 2 5 6 b y t e http://www.web-sites.co.uk/nasm

; i n t r o 2 K my thanks goes to loveC for his invaluable hints and support
; b a z e 3 S C feel free to e-mail: baze@decef.elf.stuba.sk

[org 100h]
[segment .text]

finit
fldz
mov al,13h
int 10h

mov cl,0
PAL mov al,cl
mov edx,0F65203C8h
out dx,al
inc dx
shr al,2
out dx,al
shl al,1
out dx,al
mov al,0
out dx,al
loop PAL

mov ax,cs
add ah,16
mov fs,ax
add ah,16
mov gs,ax

mov di,dx
CUBEG sbb ax,ax
and ax,112
sub ax,56
stosw
shr edx,1
jnz CUBEG

MAIN fadd dword [ANGLE]

mov si,3C9h+2
mov cl,8*3
ROTATE fld st0
fsincos
fild word [si]
lodsw
fld st0
fmul st0,st2
fild word [si]
lodsw
lodsd
mov [si+64-8],ax
fmul st3,st0
fmul st0,st4
fsubp st1,st0
fistp word [si+64-6]
fmulp st2,st0
faddp st1,st0
fistp word [si+64-4]
loop ROTATE

lea di,[si+5]
mov al,0
mov cl,8
ZCOL add [di-1],byte 128
add al,85
or al,128
mov [di],al
add di,byte 8
loop ZCOL

mov bx,[si]
mov dx,[si+2]
mov ax,[si+4]

mov ch,10h ; change this to affect speed and quality
bswap ecx

CUBE add bp,cx
ror bp,cl
push bp
and bp,byte 111000b

add bx,[bp+si]
sar bx,1
add dx,[bp+si+2]
sar dx,1
add al,[bp+si+4]
rcr al,1
add ah,[bp+si+5]
rcr ah,1

pop bp
imul di,dx,320
push di
add di,160*320+100
call ZBUFF
pop di
neg di
call ZBUFF
dec ecx
jnz CUBE

push word 0A000h
pop es

xor di,di
BACK add si,cx
rol si,cl
mov bx,si
sar bx,12
inc bx
add ah,bl
add ah,[gs:di-320]
shr ah,1
mov al,[gs:di]
mov [fs:di],ah
mov [gs:di],ah
stosb
loop BACK

in al,60h
dec al
jnz near MAIN
mov ax,3
int 10h

ZBUFF cmp al,[fs:bx+di]
jc ZEND
mov [fs:bx+di],al
mov [gs:bx+di],ah
ZEND ret

db 23h,3Dh
ANGLE equ $-4


[edited by - Jocke- on April 23, 2004 7:56:30 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by noob2asm
noob2asm when i started asm, not so much of a noob now


noob2asm Member since: 4/3/2004

If you were a noob to Assembly on the 3rd of April this year, I''d suggest that it''s safe to assume you are still a noob to it now..

Knowing the syntax isn''t the same as knowing what you''re doing

Just my $0.02

Jx

Share this post


Link to post
Share on other sites
quote:
Original post by noob2asm
is there free alternative than the abrash code, since it is a pay for site ?


It is? Huh. The Black Book is free online in a lot of places. I just took the first link that showed up on Google. Do a search for "abrash black book" and you should find it. It''s probably one of the best books for what you''re trying to do.

Share this post


Link to post
Share on other sites
quote:
Original post by noob2asm
Hey there, im lookin for the source code for a 3d rotating cube in assembly ? Know of links for reference or source code etc?

Have you tried OpenGL?

I think this might be somewhat helpful.
http://www.cfxweb.net/modules.php?name=News&file=article&sid=1922
http://www.wasm.ru/article.php?article=masmgl00

And of course don't forget on NEHE.


[edited by - raghar on April 24, 2004 8:09:14 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by noob2asm
that second link doesnt work..... dont wanna use OpenGL, just use plain ol assembly.

Umm what are you going to draw in then? Are you going to use win32 drawing functions? Create a dos program and use int 13h screen mode?

Share this post


Link to post
Share on other sites