Page 1 of 1

PB on Mac OS... strange bugs?

Posted: Wed Feb 06, 2013 8:15 pm
by zxtunes.com
I bought a MacBook.

I decided to start to try to move my project to him.

So what.

The first thing that does not work is a constant.
Mac OS version is not aware of colors!
# white, # red, # blue, etc.

Next. Files no longer work. It was found that the variable ReadFile file pointer must be Q, and not L!

But this is not the end. The program starts, but even ClearScreen not working correctly. For example ClearScreen (rgb (255,255,255)) makes the screen blue!

And instead of 3D sprites I see some piece mush.

p.s.

PB IDE has a strange bug. It does not want to write the modified file.

"Cannot save source code!"

p.s. PB 5.0, Mac OS 10.8, x64

And yes. Program runs on Mac 20 times slower. How is this possible?

Image

Re: PB on Mac OS... WTF?

Posted: Wed Feb 06, 2013 8:43 pm
by fsw
Hi,
FIRST:
as a long time member of this forum I would appreciate if you could delete "WTF" from the subject.
It is not the way we speak in this forum.
We all try to show some respect to each other (yes even to the PureBasic developers :wink: ) and converse in a professional manner.
I can image that having the three letter word in your subject might discourage people to help you.

SECOND:
I'm also new to OSX and had some problems because this OS just works different than Windows.
Maybe if you would show us code snippets to show what doesn't work it might encourage others to take your snippet and try it on their computer, in order to help you.

Thanks for reading.

peace

@Moderator
Maybe it's better to move this topis into the MacOS section where more MacOS users might find it.

Re: PB on Mac OS... WTF?

Posted: Wed Feb 06, 2013 8:57 pm
by zxtunes.com
I did not mean anything bad. I love this community and PureBasic.
In Russia perceives harmless WTF, like - "What the hell".

Package with source and stuff for windows: https://dl.dropbox.com/u/6439155/8bit%20mapping.zip (6Mb) - work fine.


Full code:

Code: Select all


UsePNGImageDecoder()

InitSprite()
InitSprite3D()
InitMouse()
InitKeyboard()

#bsize = 9
#show = 1
#clip = 5
#eye = 765
#left_sprite = 767
#right_sprite = 768
#center_sprite = 769
#free = 1118
#free2 = 1119

#terminator = 100
#draw = 101
#buddha = 102
#angel = 103
#star = 104
#embrion = 105
#swast = 106
#birth = 107
#man = 108
#heart = 109

#eye_mask = 120




Structure polygon
  
  Sprite.l
  
  xp.l
  yp.l
  
  x1.f
  x2.f
  x3.f
  x4.f
  y1.f
  y2.f
  y3.f
  y4.f
  
  on.l
  
  aspect_w.f
  aspect_h.f
  
  zoom.f
  
EndStructure

Structure loop
  
  file$
  position.l
  sel_start.l
  sel_end.l
  loop.l
  lenght.l
  
  frame_first.l
  frame_last.l
  
  category.l
  h_flip.l
  v_flip.l
  reverse.l
  file.l
  memory.l 
  gadget.l
  nm_clip.l
  type.l
  name$
  c64.l
  
  x_cut.l[5]
  y_cut.l[5]
  w_cut.l[5]
  h_cut.l[5]
  
  pos_screenshot.l
  
  rotate.l
  
  c64pal.l[32]
  
  
  
EndStructure

Structure plots
  
  nm_image.l
  x.l[2048]
  y.l[2048]
  nm_plots.l
  position.l
  on.l
  
EndStructure

Structure masks
  
  nm_image.l
  x.l
  y.f
  nm_sprite.l
  on.l
  gravitation.f
  add.f
  
EndStructure

Global NewList video.loop(), NewList Plots.plots(), NewList masks.masks(), CurrentVideo, nm_clips, scr_shift, mode, video_frame_1, filter, flash, flash_time
Global video_1, video_2, add_gadget_v, key_video, monnitor, giga
Global NewList polygons.polygon(), Dim mline(100), show_part = 1, draw_trans = 0, nm_plots

Global start_x, start_y, mbl_press, polygon_move = -1, type_move, render_mode = 2, plots_stop, show_mode=0, time
Global Dim clips(32,3), nm_cl, tk_cl, fill_r, fill_g, fill_b, fill_wh, fill_bl , border = 1, l_on=1, r_on=1, c_on=1
Global Text$, scroll, text_pos = 1, Dim Text$(128), tk_scroll, nm_scrolls, on_eq, reverse, video_speed = 1
Global CutScreenMode = 0, Dim c64pal.l(64), *screen, auto = 0, loop_nm = 0, loop_max = 3, Dim start_video(16)
Global start_video_nm = 0, go_time = 0, wscr = 800, hscr = 600



start_video(0) = 128
start_video(1) = 121
start_video(2) = 129
start_video(3) = 165;10
start_video(4) = 130;
start_video(5) = 143
start_video(6) = 144


;[ Палитра

Global Dim color.l(16), Dim cl.l(1), *scr_buffer1, *scr_buffer2, nm_releases

color(0)  =   0 |   0 << 8 | 0   << 16 
color(1)  =   0 |   0 << 8 | 180 << 16 
color(2)  = 180 |   0 << 8 | 0   << 16
color(3)  = 180 |   0 << 8 | 180 << 16 
color(4)  =   0 | 178 << 8 | 0   << 16 
color(5)  =   0 | 178 << 8 | 180 << 16
color(6)  = 180 | 178 << 8 | 0   << 16 
color(7)  = 180 | 178 << 8 | 180 << 16 

color(8)  =   0 |   0 << 8 | 0   << 16 
color(9)  =   0 |   0 << 8 | 252 << 16 
color(10) = 252 |   0 << 8 | 0   << 16 
color(11) = 252 |   0 << 8 | 252 << 16 
color(12) =   0 | 254 << 8 | 0   << 16 
color(13) =   0 | 254 << 8 | 252 << 16 
color(14) = 252 | 254 << 8 | 0   << 16 
color(15) = 252 | 254 << 8 | 252 << 16 

;]

