Plasma.... only what you need 
Author Message
 Plasma.... only what you need

; plasma.asm  Tasm code
;                   "What Senr Bill guys used to write."
;
;                   "Only what you need and nothing more."
;                                                    Andy Kennedy
        MODEL tiny
        IDEAL
        p286

;

;
; This program try to show how plasma work, and to make it work on 286 or
; better and let it stay small...
; I know it could be faster and smaller, but you should be able to understand
; it...
;
; You can distribute, modify, etc. this program as long as you distribute
; the source code with it, and you credit me somewhere (in source or program)
; and if you do some modifications, say it!
;
; It take 5.88 sec to draw on my poor 386SX-16 with slow VGA card..
; And is 511 bytes...

CODESEG

MACRO   MakePal

        mov di,OFFSET palette
        mov cx,(193*3+1)/2
        xor ax,ax
        rep stosw               ; All zero at the palette

        mov di,OFFSET palette+3
        mov cx,64
        push cx
        mov ax,63*256

MPLP1:  
        stosw
        sub ax,0FFh
        inc di
        loop MPLP1

        mov ax,63
        pop cx  

MPLP2:  stosb
        inc di
        xchg ah,al
        stosb
        xchg ah,al
        add ax,0FFh
        loop MPLP2

        mov cx,192*3/2
        inc di
        mov si,OFFSET palette+3
        rep movsw

ENDM    MakePal

        ORG 100h

MAXY    EQU 199

start:  mov al,13h
        int 10h         ; MCGA mode (320x200x256)

        MakePal         ; create Palette...

        call SetVGApalette

        push 0A000h     ; Set video segment
        pop ds

        call rand       ;
        mov [0],ah      ; putpixel(0, 0, rand() % 192) in more direct...
        call rand
        mov [319],ah
        call rand
        mov [MAXY*320+319],ah  
        call rand
        mov [MAXY*320],ah

        call subDivide C, 0, 0, 319, MAXY

        push cs

        mov ah,86h
        mov dx,3000h
        xor cx,cx
        int 15h

        call rotatePalette      ; rotatePalette

        mov ah,1
        int 16h

        xor ax,ax
        int 16h         ; remove key from buffer

        mov ax,3
        int 10h         ; Text mode...
        ret             ; Exit program

PROC    subDivide
ARG     x1:WORD,y1:WORD,x2:WORD,y2:WORD

        push bp
        mov bp,sp
        pusha
        mov dx,[x1]     ; DX=X1
        mov cx,[x2]     ; CX=X2

        mov ax,cx
        sub ax,dx
        cmp ax,2

                        ;   No need to test (y2-y1)=>2 because it never be
                        ;   runned (x is greater)
        popa
        pop bp

        mov bx,[y1]     ; BX=Y1
        mov ax,[y2]     ; AX=Y2
        mov si,dx
        add si,cx
        shr si,1        ; SI=average(X1, X2)

        mov di,ax
        add di,bx       ; DI=average(Y1, Y2)
        shr di,1

        ; adjust...
        call adjust C, dx, bx, si, bx, cx, bx ; Adjust(X1, Y1, SI, Y1, X2,
Y1)
        push ax
        push dx
        push di
        push dx
        push bx
        push dx
        call adjust     ; Adjust(X1, Y1, X1, DI, X1, Y2)
        add sp,10       ; Play with stack to save 1 push and some clocks...
        push cx
        push di
        push cx
        push bx
        push cx
        call adjust     ; Adjust(X2, Y1, X2, DI, X2, Y2)
        add sp,8        ; Play again with stack...
        push ax
        push si
        push ax
        push dx
        call adjust     ; Adjust(X1, Y2, SI, Y2, X2, Y2)
        add sp,12
        push di
        imul di,320
        add di,si
        cmp [BYTE di],0

                        ; Yes, not used...
                        ; Else skip...
        push si         ; Save SI for later...
        mov si,bx       ; SI=BX
        xor ax,ax
        ; Following code:
        ; ax=getpixel(X1,Y1)+getpixel(X2,Y1)+getpixel(X1,Y2)+getpixel(X2,Y2)
        imul di,[y2],320
        add di,dx
        mov al,[di]
        mov bx,ax
        sub di,dx
        add di,cx
        mov al,[di]
        add bx,ax
        imul di,si,320
        add di,dx
        mov al,[di]
        add bx,ax
        sub di,dx
        add di,cx
        mov al,[di]
        add ax,bx
        ; Now calculate average of the 4 corners...
        shr ax,2        ; ax=bx/4... Average of corners...
        mov bx,si       ; BX=SI, normal value (Y1)
        pop si          ; Restore SI...
        pop di
        push di
        imul di,320
        add di,si
        mov [di],al

        pop di
        push di
        push si
        push bx
        push dx
        call subDivide  ; recurse
                        ; subDivide(X1, Y1, SI, DI)
                        ; 1/4 of itself until condition on top
                        ; doesn't work
        add sp,6
        push cx
        push bx
        push si
        call subDivide  ; SubDivide(SI, Y1, X2, DI)
        add sp,8
        push [y2]
        push cx
        push di
        push si
        call subDivide  ; SubDivide(SI, DI, X2, Y2)
        add sp,6
        push si
        push di
        push dx
        call subDivide  ; SubDivide(X1, DI, SI, Y2)
        add sp,8
        popa
        pop bp
        ret             ; End one recursion...

