flat assembler
Message board for the users of flat assembler.

Index > DOS > What do you see here?

Author
Thread Post new topic Reply to topic
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 06 Jul 2008, 19:09
What do you see when you run this program?
I see a cyclops laying on its side throwing up.. Shocked ...but thats just me...(btw, most of the code minus a bit was "borrowed" out of comrades 1kb sinus cirlces thingy here.)
I stumbled upon this while playing around with the source to that program and generated this odd thing.
Each pixel basically is :
((sin(x)+sin(distance to center) / 2) + x) / 2

Code:
        org     100h
        ; switch to graphics mode
        mov     al, 013h
        int     10h

        push    cs
        pop     es
        mov     di, dist
        mov     bx, 200
@@dsty: mov     cx, 320
        @@dstx: mov     [x], cx
                mov     [y], bx
                sub     [x], 160
                sub     [y], 100
                fild    [x]
                fild    [x]
                fmulp   st1,st0
                fild    [y]
                fild    [y]
                fmulp   st1,st0
                faddp   st1,st0
                fsqrt
                fistp   [x]
                mov     ax, [x]
                stosb
                loop    @@dstx
        dec     bx
        jnz     short @@dsty

        ; initialize the palette
        mov     cx, 256
        xor     ax, ax
@@spal: mov     dx, 3C8h
        out     dx, al
        inc     dx
        out     dx, al
        out     dx, al
        out     dx, al
        inc     al
        loop    @@spal

        ; main loop
@@main: ; wait for vertical sync
        mov     dx, 3DAh
@@vs0:  in      al, dx
        test    al, 8
        jz      @@vs0
@@vs1:  in      al, dx
        test    al, 8
        jnz     @@vs1

        ; draw
        push    0A000h
        pop     es
        mov     bx, 200
        mov     si, dist
        xor     di, di
        xor     ax, ax
        mov [x],0
        mov [y],0
@@y:    mov     cx, 320
        mov [x1],0
        @@x:
                lodsb
                mov     [y], ax
                fild    [y]
                fdiv    [freq]
                ;fild    [counter]
                ;fsubp   st1,st0
                fsin
                fmul    [amp]
                fadd    [amp]
                fistp   [y]

                fild    [x1]
                ;fiadd   [y1]
                fdiv    [freq]
                ;fild    [counter]
                ;fsubp   st1,st0
                fsin
                fmul    [amp]
                fadd    [amp]
                fistp   [x]

                mov ax, [x]
                add ax,[y]
                shr ax,1
                add ax,[x1]
                shr ax,1

                stosb
                inc [x1]
                loop    @@x
        inc     [y1]
        dec     bx
        jnz     @@y

        ;inc     [counter]
        ; delay
        push    cs
        push    040h
        pop     ds
        mov     ax, [ds:6Ch]
@@wait: mov     cx, [ds:6Ch]
        sub     cx, ax
        cmp     cx, 2
        jl      @@wait
        pop     ds
        key:
        in al,60h
        dec al
        jnz key
        ;jnz @@main

        ; restore text mode
        mov     ax, 003h
        int     10h

        ret
;#########################################################################
        freq    dd      10.0
        amp     dd      31.0
        x       dw      0
        y       dw      0
        x1      dw      0
        y1      dw      0
        counter dw      0
        dist:
;#########################################################################
    


also, try changing:
Code:
@@x: 
                lodsb 
                mov     [y], ax 
                fild    [y] 
                fdiv    [freq] 
                ;fild    [counter] 
                ;fsubp   st1,st0 
                fsin 
                fmul    [amp] 
                fadd    [amp] 
                fistp   [y] 

                fild    [x1] 
                ;fiadd   [y1] 
                fdiv    [freq] 
                ;fild    [counter] 
                ;fsubp   st1,st0 
                fsin 
                fmul    [amp] 
                fadd    [amp] 
                fistp   [x] 

                mov ax, [x] 
                add ax,[y] 
                shr ax,1 
                add ax,[x1] 
                shr ax,1 

                stosb 
                inc [x1] 
                loop    @@x
    


to:

Code:
@@x:
                lodsb
                mov     [y], ax
                fild    [y]
                fdiv    [freq]
                ;fild    [counter]
                ;fsubp   st1,st0
                fsin
                fmul    [amp]
                fadd    [amp]
                fistp   [y]

                fild    [y1]
                 ;fiadd   [y1]
                fdiv    [freq]
                 ;fild    [counter]
                 ;fsubp   st1,st0
                fsin
                fmul    [amp]
                fadd    [amp]
                fistp   [x]

                mov ax, [x]
                add ax,[y]
                shr ax,1
                add ax,[y1]
                shr ax,1

                stosb
                inc [x1]
                loop    @@x
    