Procedure scr2image ( *scr, image)
  
  *scr + scr_shift
  
  StartDrawing( ImageOutput( image ) )
    
    If video()\c64 
      
      For y=0 To 199
        For x=0 To 159
          
          cl = PeekC(*scr+y*160+x) 
          Plot(x*2,199-y, video()\c64pal[ cl & 15 ] ) 
          Plot(x*2+1,199-y, video()\c64pal[ (cl & %11110000) >> 4 ] ) 
          
        Next x
      Next y
      
      
    Else   
      
      For y = 0 To 191
        
        pixelLine = 32 * ((y & $C0) | ((y << 3) & $38) | ((y >> 3) & $07))
        attr      = 6144 + ((y & $F8) << 2)
        
        If filter = 6 : CopyMemory(*scr + pixelLine + 5-Random(5), *scr + pixelLine + 5-Random(5), 32): 
          
        ElseIf filter = 8
          
          CopyMemory(*scr + Random(6912), *scr + Random(6912), Random(128)): 
          
        ElseIf filter = 9
          
          
        EndIf
        
        
        For x = 0 To 31
          
          chr_pixels   =  PeekC(*scr + pixelLine + x) 
          chr_attr     =  PeekC(*scr + attr + x)
          
          Paper = (chr_attr >> 3) & $0F
          ink   = (chr_attr & 7) | (Paper & $08)
          
          Select filter
              
            Case 1;
              
              i1 = ink & %010
              i2 = chr_pixels & %001
              
              ink = (ink & %1100) | (i1 >> 1) | (i2 << 1)
              Paper =  Paper %1101 | (chr_pixels >> 3 & %10) 
              
            Case 2  
              
              ink = ink &%1110 | (chr_pixels >> 3 & 1)
              
            Case 3
              
              ink = (ink & %0111) | ((chr_pixels >> 5) & %1000)
              
            Case 4  
              
              i1 = (ink & %100) >> 3
              i2 = (ink & %001) << 3
              
              ink = (ink & %1010) | i1 | i2
              
            Case 5
              
              i1 = (ink & %100) >> 3
              i2 = (Random(255) & %001) << 3
              
              ink = (ink & %1010) | i1 | i2  
              
            Case 7
              
              Paper = Random(15)
              
          EndSelect
          
          ;If chr_attr & 128 And flash: Swap Paper, ink: EndIf
          
          bit = 128
          For z = 0 To 7
            
            If chr_pixels & bit
              
              Plot( x<<3 + z, y, color( ink )) 
              ;scr_buf( x<<3 + z, y) = color( ink )
              
            Else  
              
              Plot( x<<3 + z, y, color( Paper ))
              ;scr_buf( x<<3 + z, y) = color( Paper )
              
            EndIf
            
            bit >> 1
          Next z 
          
        Next x
        
      Next y
      
    EndIf  
    
  StopDrawing()
  
EndProcedure
  
Procedure AddPolygon(nm, x,y)
  
  AddElement(polygons ())
  
  w = SpriteWidth(nm)
  h = SpriteHeight(nm)
  
  polygons()\x1 = 0
  polygons()\x2 = w
  polygons()\x3 = w
  polygons()\x4 = 0
  
  polygons()\y1 = 0
  polygons()\y2 = 0
  polygons()\y3 = h
  polygons()\y4 = h
  
  polygons()\Sprite = nm
  
  polygons()\xp = x
  polygons()\yp = y
  
  polygons()\on = 1
  
  polygons()\zoom = 1
  
EndProcedure
  
Procedure.l PointCollision(x1, y1, x2,y2, x3, y3,x4,y4, x, y, angle.f, scale.f)
  
  Dim yp.f(3)
  Dim xp.f(3)
  npol = 4
  
  ; xs = x1
  ; ys = y1
  ; 
  ; x1 - xs
  ; y1 - ys
  ; x3 - xs
  ; y3 - ys
  ; 
  ; x2 * scale
  ; x3 * scale
  ; 
  ; y3 * scale
  ; y4 * scale
  ; 
  ; 
  ; xz = x2/2
  ; yz = y3/2
  ; 
  ; xx1 = Cos(angle) * (x1-xz) - Sin(angle) * (y1-yz) 
  ; yy1 = Sin(angle) * (x1-xz) + Cos(angle) * (y1-yz) 
  ; 
  ; xx2 = Cos(angle) * (x2-xz) - Sin(angle) * (y2-yz) 
  ; yy2 = Sin(angle) * (x2-xz) + Cos(angle) * (y2-yz) 
  ; 
  ; xx3 = Cos(angle) * (x3-xz) - Sin(angle) * (y3-yz) 
  ; yy3 = Sin(angle) * (x3-xz) + Cos(angle) * (y3-yz) 
  ; 
  ; xx4 = Cos(angle) * (x4-xz) - Sin(angle) * (y4-yz) 
  ; yy4 = Sin(angle) * (x4-xz) + Cos(angle) * (y4-yz) 
  
  ; xp(0) = xx1 + xs
  ; xp(1) = xx2 + xs
  ; xp(2) = xx3 + xs
  ; xp(3) = xx4 + xs
  ; yp(0) = yy1 + ys
  ; yp(1) = yy2 + ys
  ; yp(2) = yy3 + ys
  ; yp(3) = yy4 + ys
  
  xp(0) = x1 
  xp(1) = x2 
  xp(2) = x3 
  xp(3) = x4 
  yp(0) = y1 
  yp(1) = y2 
  yp(2) = y3 
  yp(3) = y4 
  
  j = npol - 1
  For i = 0 To npol-1 Step 1 
    
    If (((( yp(i) <= y) And (y < yp(j) )) Or ((yp(j) <= y) And (y < yp(i) ))) And (x > (xp(j) - xp(i) ) * (y - yp(i) ) / (yp(j) - yp(i) ) + xp(i) )) :
      c ! 1
    EndIf    
    
    j = i
  Next i
  
  ProcedureReturn c
EndProcedure 
  
Procedure TestCollision(x,y,xp,yp, w)
  
  If x>= xp And x<=xp+w And y>= yp And y<= yp+w
    
    ProcedureReturn 1
    
  EndIf
  
EndProcedure
  
Procedure DrawPolygon(polygon, Sprite, b1, b2, transparent)
  
  SelectElement( polygons(), polygon )
  
  
  Start3D()
    
    Sprite3DBlendingMode(b1, b2)
    TransformSprite3D( Sprite, polygons()\x1*polygons()\zoom, polygons()\y1*polygons()\zoom, 1, polygons()\x2*polygons()\zoom, polygons()\y2*polygons()\zoom, 1, polygons()\x3*polygons()\zoom, polygons()\y3*polygons()\zoom, 1, polygons()\x4*polygons()\zoom, polygons()\y4*polygons()\zoom, 1)
    DisplaySprite3D( Sprite, polygons()\xp, polygons()\yp, transparent )
    
  Stop3D()
  
