Effect - Broken TV

Share your advanced PureBasic knowledge/code with the community.
syntax error
User
User
Posts: 93
Joined: Tue Jan 13, 2004 5:11 am
Location: Midlands , UK

Effect - Broken TV

Post by syntax error »

Code updated for 5.20+

Code: Select all

; broken TV

; Converted from Jeppe Nielsons Blitz 'Broken TV' code

sw.l=GetSystemMetrics_(#SM_CXSCREEN)
sh.l=GetSystemMetrics_(#SM_CYSCREEN)

#cell=72

dSW=sw/4 : dSH=sh/4
bw.f=dSW/#cell : bh.f=dSH/#cell


; setup display
ShowCursor_(0)
OpenWindow(0, 0, 0, sw, sh, "",  #PB_Window_BorderLess)

; main loop
Repeat
 DC=StartDrawing(WindowOutput(0))
 For y=0 To #cell-1
  For x=0 To #cell-1
   c=50+Random(200)
   FrontColor(RGB(c,c,c))
   Box(x*bw,y*bh,bw,bh)
  Next
 Next
 
 BitBlt_(DC , dSW,0 , dSW,dSH , DC , 0,0,#SRCCOPY)
 BitBlt_(DC , 0,dSH , dSW*2,dSH , DC , 0,0,#SRCCOPY)
 BitBlt_(DC , 0,dSH*2 , dSW*2,dSH*2 , DC , 0,0,#SRCCOPY)
 BitBlt_(DC , dSW*2,0 , dSW*2,dSH*4 , DC , 0,0,#SRCCOPY)
 
 StopDrawing()
 Delay(5)
Until GetAsyncKeyState_(#VK_ESCAPE)=-32767

; cleanup
CloseWindow(0)
ShowCursor_(1)
End
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

intresting,
is it me or do i see a pattern in the noise o_O
maybe i should laydown...
~Dreglor
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

@SyntaxTerror:
Nice one ... I made a TV-Noise screen, too. See here : viewtopic.php?p=44495&highlight=#44495

However, I like the fact that you achieve a pretty cool running FX without using an Open(Windowed)Screen ! Thanx for sharing...

@Dreglor:
The actual random pattern is just a 72*72 region in this example. the rest is blitted/copied.
Comment out some of the BitBlt_ commands to see what I mean.
regards,
benny!
-
pe0ple ar3 str4nge!!!
syntax error
User
User
Posts: 93
Joined: Tue Jan 13, 2004 5:11 am
Location: Midlands , UK

Post by syntax error »

I saw a similar effect in a game once and wondered how they managed to change so many dots in realtime. Thanks to Jeppe Neilsons Blitz example code I found out how.
It's clever how the repeated blocks of the main image manage to merge together so well without too much noticable tiling.

The above example is very system friendly which means it can be used as a (broken monitor) screensaver!
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

syntax error wrote:I saw a similar effect in a game once and wondered how they managed to change so many dots in realtime. Thanks to Jeppe Neilsons Blitz example code I found out how.
It's clever how the repeated blocks of the main image manage to merge together so well without too much noticable tiling.

The above example is very system friendly which means it can be used as a (broken monitor) screensaver!
I had the idea of a screensaver, too - after I wrote my version .. you can download it from my site :

http://www.weltenkonstrukteur.de/cw.html
regards,
benny!
-
pe0ple ar3 str4nge!!!
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Re: Effect - Broken TV

Post by techjunkie »

syntax error wrote:

Code: Select all

; broken TV

; Converted from Jeppe Nielsons Blitz 'Broken TV' code

[/quote]
Another Jeppe Nielson... Sweet!!  :D
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

Code updated for 5.20+

I played from this idea and obtained this (obtain 25 Mpixels/s, FPS 32, in 1024x768 on my PC) :

Code: Select all

; broken TV
  ScreenXSize = GetSystemMetrics_(#SM_CXSCREEN)
  ScreenYSize = GetSystemMetrics_(#SM_CYSCREEN)
  If InitSprite() And InitKeyboard() And OpenScreen(ScreenXSize, ScreenYSize, 32, "")
      Repeat
        FlipBuffers()
        StartDrawing(ScreenOutput())
          Address = DrawingBuffer()
          !  MOV     esi, [v_Address]             ; esi = Address. esi is the start address
          !  MOV     edi, [v_ScreenXSize]      ; edi = (ScreenXSize * ScreenYSize - ScreenXSize - ScreenYSize) * 4 + 4 + Address which is equivalent to
          !  IMUL     edi, [v_ScreenYSize]      ; edi = (ScreenXSize - 1) * (ScreenYSize - 1) * 4 + Address
          !  SUB      edi, [v_ScreenXSize]      ; edi is the last address of the drawing buffer
          !  SUB      edi, [v_ScreenYSize]      ;
          !  SAL      edi, 2                             ;
          !  ADD     edi, 4                             ;
          !  ADD     edi, esi                           ;
          ! _While_Main:                               ; While loop
            c = Random(255)                         ; c = Random(255)
            !  MOV    ebx, dword [v_c]            ; ebx = c
            !  MOV    ecx, ebx                        ; ecx = ebx
            !  SAL     ecx, 8                            ; ecx << 8
            !  ADD    ecx, ebx                        ; ecx + ebx
            !  SAL     ecx, 8                            ; ecx << 8
            !  ADD    ecx, ebx                        ; ecx + ebx, which finally corresponds to ecx = ebx << 16 + ebx << 8 + ebx or RGB(ebx, ebx, ebx) meaning RGB(c, c, c)
            !  CMP    esi, edi                          ; if esi > edi
            !  JG      _Wend_Main                   ; Break
            !  MOV    [esi], ecx                       ; PokeL(esi, ecx)
            !  INC    dword [v_NPoints]           ; NPoints + 1
            !  ADD    esi, 4                             ; esi + 4 meaning Address + 4
            !  JMP   _While_Main                     ; Wend
          ! _Wend_Main:
          BackColor(RGB(0, 0, 0))
          FrontColor(RGB(255, 255, 255))
          DrawText(10, 10, Str(FPS))
          DrawText(10, 30, Str(Points))
        StopDrawing()
        If ElapsedMilliseconds() - tz => 1000
            FPS = NFrames
            tz = ElapsedMilliseconds()
            NFrames = 0
            Points = NPoints
            NPoints = 0
        EndIf
        NFrames + 1
        ExamineKeyboard()
      Until KeyboardPushed(#PB_Key_Escape)
      CloseScreen()
  EndIf
End
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

@fweil:
Nice one ... get constant 41fps on my machine with a resolution of 1024*768.
regards,
benny!
-
pe0ple ar3 str4nge!!!
Post Reply