;Funky squares 
;Made by Frej <frej@multi.fi> somewhere between april and may 2000
;Bits reprogrammed to run within DeviatorOS
;
;This demo is just to show you how small graphical demos can get ;)
;Reprogrammed for DeviatorOS as demo program

code            segment byte public
                assume  cs:code, ds:code
		org	100h
com             proc    far

start:          jmp     initialize
include         toolbox.asm
                _compile
initialize:
                push cs
                pop  ax
                mov  ds, ax
                mov  es, ax

s:      mov bx,cs         ;put codesegment to bx
        add bh, 20h       ;add 2000 to bx
        mov ds,bx         ;and put it to ds
        mov ax, 13h       ;set ax to videomode 13
        int 10h           ;and do that
Main:   push ds           ;put buffer seg to stack
        pop es            ;and put that into es
        in ax, 40h        ;generate "random" number (timer)
        shl ax,4          ;multiply random # with 16
        mov di,ax         ;box offset (random)
        mov al,255        ;color of the box
        mov bx,50         ;height=50
pl:     add di,270        ;di+270 (320-width(50))
        mov cx,50         ;# bytes to copy to buffer
        rep stosb         ;and do it
        dec bx            ;decrement bx
        jnz pl            ;jump if bx not zero
        mov bh, 0FAh      ;assume bl = 0 (-> bx = FA00)
Smudge: mov al,[bx+1]     ;right color to al
        mov cl,[bx-1]     ;left color to cl
        add ax,cx         ;and add it to ax
        mov cl,[bx-320]   ;upper color to cl
        add ax,cx         ;and add it to ax
        mov cl,[bx+320]   ;lower color to cl
        add ax,cx         ;and add it to ax
        shr ax,2          ;divide with 4
        mov [bx],al       ;and but the avarage color to buffer
        dec bx            ;decrement bx
        jnz Smudge        ;jump if bx not zero
        mov ax, 0A000h    ;vga seg
        mov es,ax         ;put it to es
        mov ch,0FAh       ;# bytes to copy to vga
        xor di,di         ;zero vga offset
        xor si,si         ;zero buffer offset
        rep movsb         ;and do that

        _keypressed
        or  al, al
        jz  Main

       ; in al, 60h        ;check for keys
       ; dec al            ;was it esc?
       ; jnz Main          ;nope, continue


        mov ax,3          ;text mode
        int 10h           ;get back into text mode

        xor ah,ah         ;yes, return to OS
        call dosexit
        int 18h           ;back to good old kernel

; Note:- This was, as you can guess, ripped by from an os.
; So when it goes back to the 'good ol kernel' it just restarts.




exitptr:        call dosexit
                int 20h      

com             endp

code            ends

ProgramEnd      EQU $-01h

		end	start
;