EndProcedure
  
Procedure DrawPolygonsBorders()
  
  ResetList(polygons())
  
  x = MouseX()
  y = MouseY()
  
  
  If StartDrawing( ScreenOutput() )
      
      nm = 1
      
      While NextElement(polygons())
        
        If PointCollision((polygons()\x1*polygons()\zoom)+polygons()\xp,(polygons()\y1*polygons()\zoom)+polygons()\yp,(polygons()\x2*polygons()\zoom)+polygons()\xp,(polygons()\y2*polygons()\zoom)+polygons()\yp,(polygons()\x3*polygons()\zoom)+polygons()\xp,(polygons()\y3*polygons()\zoom)+polygons()\yp,(polygons()\x4*polygons()\zoom)+polygons()\xp,(polygons()\y4*polygons()\zoom)+polygons()\yp,x,y,0,1)
          
          color = #Green
          
        Else
          
          color = #Red
          
        EndIf
        
        LineXY( (polygons()\x1*polygons()\zoom)+polygons()\xp, polygons()\y1*polygons()\zoom+polygons()\yp, polygons()\x2*polygons()\zoom+polygons()\xp, polygons()\y2*polygons()\zoom+polygons()\yp, color )
        LineXY( (polygons()\x2*polygons()\zoom)+polygons()\xp, polygons()\y2*polygons()\zoom+polygons()\yp, polygons()\x3*polygons()\zoom+polygons()\xp, polygons()\y3*polygons()\zoom+polygons()\yp, color )
        LineXY( (polygons()\x3*polygons()\zoom)+polygons()\xp, polygons()\y3*polygons()\zoom+polygons()\yp, polygons()\x4*polygons()\zoom+polygons()\xp, polygons()\y4*polygons()\zoom+polygons()\yp, color )
        LineXY( (polygons()\x4*polygons()\zoom)+polygons()\xp, polygons()\y4*polygons()\zoom+polygons()\yp, polygons()\x1*polygons()\zoom+polygons()\xp, polygons()\y1*polygons()\zoom+polygons()\yp, color )
        
        color1 = color
        color2 = color
        color3 = color
        color4 = color
        
        If TestCollision(x,y, (polygons()\x1*polygons()\zoom)-4+polygons()\xp, (polygons()\y1*polygons()\zoom)-4+polygons()\yp, #bsize) 
          
          color1 = #blue
          
        ElseIf TestCollision(x,y, (polygons()\x2*polygons()\zoom)-4+polygons()\xp, (polygons()\y2*polygons()\zoom)-4+polygons()\yp, #bsize) 
          
          color2 = #blue
          
        ElseIf TestCollision(x,y, (polygons()\x3*polygons()\zoom)-4+polygons()\xp, (polygons()\y3*polygons()\zoom)-4+polygons()\yp, #bsize) 
          
          color3 = #blue
          
        ElseIf TestCollision(x,y, (polygons()\x4*polygons()\zoom)-4+polygons()\xp, (polygons()\y4*polygons()\zoom)-4+polygons()\yp, #bsize) 
          
          color4 = #blue
          
        EndIf
        
        Box( polygons()\x1*polygons()\zoom+polygons()\xp-4, polygons()\y1*polygons()\zoom+polygons()\yp-4, #bsize, #bsize, color1 )
        Box( polygons()\x2*polygons()\zoom+polygons()\xp-4, polygons()\y2*polygons()\zoom+polygons()\yp-4, #bsize, #bsize, color2 )
        Box( polygons()\x3*polygons()\zoom+polygons()\xp-4, polygons()\y3*polygons()\zoom+polygons()\yp-4, #bsize, #bsize, color3 )
        Box( polygons()\x4*polygons()\zoom+polygons()\xp-4, polygons()\y4*polygons()\zoom+polygons()\yp-4, #bsize, #bsize, color4 )
        
        DrawText( polygons()\x1*polygons()\zoom+polygons()\xp-4, polygons()\y1*polygons()\zoom+polygons()\yp-24, Str( polygons()\Sprite - #left_sprite+1 ) )
        
      Wend
      
    StopDrawing()
    
  EndIf
  
  
EndProcedure
  
Procedure TestMousePoint(x,y)
  
  ResetList(polygons())
  
  While NextElement(polygons())
    
    If TestCollision(x,y, polygons()\x1*polygons()\zoom-4+polygons()\xp, polygons()\y1*polygons()\zoom-4+polygons()\yp, #bsize) 
      
      polygon_move = ListIndex( polygons() )
      ProcedureReturn 1
      Break 
      
    ElseIf TestCollision(x,y, polygons()\x2*polygons()\zoom-4+polygons()\xp, polygons()\y2*polygons()\zoom-4+polygons()\yp, #bsize) 
      
      polygon_move = ListIndex( polygons() )
      ProcedureReturn 2
      Break
      
    ElseIf TestCollision(x,y, polygons()\x3*polygons()\zoom-4+polygons()\xp, polygons()\y3*polygons()\zoom-4+polygons()\yp, #bsize) 
      
      polygon_move = ListIndex( polygons() )
      ProcedureReturn 3
      Break
      
    ElseIf TestCollision(x,y, polygons()\x4*polygons()\zoom-4+polygons()\xp, polygons()\y4*polygons()\zoom-4+polygons()\yp, #bsize) 
      
      polygon_move = ListIndex( polygons() )
      ProcedureReturn 4
      Break
      
    EndIf
    
    
    If PointCollision(polygons()\x1*polygons()\zoom+polygons()\xp,polygons()\y1*polygons()\zoom+polygons()\yp,polygons()\x2*polygons()\zoom+polygons()\xp,polygons()\y2*polygons()\zoom+polygons()\yp,polygons()\x3*polygons()\zoom+polygons()\xp,polygons()\y3*polygons()\zoom+polygons()\yp,polygons()\x4*polygons()\zoom+polygons()\xp,polygons()\y4*polygons()\zoom+polygons()\yp,x,y,0,1)
      
      polygon_move = ListIndex( polygons() ) 
      
      ProcedureReturn 5
      
    EndIf
    
  Wend  
  
  ProcedureReturn 0
  
EndProcedure
  
Procedure PolygonsMove()
  
  SelectElement( polygons(), polygon_move )
  
  x = MouseX()
  y = MouseY()
  
  Select type_move
      
    Case 1: polygons()\x1 - (start_x - x) : polygons()\y1 - (start_y - y)
    Case 2: polygons()\x2 - (start_x - x) : polygons()\y2 - (start_y - y)
    Case 3: polygons()\x3 - (start_x - x) : polygons()\y3 - (start_y - y)
    Case 4: polygons()\x4 - (start_x - x) : polygons()\y4 - (start_y - y)  
    Case 5: polygons()\xp - (start_x - x) : polygons()\yp - (start_y - y)
      
  EndSelect
  
  start_x = x 
  start_y = y
  
EndProcedure
  

  
Procedure LineXYS(x1,y1,x2,xc,yc, radius, spr)
  
  If x1 > x2: Swap x1, x2: EndIf
  
  StartDrawing( SpriteOutput(spr) )
    n = 0
    
    For x=x1 To x2
      
      mline(n) = Point(x,y1)
      n +1
      
    Next x
  StopDrawing()
  
  n = 0
  StartDrawing( ScreenOutput() )
    For x=x1 To x2
      
      ;a = Sqr((x-xc)^2 + (y1-yc)^2) 
      
      v.f = radius / 100 * a
      
      ra = Red(mline(n)) 
      rb = Red(Point(x,y1))
      rc = ((ra*v)/100) + ((rb*(100-v)) / 100)
      
      ga = Green(mline(n)) 
      gb = Green(Point(x,y1))
      gc = ((ga*v)/100) + ((gb*(100-v)) / 100)
      
      ba = Blue(mline(n)) 
      bb = Blue(Point(x,y1))
      bc = ((ba*v)/100) + ((bb*(100-v)) / 100)
      
      Plot(x,y1, RGB(rc,gc,bc))
      n +1
    Next
  StopDrawing()
  
  
EndProcedure
  
Procedure DrawCircle(bcenter_x, bcenter_y, bradi, bfill, sprite2)
  
  bdi = 3 - (bradi << 1)
  bxi = bradi
  byi = 0
  
  ;draw the first octant, until y = x
  While byi <= bxi
    
    LineXYS(bcenter_x - bxi, bcenter_y - byi, bcenter_x + bxi, bcenter_x, bcenter_y, bradi, sprite2)
    LineXYS(bcenter_x - bxi, bcenter_y + byi, bcenter_x + bxi, bcenter_x, bcenter_y, bradi, sprite2)
    
    If bdi >= 0 ;if x changed fill outer octants, n-nw>n-ne and s-sw>s-se
      
      LineXYS(bcenter_x - byi, bcenter_y - bxi, bcenter_x + byi, bcenter_x, bcenter_y,radius, sprite2)
      LineXYS(bcenter_x - byi, bcenter_y + bxi, bcenter_x + byi, bcenter_x, bcenter_y,radius, sprite2)
      
    EndIf
    
    
    
    If bdi < 0
      bdi = bdi + (byi << 2) + 6
    Else
      bdi = bdi + (byi - bxi) << 2 + 10
      bxi = bxi - 1 ;move left
    EndIf
    byi = byi + 1 ;always move up
  Wend
  
EndProcedure
  
Procedure ScrRender( Sprite)
  
  If StartDrawing( SpriteOutput( Sprite ) ) 
      
      DrawImage(ImageID(0), -video()\x_cut[Sprite - #left_sprite], -video()\y_cut[Sprite - #left_sprite]) 
      
      ; DrawImage(ImageID(0), 0, 0) 
      
      
    StopDrawing()
  EndIf
  
EndProcedure  

Procedure SprPreResize()
  
  For a=0 To 2
    
    CreateSprite(#left_sprite+a, video()\w_cut[a], video()\h_cut[a], #PB_Sprite_Texture)
    ;CreateSprite(#left_sprite+a, 300, 200, #PB_Sprite_Texture)
    CreateSprite3D(#left_sprite+a, #left_sprite+a)
    
  Next a
  
EndProcedure
  
Procedure DrawScreen( video, Speed=1 )
  
  SelectElement( video(), video )
  
  If video()\c64
    
    FileSeek( video()\file, 72+video()\position*32000)
    ReadData( video()\file, *screen , 32000)
    
  Else 
    
    FileSeek( video()\file, video()\position*6912)
    ReadData( video()\file, *screen , 6912)
    
  EndIf
  
  scr2image( *screen, 0 )
  
  If reverse
    
    video()\position - Speed
    
    If video()\position < video()\frame_first: video()\position = video()\frame_last: EndIf
    
  Else  
    
    video()\position + Speed
    
    If video()\position > video()\frame_last: video()\position = video()\frame_first: 
      
      If auto
        
        loop_nm + 1  
        
        If loop_nm > loop_max
          
          loop_nm = 0
          
          
          mode  = 0
          Repeat
            CurrentVideo = Random(nm_clips-1)
          Until CurrentVideo <> nm_clips-1  
          
          loop_max = 2+Random(3)
          
          SelectElement( video(), CurrentVideo )
          SprPreResize()
          
          If video()\c64: loop_max = 2+Random(5): EndIf
          
        EndIf
        
      EndIf
      
      
    EndIf
    
  EndIf
  
EndProcedure
  


Procedure CreateClip( new=0 )
  
  If new=0: 
    
    CopyStructure(@video(), AddElement( video() ), loop): 
    video()\pos_screenshot = video()\position
    
  EndIf
  
  video()\frame_first = video()\sel_start
  video()\frame_last = video()\sel_end
  video()\lenght = video()\sel_end-video()\sel_start + 1
  
  ;video()\memory = AllocateMemory( 6912 * 3 )
  
  video()\type = #clip
  
  
  
  
  ;FileSeek( video()\file, video()\position * 6912 )
  ;ReadData( video()\file, video()\memory + 6912, 6912 )
  ;scr2image( video()\memory + 6912, 0 )
  
  
  
EndProcedure
  
Procedure OpenClips(name$ = "clips.zvj")
  
  If ReadFile(0, name$)
    
    While Eof(0) = 0
      
      AddElement( video() )
      
      CurrentVideo = ListIndex( video() )
      
      video()\file$ = ReadString(0)
      
      video()\sel_start = Val(ReadString(0))
      
      video()\sel_end = Val(ReadString(0))
      video()\h_flip = Val(ReadString(0))
      video()\v_flip = Val(ReadString(0))
      video()\reverse = Val(ReadString(0))
      video()\name$ = ReadString(0)
      video()\pos_screenshot = Val(ReadString(0))
      video()\lenght = video()\frame_last - video()\frame_first
      video()\position = video()\pos_screenshot
      cut$ = ReadString(0)
      video()\c64 = Val(ReadString(0))
      ReadString(0)
      ReadString(0)
      ReadString(0)
      
      ;  Debug video()\file$ +" "+ Str(video()\c64) +" "+ cut$
      
      n = 1     
      For a=0 To 2
        
        video()\x_cut[a] = Val( StringField(cut$, n, ",")  )
        n+1
        video()\y_cut[a] = Val( StringField(cut$, n, ",")  )
        n+1
        video()\w_cut[a] = Val( StringField(cut$, n, ",")  )
        n+1
        If video()\w_cut[a] = 0: video()\w_cut[a] = 256: EndIf
        video()\h_cut[a] = Val( StringField(cut$, n, ",")  )
        n+1
        If video()\h_cut[a] = 0: video()\h_cut[a] = 192: EndIf
        
      Next
      
      
      
      video()\file = ReadFile(#PB_Any, GetCurrentDirectory() + video()\file$)
      
      If video()\c64 
        
        FileSeek(video()\file, 8)
        
        For c=0 To 15
          
          video()\c64pal[c] = ReadLong(video()\file)
          
        Next c  
        
      EndIf
      
      CreateClip( 1 )
      nm_clips + 1
      
    Wend
    
    CloseFile(0)
    
  EndIf
  
EndProcedure
  
Procedure SaveClips(name$ = "clips.zvj")
  
  If CreateFile(0, name$)
    
    ResetList(video())
    
    While NextElement(video())
      
      Debug video()\file$ +" "+ Str(video()\c64) +" "+ cut$
      
      WriteStringN(0, video()\file$)
      WriteStringN(0, Str(video()\sel_start))
      WriteStringN(0, Str(video()\sel_end))
      WriteStringN(0, Str(video()\h_flip))
      WriteStringN(0, Str(video()\v_flip))
      WriteStringN(0, Str(video()\reverse))
      WriteStringN(0, video()\name$)
      WriteStringN(0, Str(video()\pos_screenshot))
      
      
      z$ = Str(video()\x_cut[0])+","+Str(video()\y_cut[0])+","+Str(video()\w_cut[0])+","+Str(video()\h_cut[0])
      z$ + ","+Str(video()\x_cut[1])+","+Str(video()\y_cut[1])+","+Str(video()\w_cut[1])+","+Str(video()\h_cut[1])
      z$ + ","+ Str(video()\x_cut[2])+","+Str(video()\y_cut[2])+","+Str(video()\w_cut[2])+","+Str(video()\h_cut[2])
      
      WriteStringN(0, z$)
      WriteStringN(0, Str(video()\c64))
      WriteStringN(0, "")
      WriteStringN(0, "")
      WriteStringN(0, "")
      
      
      
    Wend
    
    CloseFile(0)
    
  EndIf
  
EndProcedure
  
Procedure PrintInfo()
  
  Shared tm, frames, fps
  
  If ElapsedMilliseconds() - tm < 1000
    
    frames + 1
    
  Else  
    
    go_time + 1
    fps = frames
    frames = 0
    tm = ElapsedMilliseconds()
    
  EndIf
  
  StartDrawing( ScreenOutput() )
    
    If video()\h_flip 
      
      off$ = "off"
      
    Else  
      
      off$ = "on"
      
    EndIf
    
    If border:
      DrawText(0,0, "clip: " + Str(CurrentVideo) + " fps: " + Str(fps) + " auto: "+Str(auto)+"/"+Str(loop_nm)+"/"+Str(loop_max) + video()\file$+" " + Str( video()\h_flip ))
    EndIf
    
  StopDrawing()
  
EndProcedure

Procedure SetPolygonSprite(index, Sprite)
  
  SelectElement( polygons(), index )
  polygons()\Sprite = Sprite
  
EndProcedure

Procedure DrawColorsBox()
  
  If fill_r Or fill_g Or fill_b
    
    color = RGB(fill_r, fill_g, fill_b)
    
  ElseIf fill_bl 
    
    color = $010101
    
  ElseIf fill_wh
    
    color = #white
    
  EndIf
  
  If color
    
    If StartDrawing( SpriteOutput( #left_sprite ) )
        
        Box(0,0, SpriteWidth(#left_sprite), SpriteHeight(#left_sprite), color )
        
      StopDrawing()
    EndIf
    
    If StartDrawing( SpriteOutput( #right_sprite ) )
        
        Box(0,0, SpriteWidth(#right_sprite), SpriteHeight(#right_sprite), color )
        
      StopDrawing()
    EndIf
    
    
    
    If StartDrawing( SpriteOutput( #center_sprite ) )
        
        Box(0,0, SpriteWidth(#center_sprite), SpriteHeight(#center_sprite), color )
        
      StopDrawing()
    EndIf
    
  EndIf
  
EndProcedure

Procedure SaveState()
  
  CreateFile(0, "save.txt")
  
  ResetList( polygons() )
  
  While NextElement( polygons() )
    
    WriteStringN(0, Str(polygons()\xp))
    WriteStringN(0, Str(polygons()\yp))
    WriteStringN(0, Str(polygons()\x1))
    WriteStringN(0, Str(polygons()\y1))
    WriteStringN(0, Str(polygons()\x2))
    WriteStringN(0, Str(polygons()\y2))
    WriteStringN(0, Str(polygons()\x3))
    WriteStringN(0, Str(polygons()\y3))
    WriteStringN(0, Str(polygons()\x4))
    WriteStringN(0, Str(polygons()\y4))
    WriteStringN(0, StrF(polygons()\zoom))
    
  Wend  
  
  CloseFile(0)  
  
EndProcedure

Procedure LoadState()
  
  ReadFile(0, "save.txt")
  
  ResetList( polygons() )
  
  While NextElement( polygons() )
    
    polygons()\xp = Val(ReadString(0))
    polygons()\yp = Val(ReadString(0))
    polygons()\x1 = Val(ReadString(0))
    polygons()\y1 = Val(ReadString(0))
    polygons()\x2 = Val(ReadString(0))
    polygons()\y2 = Val(ReadString(0))
    polygons()\x3 = Val(ReadString(0))
    polygons()\y3 = Val(ReadString(0))
    polygons()\x4 = Val(ReadString(0))
    polygons()\y4 = Val(ReadString(0))
    polygons()\zoom = ValF(ReadString(0))
    
  Wend  
  
  CloseFile(0)  
  
EndProcedure

Procedure DrawScroll()
  
  Static y
  
  If StartDrawing( SpriteOutput( #left_sprite ) )
      
      DrawingFont( FontID(1) )
      DrawingMode(#PB_2DDrawing_Transparent )
      Box(0,0, SpriteWidth(#left_sprite), SpriteHeight(#left_sprite), color )
      
      For a=0 To 15
        
        s$ = Mid(Text$(tk_scroll), text_pos+a, 1)
        DrawText( SpriteWidth(#left_sprite)/2 - TextWidth(s$)/2 , (-24 - y) + 0+a*24, s$, #white, #Black)
        
      Next
      
    StopDrawing()
  EndIf
  
  If StartDrawing( SpriteOutput( #center_sprite ) )
      
      DrawingFont( FontID(1) )
      DrawingMode(#PB_2DDrawing_Transparent )
      Box(0,0, SpriteWidth(#center_sprite), SpriteHeight(#left_sprite), color )
      
      For a=0 To 15
        
        s$ = Mid(Text$(tk_scroll), text_pos+a, 1)
        DrawText( SpriteWidth(#center_sprite)/2 - TextWidth(s$)/2 , (-24 - y) + 0+a*24, s$, #white, #Black)
        
      Next
      
    StopDrawing()
  EndIf
  
  y + 2
  
  If y = 24: 
    
    y = 0: text_pos+1:
    If text_pos = Len(Text$(tk_scroll)): text_pos = 1: EndIf
    
  EndIf
  
  
EndProcedure

Procedure ParseText()
  
  Repeat
    
    s$ = StringField(Text$, nm_scrolls+1, ">")
    Text$(nm_scrolls) = s$
    
    ;Debug Text$(nm_scrolls)
    
    nm_scrolls + 1
    
  Until s$ = ""
  
  nm_scrolls - 1
  
EndProcedure

Procedure DrawEq()
  
  Static zam, a,c,b,cc,t
  
  
  If StartDrawing( ImageOutput(0)  ) 
      
      Box(0,0,256,192,0)
      
      If zam = 1
        
        cc=c
        b=0
        Repeat 
          
          If b<100:Box(0,160-b, 256, 10, RGB(0, 255, 50)):EndIf      
          If b>90 :Box(0,160-b, 256, 10, RGB(180, 180, 0)):EndIf   
          If b>120:Box(0,160-b, 256, 10, RGB(255, 0, 0)):EndIf 
          
          cc-1:b+15
        Until  cc<=0
        
        t+1
        If t=2:t=0:c-1:EndIf 
        If c=0:zam=0:EndIf 
        
      EndIf
      
      a=Random(11)
      c=a
      
      If a<>0:
        
        b=0
        Repeat 
          
          If b<100:Box(0,160-b, 256, 10, RGB(0, 255, 150)):EndIf      
          If b>90:Box(0,160-b, 256, 10, RGB(255, 255, 0)):EndIf   
          If b>120:Box(0,160-b, 256, 10, RGB(255, 0, 0)):EndIf 
          
          a-1:b+15
          
        Until  a<=0
        zam=1
        
      EndIf
      
    StopDrawing()
    
  EndIf
  
EndProcedure

Procedure drawSelectScreenCut()
  
  
  StartDrawing( ScreenOutput() )
    
    DrawingMode(#PB_2DDrawing_Outlined )
    
    Box( video()\x_cut[CutScreenMode-1] ,  video()\y_cut[CutScreenMode-1] + hscr-200 , video()\w_cut[CutScreenMode-1], video()\h_cut[CutScreenMode-1], #white)
    Box( video()\x_cut[CutScreenMode-1]+1 ,  video()\y_cut[CutScreenMode-1] + 1+ hscr-200, video()\w_cut[CutScreenMode-1], video()\h_cut[CutScreenMode-1], #Black)
    
    DrawText( 0, hscr-200-24, Str(CutScreenMode) )
    
  StopDrawing()
  
EndProcedure

Procedure MoveObjects()
  
  If CutScreenMode
    
    
    If KeyboardPushed(#PB_Key_LeftShift)
      
      If KeyboardPushed(#PB_Key_Left) And video()\w_cut[CutScreenMode-1]>8: video()\w_cut[CutScreenMode-1] - 1: 
        
        CreateSprite(#left_sprite+CutScreenMode-1, video()\w_cut[CutScreenMode-1], video()\h_cut[CutScreenMode-1], #PB_Sprite_Texture)
        CreateSprite3D(#left_sprite+CutScreenMode-1, #left_sprite+CutScreenMode-1)
        
      EndIf
      
      If KeyboardPushed(#PB_Key_Right) And video()\w_cut[CutScreenMode-1]<320: video()\w_cut[CutScreenMode-1] + 1: 
        
        CreateSprite(#left_sprite+CutScreenMode-1, video()\w_cut[CutScreenMode-1], video()\h_cut[CutScreenMode-1], #PB_Sprite_Texture)
        CreateSprite3D(#left_sprite+CutScreenMode-1, #left_sprite+CutScreenMode-1)
        
      EndIf
      
      If KeyboardPushed(#PB_Key_Up) And video()\h_cut[CutScreenMode-1]>8: video()\h_cut[CutScreenMode-1] - 1: 
        
        CreateSprite(#left_sprite+CutScreenMode-1, video()\w_cut[CutScreenMode-1], video()\h_cut[CutScreenMode-1], #PB_Sprite_Texture)
        CreateSprite3D(#left_sprite+CutScreenMode-1, #left_sprite+CutScreenMode-1)
        
      EndIf
      
      If KeyboardPushed(#PB_Key_Down) And video()\h_cut[CutScreenMode-1]<200: video()\h_cut[CutScreenMode-1] + 1: 
        
        CreateSprite(#left_sprite+CutScreenMode-1, video()\w_cut[CutScreenMode-1], video()\h_cut[CutScreenMode-1], #PB_Sprite_Texture)
        CreateSprite3D(#left_sprite+CutScreenMode-1, #left_sprite+CutScreenMode-1)
        
      EndIf
      
    Else  
      
      If KeyboardPushed(#PB_Key_Left): video()\x_cut[CutScreenMode-1] - 1: EndIf
      If KeyboardPushed(#PB_Key_Right): video()\x_cut[CutScreenMode-1] + 1: EndIf
      If KeyboardPushed(#PB_Key_Up): video()\y_cut[CutScreenMode-1] - 1: EndIf
      If KeyboardPushed(#PB_Key_Down): video()\y_cut[CutScreenMode-1] + 1: EndIf
      
    EndIf
    
    If CutScreenMode: drawSelectScreenCut(): EndIf
    
  EndIf
  
  If mbl_press: PolygonsMove(): EndIf
  
EndProcedure



; 128 - 121 - 129 - 130 - 126 - 131 - 104

w = 800
h = 600



wscr = 800
hscr = 600

;OpenWindow(1,0,0,800,600,"",  #PB_Window_BorderLess )
OpenScreen(w,h,32,"ottodix")
;OpenWindedScreen(w,h,32,"ottodix")  
;OpenWindowedScreen( WindowID(1),0,0,800,600,0,0,0,0 )


SetFrameRate(100)
  
CreateImage(0,320,200)
CreateImage(1,320,200)

*screen = AllocateMemory(65000)

OpenClips()

For a=0 To 2
  CreateSprite(#left_sprite+a, video()\w_cut[a], video()\h_cut[a], #PB_Sprite_Texture)
  CreateSprite3D(#left_sprite+a, #left_sprite+a)
Next a

AddPolygon(#left_sprite, 50, 30)
AddPolygon(#center_sprite, 840, 30)
AddPolygon(#right_sprite, 440, 30)

LoadState()


  

  

  
  


ReadFile(0, "text.txt")
Text$ = ReadString(0)
ParseText()
  
LoadFont(1, "Times", 22, #PB_Font_Bold )

LoadSprite(88888, "cursor.png")
TransparentSpriteColor(88888, $FF00FF)

LoadImage(88888, "cursor.png")



Procedure RndVideo()
  
  Repeat
    
    CurrentVideo = Random(nm_clips-1)
    c = CurrentVideo
    ;74, 1, 122, 104, 152, 127, 24, 29, 36, ,4 ,8 ,9 ,24 , , , 
    If c<>74 And c<>1 And c<>122 And c<>104 And c<>152 And c<>127 And c<>24 And c<>29 And c<>36 And c<>4 And c<>8 And c<>9 And c<>29 And c<>87
      
      Break
      
    EndIf  
    
    
  ForEver  
  
EndProcedure  
  

CurrentVideo = 1
  


SelectElement( video(), CurrentVideo )
SprPreResize()
  
;CallDebugger

auto = 0

CutScreenMode = 1

Repeat
  
  ;Delay(10)
  
  ;WindowEvent()
  
  ExamineKeyboard()
  ExamineMouse()
  
  If KeyboardPushed(#PB_Key_1) : fill_r ! 255 : EndIf
  If KeyboardPushed(#PB_Key_2) : fill_g ! 255 : EndIf
  If KeyboardPushed(#PB_Key_3) : fill_b ! 255 : EndIf
  If KeyboardPushed(#PB_Key_4) : fill_bl ! 255 : EndIf
  If KeyboardPushed(#PB_Key_5) : fill_wh ! 255 : EndIf  
  
  
  
  
  FlipBuffers()
  
  
  
  
  x = MouseX() 
  y = MouseY()
  
  ClearScreen(#Black)
  
  
  
  
  If mbl_press = 0  And MouseButton(#PB_MouseButton_Left)    
    
    type_move = TestMousePoint(x,y)
    
    If type_move 
      
      mbl_press = 1
      start_x = x 
      start_y = y
      
    EndIf
  EndIf   
  
  If  mbl_press And MouseButton(#PB_MouseButton_Left)  = 0
    
    mbl_press = 0 
    
  EndIf     
  
  
  
  
  
  
  
  
  If KeyboardPushed(#PB_Key_Z) And mbl_press And type_move = 5: 
    
    SelectElement(polygons(), polygon_move)
    If polygons()\zoom > 0.2: polygons()\zoom - 0.01: EndIf
    
  EndIf
  
  If KeyboardPushed(#PB_Key_X) And mbl_press And type_move = 5:
    
    SelectElement(polygons(), polygon_move):
    If polygons()\zoom < 10: polygons()\zoom + 0.01: EndIf
    
  EndIf  
  
  
  
  If KeyboardReleased(#PB_Key_O): 
    
    CurrentVideo - 1
    If CurrentVideo < 0: CurrentVideo = nm_clips-1: EndIf
    mode = 0
    SelectElement( video(), CurrentVideo )
    
    SprPreResize()
    
  EndIf
  
  If KeyboardReleased(#PB_Key_P): 
    
    CurrentVideo + 1
    If CurrentVideo = nm_clips: CurrentVideo = 0: EndIf
    mode = 0
    SelectElement( video(), CurrentVideo )
    
    SprPreResize()
    
  EndIf
  
  
  
  
  
  
  
  If KeyboardReleased(#PB_Key_Escape): SaveState(): SaveClips(): 
    End: 
  EndIf
  
  
  
  
  
  
  
  
  
  
  If mode:
    
    SelectElement( video(), CurrentVideo )
    DrawScreen(CurrentVideo, video_speed): If on_eq: DrawEq(): EndIf
    ScrRender(#left_sprite)
    
    ;SelectElement( video(), CurrentVideo2 )
    DrawScreen(CurrentVideo2, video_speed): If on_eq: DrawEq(): EndIf
    ScrRender(#center_sprite)
    
    DrawScreen(CurrentVideo3, video_speed): If on_eq: DrawEq(): EndIf
    ScrRender(#right_sprite)
    
  Else  
    DrawScreen(CurrentVideo, video_speed)
    
    If on_eq: DrawEq(): EndIf
    
    ScrRender(#left_sprite)
    ScrRender(#center_sprite)
    ScrRender(#right_sprite)
  EndIf
  
  
  
  
  
  
  If scroll: DrawScroll(): EndIf
  
  DrawColorsBox()
  
  If l_on: DrawPolygon( 0, #left_sprite,  5,6,255 ): EndIf
  If c_on: DrawPolygon( 1, #center_sprite,5,6,255 ): EndIf
  If r_on:  DrawPolygon( 2, #right_sprite, 5,6,255 ): EndIf
  ;EndIf
  
  
  
  If border = 1: DrawPolygonsBorders(): EndIf
  
  ;If rnd_c=0:
  ;  fill_r = 0: fill_g = 0: fill_b = 0: fill_wh = 0: fill_bl = 0 ;: EndIf
  ;EndIf
  
  
  
  If KeyboardPushed(#PB_Key_F1) : SetFrameRate(10) : EndIf
  If KeyboardPushed(#PB_Key_F2) : SetFrameRate(20) : EndIf
  If KeyboardPushed(#PB_Key_F3) : SetFrameRate(30): EndIf
  If KeyboardPushed(#PB_Key_F4) : SetFrameRate(40): EndIf
  If KeyboardPushed(#PB_Key_F5) : SetFrameRate(50): EndIf
  If KeyboardPushed(#PB_Key_F6) : SetFrameRate(60): EndIf
  If KeyboardPushed(#PB_Key_F7) : SetFrameRate(70): EndIf
  If KeyboardPushed(#PB_Key_F8) : SetFrameRate(80): EndIf
  If KeyboardPushed(#PB_Key_F9) : SetFrameRate(90): EndIf
  If KeyboardPushed(#PB_Key_F10) : SetFrameRate(100): EndIf
  
  If KeyboardReleased(#PB_Key_Q) : l_on ! 1 : EndIf
  If KeyboardReleased(#PB_Key_W) : c_on ! 1 : EndIf
  If KeyboardReleased(#PB_Key_E) : r_on ! 1 : EndIf
  
  
  
  If KeyboardReleased(#PB_Key_S) : scroll = 0 : EndIf
  If KeyboardReleased(#PB_Key_Space) : scroll ! 1: 
    
    
    
    
    If scroll = 0:
      
      mode  = 0
      RndVideo()
      
      SelectElement( video(), CurrentVideo )
      SprPreResize()
      
    Else
      
      tk_scroll + 1 : text_pos = 1
      
      If tk_scroll = nm_scrolls: tk_scroll=0: EndIf: 
      
      
    EndIf
    
  EndIf
  
  If KeyboardReleased(#PB_Key_R) : reverse ! 1 : EndIf
  If KeyboardReleased(#PB_Key_Return) : on_eq ! 1 : EndIf
  If KeyboardReleased(#PB_Key_B): border ! 1: EndIf
  
  If KeyboardReleased(#PB_Key_L) : CutScreenMode = (CutScreenMode + 1) & 3 : EndIf
  
  
  If KeyboardPushed(#PB_Key_6): 
    
    If rnd_c = 0: 
      
      fill_r = Random(255): fill_g = Random(255): fill_b = Random(255): 
      
    EndIf
    
    rnd_c = 1
  Else
    rnd_c = 0
  EndIf
  
  
  
  
  If KeyboardReleased(#PB_Key_N): 
    
    auto ! 1
    
  EndIf
  
  If KeyboardReleased(#PB_Key_7): 
    
    scroll = 0
    
    mode  = 0
    RndVideo()  
    
    SelectElement( video(), CurrentVideo )
    SprPreResize()
    
  EndIf
  
  If KeyboardReleased(#PB_Key_0): 
    
    mode  =1
    
    RndVideo() 
    
    SelectElement( video(), CurrentVideo )
    CreateSprite(#left_sprite+0, video()\w_cut[0], video()\h_cut[0], #PB_Sprite_Texture)
    CreateSprite3D(#left_sprite+0, #left_sprite+0)
    
    Repeat
      CurrentVideo2 = Random(nm_clips-1)
    Until CurrentVideo2 <> nm_clips-1  
    
    SelectElement( video(), CurrentVideo2 )
    CreateSprite(#left_sprite+2, video()\w_cut[2], video()\h_cut[2], #PB_Sprite_Texture)
    CreateSprite3D(#left_sprite+2, #left_sprite+2)
    
    ;CurrentVideo3 = Random(nm_clips-1)
    
    ; Until CurrentVideo<>CurrentVideo2 And CurrentVideo2<>CurrentVideo3
    
  EndIf
  
  
  If CutScreenMode
    StartDrawing(ScreenOutput()): DrawImage(ImageID(0), 0,hscr-192-8, 320,200): StopDrawing()
  EndIf
  
  MoveObjects()
  
  PrintInfo() 
  
  If border: DisplayTransparentSprite(88888, x, y): EndIf
  
  
  
  fill_r = 0: fill_g = 0: fill_b = 0: fill_wh = 0: fill_bl = 0 ;: EndIf
  
ForEver
  




Re: PB on Mac OS... strange bugs?

Posted: Wed Feb 06, 2013 9:25 pm
by zxtunes.com
This software used for Concert Show our music band (mapping on LED screen, banners etc).

Image

Re: PB on Mac OS... strange bugs?

Posted: Wed Feb 06, 2013 9:42 pm
by c4s
zxtunes.com wrote:Mac OS version is not aware of colors!
# white, # red, # blue, etc.
These are not official PureBasic color constants (note the missing "#PB_" at the beginning) but from Windows. You can easily solve this with something like:

Code: Select all

CompilerIf #PB_Compiler_OS <> #PB_OS_Windows
	#Black = $000000
	#White = $FFFFFF
	; ...
CompilerEndIf
zxtunes.com wrote:Files no longer work. It was found that the variable ReadFile file pointer must be Q, and not L!
No, I think this should be I.


I don't know what to say about the other issues you've mentioned...

Re: PB on Mac OS... strange bugs?

Posted: Wed Feb 06, 2013 11:22 pm
by jesperbrannmark
Be a bit careful with 32/64 bit versions (I was running 32 bit on pc and had different datatypes that was working fine for 32 bit... then i moved to mac and installed 64 bit and got headache until i switched over to 32 bit there as well)

Re: PB on Mac OS... strange bugs?

Posted: Fri Feb 08, 2013 12:56 am
by kenmo
Yes, the first thing many people notice on Mac is the color constants are missing... this is because they are technically included with all the Windows OS constants, not as PB constants!

Just put this in your code (compiles on Windows, no need to check #PB_Compiler_OS):

Code: Select all

#White   = $FFFFFF
#Black   = $000000
#Red     = $0000FF
#Green   = $00FF00
#Blue    = $FF0000
#Cyan    = $FFFF00
#Magenta = $FF00FF
#Yellow  = $00FFFF
#Gray    = $808080
About ReadFile() etc... you should be using type i (INTEGER) not LONG or QUAD... This is because you are using the 64-bit version so pointers will be 64-bit, not a 32-bit long, this is the same across all OS's. Check out freak's post: http://www.purebasic.fr/blog/?p=42

Your code runs 20x slower? :shock: I know 2DDrawing runs 2-4 times slower on Mac than Windows for me, but Sprite and Sprite3D seem to run fine at 60 FPS. ClearScreen() works fine for me too. Is the debugger and purifier off?

"Cannot save source file" probably has to do with program privileges... I know on Windows 7, if I don't run PB with administrator rights, it will complain that I can't save edited Example files, because it doesn't have write access (to Program Files/PureBasic/Examples or similar)... at least I think that's the reason.

Check out this post too by WilliamL: http://www.purebasic.fr/english/viewtop ... 19&t=45613