This code doesn't work on PB3.93

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

This code doesn't work on PB3.93

Post by Psychophanta »

Code: Select all

; converted from bb code
; edited by webmatze
; turn debugger off for performance..

#appWidth = 640
#appHeight= 480

; Structure LONG    ; Structure already declared in PB3.70+
;   l.l
; EndStructure

Dim Palette.l(255)
Dim table.l(#appWidth, #appWidth)

; init
Procedure.l FP_Init()
  Shared *Screen.LONG, bufferadr.l, byte_pixel.b, byte_line.l

  StartDrawing(ScreenOutput())
  StopDrawing()

  bufferadr.l = DrawingBuffer()

  byte_pixel.b = Round( ( DrawingBufferPixelFormat() + 1)/2, 1)
  byte_line.l = DrawingBufferPitch()

  *Screen.LONG = bufferadr
  
  ProcedureReturn bufferadr
EndProcedure

Procedure SetupPalette()
  ; create a temporary image...
  CreateImage(0, #appWidth, #appHeight)
  ; ...to draw a nice colour-pattern onto it
  StartDrawing(ImageOutput())
    For i = 0 To 63
     LineXY(i,0,i,200, RGB(0, 0, i*4))
    Next

    For i = 0 To 127
     LineXY(i+64,0,i+64,200, RGB(0, (i/2)*4, 63*4))
    Next

    For i = 0 To 63
     LineXY(i+192,0,i+192,200,RGB(i*4, 63*4, 63*4))
    Next
  ; grab palette data
  For x = 0 To 255
   Palette(x) = Point(x,0)
  Next
  StopDrawing()

  ; clean-up
  FreeImage(0)
EndProcedure

Procedure PreCalc()
  For y = 0 To #appHeight
   For x = 0 To #appWidth
    If x = 0 And y = 0
     table(y,x) = 255
    Else
     table(y,x) = (9000000000 / (Sqr(x*x + y*y) * 250000))
    EndIf
   Next
  Next
EndProcedure


If InitSprite() = 0
  End
EndIf

OpenWindow(0, 0, 0, #appWidth, #appHeight, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "testing...")
OpenWindowedScreen(WindowID(), 0, 0, #appWidth, #appHeight, 0, 0 ,0)

If FP_Init() = 0 : End : EndIf

SetupPalette()
PreCalc()

halfW.l = #appWidth/2
halfH.l = #appHeight/2


Repeat

  If WindowEvent() = #PB_Event_CloseWindow
    quit.b = 1
  EndIf
  
  ; fps
  If GetTickCount_() => zeit + 1000 
    FrameSek = Frames 
    Frames = 0 
    zeit = GetTickCount_() 
  Else 
    Frames + 1 
  EndIf 

  FlipBuffers()

  cosAlfa.f = Cos (alfa.f)
  cosAlfam.f = Cos (-alfa)
  cosAlfa2.f = Cos (alfa*2)
  cosAlfam2.f = Cos (-alfa*2)
  sinAlfa.f = Sin (alfa)
  sinAlfam.f = Sin (-alfa)
  sinAlfa2.f = Sin (alfa*2)
  
  
  
  x1.f = 60 * cosAlfa  + 30 * sinAlfam  + halfW
  y1.f = 30 * cosAlfam2 + 60 * sinAlfa   + halfH
  x2.f = 30 * cosAlfa    + 60 * sinAlfa2 + halfW
  y2.f = 60 * cosAlfa    + 30 * sinAlfa   + halfH
  x3.f = 45 * cosAlfam   + 45 * sinAlfa   + halfW
  y3.f = 45 * cosAlfa2  + 45 * sinAlfam  + halfH
  x4.f = 75 * cosAlfa    + 15 * sinAlfa2 + halfW
  y4.f = 15 * cosAlfam   + 75 * sinAlfa2 + halfH
  x5.f = 35 * cosAlfa    + 10 * sinAlfa   + halfW
  y5.f = 10 * cosAlfa2  + 35 * sinAlfam  + halfH
  x6.f = 40 * cosAlfam   + 30 * sinAlfa2 + halfW
  y6.f = 40 * cosAlfa    + 10 * sinAlfa   + halfH


  alfa.f+0.05
  
  For y = 0 To #appHeight Step 2
    a1.l = Abs(y1-y)
    a3.l = Abs(y2-y)
    a5.l = Abs(y3-y)
    a7.l = Abs(y4-y)
    a9.l = Abs(y5-y)
    a11.l = Abs(y6-y)
    *screen1.LONG = bufferadr + y*byte_line
    *screen2.LONG = *screen1 + byte_line
    For x = 0 To #appWidth Step 2
        a2.l = Abs(x1-x)
        a4.l = Abs(x2-x)
        a6.l = Abs(x3-x)
        a8.l = Abs(x4-x)
       a10.l = Abs(x5-x)
       a12.l = Abs(x6-x)

      pixel.l = table(a1, a2) + table(a3, a4) + table(a5, a6) + table(a7,a8) + table(a9, a10) + table(a11, a12)
     
      If pixel>255
        pixel=255
      EndIf
      
      pixel = palette(pixel)
      
      *screen1\l = pixel
      
      *screen1 + byte_pixel
      *screen1\l = pixel

      *screen2\l = pixel
      
      *screen2 + byte_pixel
      *screen2\l = pixel
      
      *screen1 + byte_pixel
      *screen2 + byte_pixel

    Next
  Next

  StartDrawing(ScreenOutput())
    FrontColor(0, 0, 0)
    DrawingMode(0)
    Locate(5,452)
    DrawText("FPS: "+Str(FrameSek))
  StopDrawing()

Until quit = 1

It is a plasma effect i found out there, and in previous versions it worked :roll:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Works fine here on WinXPhome with PB 3.93.
Image
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

It's messed up here (little rectangles...)
(winxp pro, ati radeon 9600xt, pb 3v93)
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: This code doesn't work on PB3.93

Post by traumatic »

Works fine here (XP, Ti4200)
It is a plasma effect[...]
The effect is called "blobs" actually ;)
Good programmers don't comment their code. It was hard to write, should be hard to read.
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

fsw wrote:It's messed up here (little rectangles...)
(winxp pro, ati radeon 9600xt, pb 3v93)
Yep, same problem here.. (maybe it's the ATI gfx card?)
(win2k, radeon 9600, pb3.93+updates)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

I own ATI Radeon 9600 too.
I get messy small rectangles.
Last edited by Psychophanta on Thu Mar 17, 2005 6:36 pm, edited 1 time in total.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i have ati, & same problem.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

It's messed up here too (little rectangles...)
(ATI 9800pro 128mb)
--Kale

Image
eevee
User
User
Posts: 69
Joined: Sat Jan 08, 2005 6:24 pm
Location: UK

Post by eevee »

P4 with ABit Geforce 128Meg

Crashes will Illegal Op.
Regards,

Ernest
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

eevee wrote:Crashes will Illegal Op.
Seems like you're the winner! :mrgreen:
Good programmers don't comment their code. It was hard to write, should be hard to read.
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

:lol: wow I am wondering that my S3 Unichrome can do that :shock: with shared memory. Yai!!! (WinXP Home)
bye,
Daniel
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Old MatroxG400 Athlon2200+
Works without problems, 50 fps :)
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

nice.. nvidia 64mb geforce4 (440go-mobile)

1.6ghz intel p4 mobile
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Post by LuCiFeR[SD] »

Def looking like an ATI issue... Getting the same rectangle drawing issues with an ATi Radeon 9550. But works fine on a geforce2 MX400.
xMystik
User
User
Posts: 10
Joined: Fri Apr 25, 2003 5:52 pm
Location: England
Contact:

Post by xMystik »

All messed up on my Radeon 9600

Steve.
Post Reply