ENDP    subDivide

PROC    adjust
ARG     xa:WORD, ya:WORD, x:WORD, y:WORD, xb:WORD, yb:WORD

        push bp
        mov bp,sp
        pusha
        imul bx,[y],320
        add bx,[x]
        cmp [BYTE bx],0

        mov bx,[xa]
        sub bx,[xb]       ; BX=Abs(XA-XB)


        mov si,[ya]
        sub si,[yb]


        add si,bx       ; SI+=BX
                        ; SI=delta(X)+delta(Y)
                        ; Used later...
        xor ax,ax
        imul di,[ya],320        ; bx=GetPixel(XA,YA)
        add di,[xa]
        mov al,[di]
        mov bx,ax
        imul di,[yb],320        ; bx+=GetPixel(XB,YB)
        add di,[xb]
        mov al,[di]
        add bx,ax
        shr bx,1        ; BX/=2 Average

        in al,40h       ; Random 0-255...
        sub ah,ah
                        ; AX=SI*(rand(0-255))/128+BX-SI <-- modify this
        mul si          ; formula to change the plasma...
        shr ax,7
        sub ax,si
        add ax,bx
        or ax,ax
        jg Cnt1
        mov al,1       ; AX must be between 1 and 192

Cnt1:
        cmp ax,193


        add bx,[x]

        popa
        pop bp
        ret

ENDP    adjust

PROC    rotatePalette
        ; Take palette part(1-192) and rotate it one pos forward
        ; Use paltmp to not make some colors unchanged...

        pusha

        mov si,OFFSET palette+3
        lodsw
        mov bl,[si]

        mov di,OFFSET palette+3
        mov si,OFFSET palette+6
        mov cx,191*3/2
        rep movsw
        movsb
        stosw
        mov [di],bl

        popa            ; No ret, so will continue...
                        ; (save one call and 4 bytes)
ENDP    rotatePalette

PROC    SetVGApalette

        mov si,OFFSET palette
        mov cx,193*3


        in al,dx
        test al,8

        in al,dx
        test al,8

        xor ax,ax
        mov dx,3C8h
        out dx,al       ; Set starting color
        inc dx          ; port 3C9h
        rep outsb       ; set color palette

        ret

ENDP    SetVGApalette

; Return in AH... 1-191
PROC    rand

        in al,40h       ; PIT counter divisor (pseudo-random result)
        mov ah,al
        and ah,7Fh
        in al,40h       ; idem
        and al,3Fh      ; To avoid overflow (65535/192>255)
        add al,ah
        inc ax
        ret

ENDP    rand

DATASEG

palette db 193*3 DUP (?)

END start



Tue, 05 Jul 2005 01:13:10 GMT  
 Plasma.... only what you need

Quote:

