PDA

View Full Version : [Tut] 2D-Metaballs



Mogh
12-19-2007, 10:54 PM
*** metab.asm

; 2D-Metaballs in 256 bytes
; Coded: Mogh at DXTH4X.COM

.model tiny, stdcall
.386
.code
option casemap :none
org 100h

BLOB_SIZE equ (offset blob1_end - offset blobs)

start:
push 0A000h
pop es
mov al, 13h
int 10h

xor cx, cx
make_palette:
mov dx, 3c8h
mov al, cl
out dx, al
inc dx
shr ax, 2
out dx, al
out dx, al
out dx, al
loop make_palette ; slow, but small

main_loop:
xor di, di

rend_screen:
mov bx, offset blobs
fldz
cwd
mov ax, di
mov cx, 320

div cx
@@:
mov tmp, dx
fild tmp
fsub real4 ptr [bx]
fmul st, st
mov tmp, ax
fild tmp
fsub real4 ptr [bx+4]
fmul st, st
fadd
fidivr word ptr [bx+8]
fadd
add bl, (BLOB_SIZE and 0FFh)
test bl, bl
jnz @B

fcom m_0_09
fnstsw ax
sahf
jc @F
mov al, 255
jmp put_pixel
@@:
fcom m_0_01
fnstsw ax
sahf
jc @F
fimul m_2700
fist tmp
mov al, byte ptr [tmp]
jmp put_pixel
@@:
mov al, 27
put_pixel:
fstp st
mov [di+500h], al
inc di
cmp di, (320*200)
jnz rend_screen

mov bx, offset blobs
@@:
fld counter
fld st
fidiv word ptr [bx+10]
fsin
fimul blob1_s
fadd real4 ptr [bx]
fstp real4 ptr [bx]

fidiv word ptr [bx+12]
fcos
fimul blobs_ca
fadd real4 ptr [bx+4]
fstp real4 ptr [bx+4]

add bl, (BLOB_SIZE and 0FFh)
test bl, bl
jnz @B

fld counter
fadd counter_a
fstp counter

mov si, 500h
xor di, di
mov cx, (320*200)/2
rep movsw

in al, 60h
dec al
jnz main_loop

mov ax, 03h
int 10h

ret

; data ---
m_0_09 real4 0.09
m_0_01 real4 0.01
m_2700 word 2700

counter real4 0.0
counter_a real4 0.5

blobs_ca word 3

blobs:
blob1_x real4 15.0
blob1_y real4 105.0
blob1_rad word 64
blob1_s word 8
blob1_c word 9
blob1_end:
blob2_x real4 15.0
blob2_y real4 105.0
blob2_rad word 33
blob2_s word 9
blob2_c word 8
blobs_end:

tmp word 0
end start

*** make.bat
ml /AT /Cp /c /nologo metab.asm
link /nologo /tiny metab.obj,metab.com,,,,


Like beginners see: Assembly is hard, i learn it from school.

I didn't add comments much but i hope you understand a little bit..

Str8Soulja
12-19-2007, 10:59 PM
if you really wrote this what does this mean

fadd real4 ptr [bx]
fstp real4 ptr [bx]

net
12-20-2007, 03:24 AM
from this site the code http://www.ohjelmointiputka.net/koodit_nayta.php?tunnus=471

Mogh
12-20-2007, 04:31 AM
Minä olen thefox.. Ja tuo on vanha koodi. =D I'm thefox, who writed the code, here i'm 'mogh' =)

Str8Soulja
12-20-2007, 05:40 AM
you never answered my question

net
12-20-2007, 07:01 AM
the code posted (03.05.2003) is not you the thefox :)

Mogh
12-20-2007, 10:07 AM
There got new, 12.11.07..Search.. And Str8, w8

net
12-21-2007, 06:19 AM
you need to replay DXT-Str8Soulja :)

Mogh
01-07-2008, 02:40 PM
Oh, sorry. I got little bad English but..:o

Commands fadd and fstp relate for (to?) mathprocessor..

Dxt-Credzis
02-17-2008, 06:43 AM
Congratz, u needed 2 month's to google the answer.

ARYAN-MAN
12-19-2008, 04:33 PM
Can I like say... WTF?
What does that have to do with this lol. Stop spamming.

warrockhack
12-19-2008, 04:42 PM
There got new, 12.11.07..Search.. And Str8, w8

answare him cuz u no u can;t do wat ever u guys are talking about XD

hackisfun
12-20-2008, 12:53 AM
Congratz, u needed 2 month's to google the answer.

lawl thats what i was thinking comeandgetsome

Durrcookie
12-20-2008, 08:30 AM
Look at the date FFS...

Closed -_-