[4.31 PowerPC] Executable works incorrectly

Mac OSX specific forum
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

[4.31 PowerPC] Executable works incorrectly

Post by LCD »

I created a multiplatform utility. It convert Sinclair ZX Spectrum Emulator TZX files to TAP format, which is supported by the real machine, where I use it on SD Cards. The utility works excellent under Windows and Linux, but on MacOS (PPC) it crashes at exit and shows other strange behaviour. If I compile if directly, it seems to work normal, except from "no reaction" at exit, but if I create a executable, it opens a console (?) and if mouse cursor hovers over SplitterGadgets, the cursor won't change.
Any idea?
I have a OS-X 10.x iMac 450 Mhz at moment, but today I will recieve a newer eMac

Code: Select all

version$="0.13"
directory$=GetCurrentDirectory()

Global *Buffer=AllocateMemory(65536)
Procedure.s GetFileName(Filename$); Without suffixes
  len=Len(Filename$):Pos=len
  For a=1 To len
    If Mid(Filename$,a,1)="."
      Pos=a
    EndIf
  Next a
  ProcedureReturn Left(Filename$,Pos-1)
EndProcedure
Procedure TZX2TAP(Filename$)
  Shared Report
  Out$=GetFileName(Filename$)+".tap"
  error=0
  fileIn=OpenFile(#PB_Any,Filename$)
  If FileSize(Out$)<1
    fileout=CreateFile(#PB_Any,Out$)
    ReadData(fileIn,*Buffer,10)
    ID$=PeekS(*Buffer,7)
    If ID$="ZXTape!" And PeekB(*Buffer+7)&$FF=$1A
      Repeat
        id=ReadByte(fileIn)&255
        Select id
          Case $10
            pause=ReadWord(fileIn)&$FFFF
            length=ReadWord(fileIn)&$FFFF
            ReadData(fileIn,*Buffer,length)
            WriteWord(fileout,length)
            WriteData(fileout,*Buffer,length)
          Case $11
            Pilot=ReadWord(fileIn)&$FFFF
            Sync0=ReadWord(fileIn)&$FFFF
            Sync1=ReadWord(fileIn)&$FFFF
            Pulse0=ReadWord(fileIn)&$FFFF
            Pulse1=ReadWord(fileIn)&$FFFF
            Tone=ReadWord(fileIn)&$FFFF
            lastbits=ReadByte(fileIn)&255
            pause=ReadWord(fileIn)&$FFFF
            length=ReadWord(fileIn)&$FFFF+ReadByte(fileIn)<<16
            If length>65535
              length=65535
              AddGadgetItem(Report,-1,Out$+": size over 65535 bytes cannot be saved in TAP")
            EndIf
            ReadData(fileIn,*Buffer,length)
            WriteWord(fileout,length)
            WriteData(fileout,*Buffer,length)
          Case $12 To $13,$15 To $1F
            error=1
            error$="Unsupported!"
            AddGadgetItem(Report,-1,Out$+": Unsupported block found ($"+Hex(id)+")")
          Case $14
            Pulse0=ReadWord(fileIn)&$FFFF
            Pulse1=ReadWord(fileIn)&$FFFF
            lastbits=ReadByte(fileIn)&255
            pause=ReadWord(fileIn)&$FFFF
            length=ReadWord(fileIn)&$FFFF+ReadByte(fileIn)<<16
            If length>65535
              length=65535
              AddGadgetItem(Report,-1,Out$+": size over 65535 bytes cannot be saved in TAP")
            EndIf
            ReadData(fileIn,*Buffer,length)
            WriteWord(fileout,length)
            WriteData(fileout,*Buffer,length)
          Case $20
            ReadWord(fileIn)
          Case $21,$30
            length=ReadByte(fileIn)&255
            ReadData(fileIn,*Buffer,length)
            text$=PeekS(*Buffer,length)
          Case $22 To $29
          Case $2A
            ReadLong(fileIn)
          Case $31
            pause=ReadByte(fileIn)&255
            length=ReadByte(fileIn)&255
            ReadData(fileIn,*Buffer,length)
            text$=PeekS(*Buffer,length)
          Case $32
            length=ReadWord(fileIn)&$FFFF
            ReadData(fileIn,*Buffer,length)
            text$=PeekS(*Buffer,length)
          Case $33
            Infos=ReadByte(fileIn)&$FF
            ReadData(fileIn,*Buffer,Infos*3)
        EndSelect
      Until Eof(fileIn) Or error
      CloseFile(fileout)
    EndIf
  EndIf
  CloseFile(fileIn)
EndProcedure
CompilerSelect #PB_Compiler_OS ;{
  CompilerCase #PB_OS_Linux
    sys$="Tux_"
  CompilerCase #PB_OS_MacOS
    sys$="Mac_"
  CompilerCase #PB_OS_Windows
    sys$="Win_"
CompilerEndSelect ;}

window=OpenWindow(#PB_Any,0,0,1021,700,sys$+"TZX2TAP v. "+version$+" Written in 2009 by LCD",#PB_Window_ScreenCentered|#PB_Window_SystemMenu |#PB_Window_MinimizeGadget |#PB_Window_SizeGadget)
CompilerIf #PB_Compiler_OS=#PB_OS_Windows ;{
  SmartWindowRefresh(window,1)
CompilerEndIf ;}

TZXDirs=ExplorerTreeGadget(#PB_Any,0,0,200,500,directory$, #PB_Explorer_AlwaysShowSelection |#PB_Explorer_NoFiles |#PB_Explorer_NoDriveRequester |#PB_Explorer_AutoSort)
TZXFiles=ExplorerListGadget(#PB_Any,200,0,720,500, directory$+"*.tzx",#PB_Explorer_AlwaysShowSelection |#PB_Explorer_MultiSelect |#PB_Explorer_GridLines |#PB_Explorer_FullRowSelect |#PB_Explorer_NoFolders |#PB_Explorer_NoParentFolder |#PB_Explorer_NoDirectoryChange |#PB_Explorer_NoDriveRequester |#PB_Explorer_AutoSort)
Report=EditorGadget(#PB_Any,0,500,920,200,#PB_Editor_ReadOnly)
splitter1=SplitterGadget(#PB_Any,0,0,920,500,TZXDirs,TZXFiles,#PB_Splitter_Vertical |#PB_Splitter_Separator)
splitter2=SplitterGadget(#PB_Any,0,0,920,700,splitter1,Report,#PB_Splitter_Separator)
ConvertButton=ButtonGadget(#PB_Any,920,0,100,19,"Convert to TAP")

Repeat
wwe=WaitWindowEvent()
If wwe=#PB_Event_Gadget;{
  Select EventGadget()
    Case TZXDirs
      SetGadgetText(TZXFiles,GetGadgetText(TZXDirs))
    Case ConvertButton
      Gosub conversion
  EndSelect ;}
ElseIf wwe=#PB_Event_SizeWindow ;{
  sizex=WindowWidth(window)
  sizey=WindowHeight(window)
  ResizeGadget(splitter2,#PB_Ignore,#PB_Ignore,sizex-101,sizey)
  ResizeGadget(ConvertButton,sizex-100,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndIf ;}
Until wwe=#PB_Event_CloseWindow
End

conversion: ;{
ClearGadgetItems(Report)
HideGadget(TZXFiles,1)
For a=0 To CountGadgetItems(TZXFiles)-1
  dir$=GetGadgetText(TZXFiles)
  If GetGadgetItemState(TZXFiles,a)&#PB_Explorer_Selected
    Filename$=GetGadgetItemText(TZXFiles,a,0)
    ext$=LCase(GetExtensionPart(Filename$))
    If ext$="tzx"
      fullpath$=dir$+Filename$
      Debug fullpath$
      TZX2TAP(fullpath$)
      AddGadgetItem(Report,-1,Filename$)
    EndIf
  EndIf
Next a
HideGadget(TZXFiles,0)
Return ;}
Maybe it is a PB bug, but maybe I made a mistake.
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: [4.31 PowerPC] Executable works incorrectly

Post by lexvictory »

LCD wrote:but if I create a executable, it opens a console (?)
When you create the executable, add ".app" to the end of the name. That way it creates a bundle which will not show the console
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Re: [4.31 PowerPC] Executable works incorrectly

Post by LCD »

lexvictory wrote:
LCD wrote:but if I create a executable, it opens a console (?)
When you create the executable, add ".app" to the end of the name. That way it creates a bundle which will not show the console
I own a mac, but my primary platform is Windows/ReactOS, so I did not knew that. Thank you!!!
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Post Reply