>; plasma.asm  Tasm code
>;                   "What Senr Bill guys used to write."
>;
>;                   "Only what you need and nothing more."
>;                                                    Andy Kennedy
>        MODEL tiny
>        IDEAL
>        p286

>;

>;
>; This program try to show how plasma work, and to make it work on 286 or
>; better and let it stay small...
>; I know it could be faster and smaller, but you should be able to understand
>; it...
>;
>; You can distribute, modify, etc. this program as long as you distribute
>; the source code with it, and you credit me somewhere (in source or program)
>; and if you do some modifications, say it!
>;
>; It take 5.88 sec to draw on my poor 386SX-16 with slow VGA card..
>; And is 511 bytes...

>CODESEG

>MACRO       MakePal

>    mov di,OFFSET palette
>    mov cx,(193*3+1)/2
>    xor ax,ax
>    rep stosw               ; All zero at the palette

>    mov di,OFFSET palette+3
>    mov cx,64
>    push cx

[]
hiya,

I tried to assemble that but I only have MASM and it was giving
a lot of errors.... I used to have a copy of TASM (this is TASM
source code, right? ) but it's one of those neat things that you
have "somewhere" on the harddrive that gets replaced and for some
reason even though you copied everything, 5% of the really useful
things get lost (the little piece of paper syndrome; all the note
paper with junk that never gets used accumalated whilst the
note paper with very very very useful notes goes off to pixie land ;-)

Anyhow I was just going to say that you might find this section
of my site interesting, there is source included;

http://lf.1accesshost.com/VARIOUS/VARIOUS.HTM

The "VPRJ" series are plasma-type programs,

bestwishes
laura



Tue, 05 Jul 2005 08:23:36 GMT  
 Plasma.... only what you need
Yes this would be for TASM only, you would need to change some of the code
for this to work with MASM.


Quote:

> >; plasma.asm  Tasm code
> >;                   "What Sen"r Bill guys used to write."
> >;
> >;                   "Only what you need and nothing more."
> >;                                                    Andy Kennedy
> >        MODEL tiny
> >        IDEAL
> >        p286

> >;

> >;
> >; This program try to show how plasma work, and to make it work on 286 or
> >; better and let it stay small...
> >; I know it could be faster and smaller, but you should be able to
understand
> >; it...
> >;
> >; You can distribute, modify, etc. this program as long as you distribute
> >; the source code with it, and you credit me somewhere (in source or
program)
> >; and if you do some modifications, say it!
> >;
> >; It take 5.88 sec to draw on my poor 386SX-16 with slow VGA card..
> >; And is 511 bytes...

> >CODESEG

> >MACRO MakePal

> > mov di,OFFSET palette
> > mov cx,(193*3+1)/2
> > xor ax,ax
> > rep stosw ; All zero at the palette

> > mov di,OFFSET palette+3
> > mov cx,64
> > push cx

> []
> hiya,

> I tried to assemble that but I only have MASM and it was giving
> a lot of errors.... I used to have a copy of TASM (this is TASM
> source code, right? ) but it's one of those neat things that you
> have "somewhere" on the harddrive that gets replaced and for some
> reason even though you copied everything, 5% of the really useful
> things get lost (the little piece of paper syndrome; all the note
> paper with junk that never gets used accumalated whilst the
> note paper with very very very useful notes goes off to pixie land ;-)

> Anyhow I was just going to say that you might find this section
> of my site interesting, there is source included;

> http://lf.1accesshost.com/VARIOUS/VARIOUS.HTM

> The "VPRJ" series are plasma-type programs,

> bestwishes
> laura



Wed, 06 Jul 2005 03:35:09 GMT  
 Plasma.... only what you need

Quote:

> Anyhow I was just going to say that you might find this section
> of my site interesting, there is source included;

> http://lf.1accesshost.com/VARIOUS/VARIOUS.HTM

<BODY BGCOLOR=#000000 TEXT=#0000FF

That's very dark text. Are you sure you wouldn't be more readable with
something a bit ligther than that? I found it completely unreadable at any
size (until I overrided your colours).

Phil



Wed, 06 Jul 2005 06:01:40 GMT  
 Plasma.... only what you need