Are these boards dying? I've been gone since mid june(no internet Sad ) and doesn't look like much has gone on since then.

Wooooo......4 years as a registered user and only 50 some posts lol

_________________
----> * <---- My star, won HERE
Post 06 Jul 2008, 19:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20343
Location: In your JS exploiting you and your system
revolution 07 Jul 2008, 01:40
windwakr wrote:
Are these boards dying? I've been gone since mid june(no internet Sad ) and doesn't look like much has gone on since then.
Well let's see. Sometime in mid-June the board was hacked and everybody lost access for ~1 day. Tomasz took the opportunity to upgrade the forum software and many bugs were discovered. Then it was discovered that many of the users passwords had been reversed and publicly posted (including my own and vid's passwords). Emails were sent out to the affected users and everyone had to reset their password. Do try to keep up.
windwakr wrote:
Wooooo......4 years as a registered user and only 50 some posts lol
If you want more activity then post some more. You can't just wait for others to post, you must also participate. So the above post is a good start, keep them coming.


Last edited by revolution on 07 Jul 2008, 04:15; edited 1 time in total
Post 07 Jul 2008, 01:40
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 07 Jul 2008, 01:55
windwakr wrote:

Each pixel basically is :
((sin(x)+sin(distance to center) / 2) + x) / 2


What you invented there is a class of graphics demos called "plasmas" Smile
Those used to be real popular in late 80s/early 90s in the demo-scene world.

Its a rather easy effect: add a bunch of sine-waves of different periods, index into a gradient palette table. Do a phase-shift on the sine-waves for animation.

Check Hornet (these days accessible at http://www.scene.org/dir.php?dir=%2Fmirrors%2Fhornet%2Fcode%2Feffects%2Fplasma/) for more demos of this sort. You will probably need a MS-DOS VM with something like Turbo C and TASM installed to play with the sources Smile Though I think most stuff still runs fine under NTVDM.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 07 Jul 2008, 01:55
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 07 Jul 2008, 01:56
If really get interested in that kinda stuff, also check http://www.pouet.net/ or ask around in #coders on IRCnet.
Post 07 Jul 2008, 01:56
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4043
Location: vpcmpistri
bitRAKE 07 Jul 2008, 02:07
ZOMG - one of the aliens have revealed itself:
Code:
@@x:
                lodsb
                mov     [y], ax

                fild    [y]
                fdiv    [freq]
                ;fild    [counter]
                ;fsubp   st1,st0
                fsin
                fmul    [amp]
                fadd    [amp]
                fistp   [y]

                fild    [y1]
                 ;fiadd   [y1]
                fdiv    [freq]
                 ;fild    [counter]
                 ;fsubp   st1,st0
                fsin
                fmul    [amp]
                fadd    [amp]
                fistp   [x]

                add ax,[y]
                add ax,[x]
                shr ax,1
                jpe .0
                add ax,[y1]
                jmp .1
.0:             xadd ax,dx
.1:             shr ax,1
                stosb
                inc [x1]
                loop    @@x    
Laughing

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 07 Jul 2008, 02:07
View user's profile Send private message Visit poster's website Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 07 Jul 2008, 02:20
Wow, the forums were hacked? Good thing everythings back to normal(or at least looks normal, I couldn't tell anything had happened)

comrade:
Thanks for the links. I'll check them out.

bitRAKE:
Shocked .....WOW.....

_________________
----> * <---- My star, won HERE
Post 07 Jul 2008, 02:20
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 07 Jul 2008, 02:46
Since I can't provide any better image then I'll contribute a modification on the code Razz

Code:
        @@dstx: mov     [x], cx
                mov     [y], bx  
                sub     [x], 160  
                sub     [y], 100  
                fild    [x]  
;                fild    [x]  
                fmul   st0, st0
                fild    [y]  
;                fild    [y]  
                fmul   st0, st0
                faddp     
    


BTW, also try this:
Code:
        @@dstx: mov     [x], cx
                mov     [y], bx
                sub     [x], 160
                sub     [y], 100
                fild    [x]
                fabs
                fild    [y]
                fabs
                faddp
                fistp   [x]
                mov     ax, [x]
                stosb
                loop    short @@dstx    
(Not equivalent but yet provides somewhat "nice" results)
Post 07 Jul 2008, 02:46
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 07 Jul 2008, 02:54
Ya, that diamond pattern makes it look good.
Post 07 Jul 2008, 02:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.