Quote:
>I tried to assemble that but I only have MASM and it was giving
>a lot of errors.... I used to have a copy of TASM (this is TASM
>source code, right? ) but it's one of those neat things that you
>have "somewhere" on the harddrive that gets replaced and for some

There are older versions of Tasm for free on the net, it used to be most
code was tasm. Now it's tasm,masm, and about 5 others.
I'm learning masm now, but that's it on the compilers. Paying for my 2 daughters
in college doesn't give a single parent much time.

Quote:
>Anyhow I was just going to say that you might find this section
>of my site interesting, there is source included;

>http://lf.1accesshost.com/VARIOUS/VARIOUS.HTM

>The "VPRJ" series are plasma-type programs,

Thanks, I have it bookmarked.

Please include my sister Andrea and our family in your prayers. She has taken
a bad turn for the worse.

Thanks.



Thu, 07 Jul 2005 03:21:02 GMT  
 Plasma.... only what you need

Quote:
> Please include my sister Andrea and our family in your prayers. She has taken
> a bad turn for the worse.

I'd like to add some lbs of my prayers too, please tell me the exact space
coordinates to send them to.

Quote:
> Thanks.

You're welcome, I'll send the parcel later. I guarantee results.


Thu, 07 Jul 2005 18:10:17 GMT  
 Plasma.... only what you need

Quote:


>> Anyhow I was just going to say that you might find this section
>> of my site interesting, there is source included;

>> http://lf.1accesshost.com/VARIOUS/VARIOUS.HTM

><BODY BGCOLOR=#000000 TEXT=#0000FF

>That's very dark text. Are you sure you wouldn't be more readable with
>something a bit ligther than that? I found it completely unreadable at any
>size (until I overrided your colours).

hi

Yeah, I will change it to more sensible green once I have things
organised more locally (I've been doing most of the uploading & file
maintenance manually so now I'm working on some proper scripts to do it all
for me ;-). Another thing you can do, as recommended on the site,
is to use "Save As... text"... a lot of the material is meant to be
viewed as text anyhow, (I only changed it to HTML due to ISP problems
but most stuff is sourced from TEXT).

Quote:

>Phil

bestwishes
laura


Fri, 08 Jul 2005 08:26:40 GMT  
 Plasma.... only what you need

Quote:

>>I tried to assemble that but I only have MASM and it was giving
>>a lot of errors.... I used to have a copy of TASM (this is TASM
>>source code, right? ) but it's one of those neat things that you
>>have "somewhere" on the harddrive that gets replaced and for some
>There are older versions of Tasm for free on the net, it used to be most
>code was tasm. Now it's tasm,masm, and about 5 others.

Do you have a link for an old tasm version? I keep my eyes peeled
but I don't have a lot of time for browsing at the moment.

Quote:
>I'm learning masm now, but that's it on the compilers. Paying for my 2 daughters
>in college doesn't give a single parent much time.

Compiler? I don't know about Randy's HLA (I haven't tried it yet
but all the talk has made me very curious to have a look) but
MASM and TASM are assemblers. I'm very very familiar with the time
problem,...;)

Quote:

>>Anyhow I was just going to say that you might find this section
>>of my site interesting, there is source included;

>>http://lf.1accesshost.com/VARIOUS/VARIOUS.HTM

>>The "VPRJ" series are plasma-type programs,
>Thanks, I have it bookmarked.

>Please include my sister Andrea and our family in your prayers. She has taken
>a bad turn for the worse.

Sorry to hear about that, hope she gets better soon.

Quote:

>Thanks.

bestwishes
laura


Fri, 08 Jul 2005 10:08:05 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Cheap Plasma TV DwbIfq

2. AI for plasma control

3. Static Plasma???

4. recursive procs and plasma

5. Plasma with text included ..

6. Fire/plasma/etc. effect in TASM

7. Optimization contest - PLASMA - 559 bytes

8. recursive procs and plasma

9. recursive procs and plasma WITH source

10. Can anyone send me plasma and musicmodule demos

11. PLASMA PROBLEM

12. Plasma can Export VRML too!

 

 
Powered by phpBB® Forum Software