Author Topic: New issues with 0.2.3  (Read 4590 times)

0 Members and 3 Guests are viewing this topic.

jcfuller

  • Guest
New issues with 0.2.3
« on: July 17, 2019, 06:44:31 AM »
Charles,
  My big test app appears fine now but still issues.
Did you mistakenly not change the version?
Now I have two 0.2.3 versions both with different issues which makes it hard to test and report.
I always change my version numbers for even the most minor fixes.

Attached works fine with 0.2.2

James

Charles Pegge

  • Guest
Re: New issues with 0.2.3
« Reply #1 on: July 17, 2019, 09:48:16 AM »
James,

Thanks for your code. I've fixed the problem now. Earlier 0.2.3 are toast, and 0.2.4 is soon to arrive.

Brian Alvarez

  • Guest
Re: New issues with 0.2.3
« Reply #2 on: July 22, 2019, 11:42:46 PM »
In my tests, this compiles and runs fine.

Brian Alvarez

  • Guest
Re: New issues with 0.2.3
« Reply #3 on: July 23, 2019, 01:05:29 AM »
I need help with this one though....

Code:
Code: [Select]
% SND_SYNC   = 0
% SND_RESOURCE = 262148


DECLARE FUNCTION SNDPLAYSOUND LIB "WINMM.DLL" ALIAS "sndPlaySoundA" (azsSound AS ASCIIZ, BYVAL Opts AS DWORD) AS INT
DECLARE FUNCTION PBMAIN() AS INT

FUNCTION PBMAIN() AS INT
   IF SNDPLAYSOUND(bycopy "WAV0001", SND_RESOURCE OR SND_SYNC) THEN
      print "Sound played"
   ELSE
      print "Could not play sound"
   END IF
END FUNCTION

PBMAIN() ' invoke entry point

Resource:
Code: [Select]
WAV0001 WAVE "C:\\executing.wav"
Also tried SOUND instead of WAVE.

Compiles fine, also resources. Resource link OK, Runs OK... but takes a long time, no sound and prints: Could not play sound

WAV file attached.

Charles Pegge

  • Guest
Re: New issues with 0.2.3
« Reply #4 on: July 23, 2019, 01:36:49 AM »
Hi Brian,

It plays directly. The resource thing may be obsolete:

https://docs.microsoft.com/en-us/previous-versions/dd798676(v%3Dvs.85)

Code: [Select]
% SND_SYNC   = 0
% SND_RESOURCE = 262148


DECLARE FUNCTION SNDPLAYSOUND LIB "WINMM.DLL" ALIAS "sndPlaySoundA" (azsSound AS ASCIIZ, BYVAL Opts AS DWORD) AS INT
DECLARE FUNCTION PBMAIN() AS INT

FUNCTION PBMAIN() AS INT
   'IF SNDPLAYSOUND(bycopy "WAV0001", SND_RESOURCE OR SND_SYNC) THEN
   IF SNDPLAYSOUND(bycopy "executing.wav", SND_SYNC) THEN
      print "Sound played"
   ELSE
      print "Could not play sound"
   END IF
END FUNCTION

PBMAIN() ' invoke entry point

Brian Alvarez

  • Guest
Re: New issues with 0.2.3
« Reply #5 on: July 23, 2019, 02:09:47 AM »
Code: [Select]
IF SNDPLAYSOUND(bycopy "executing.wav", SND_SYNC) THEN
Nope... doesnt play. :(

Does it play on your side?
« Last Edit: July 23, 2019, 02:22:37 AM by Brian Alvarez »

Arnold

  • Guest
Re: New issues with 0.2.3
« Reply #6 on: July 23, 2019, 03:43:47 AM »
With version 0.2.4 the app plays "Executing script" and there is a message: "Sound played". I was surprised that there is also the message "Sound played" if I rename executing.wav or if the file does not exist at all. But the docs indicate that the function plays the default sound then if possible. This was the case with my system.
 

Charles Pegge

  • Guest
Re: New issues with 0.2.3
« Reply #7 on: July 23, 2019, 03:56:07 AM »
I've done some deep digging:

Using ResEdit, I found the first letter of the resource name was omitted by GoRc.
This may be a bug caused by user-defined types (WAVE).

So I used this resource script (with "executing.wav" in the cureent directory):
Code: [Select]
  // TEST
  uWAV0001 WAVE c:executing.wav

resource linkage with tlink.bat:
Code: [Select]
..\..\tools\gorc /r t.rc
..\..\tools\linkres2exe t.res t.exe
pause

This now works:
ps: also works with rtl64
Code: [Select]
$filename "t.exe"
uses rtl32
% SND_SYNC   = 0
% SND_RESOURCE = 262148 '0x40004

DECLARE FUNCTION PLAYSOUND LIB "WINMM.DLL" ALIAS "PlaySoundA" (azsSound AS ASCIIZ, BYVAL hModule as SYS, BYVAL  Opts AS DWORD) AS INT
DECLARE FUNCTION PBMAIN() AS INT

FUNCTION PBMAIN() AS INT
   sys h=GetModuleHandle(0)
   IF PLAYSOUND("WAV0001", h, SND_RESOURCE OR SND_SYNC) THEN
      print "Sound played"
   ELSE
      print "Could not play sound"
   END IF
END FUNCTION
« Last Edit: July 23, 2019, 04:20:20 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: New issues with 0.2.3
« Reply #8 on: July 23, 2019, 06:34:59 AM »
I also tested with our earlier version of GORC and saw the same problem. It only affects user-defined types, and appears consistent in removing the first character of the resource name.

jcfuller

  • Guest
Re: New issues with 0.2.3
« Reply #9 on: July 23, 2019, 09:37:26 AM »
Charles,
  I've been playing with this and cannot get it to work using an ID instead of a string name and RCDATA instead of WAVE.
what is O2 translation of this :
#define MAKEINTRESOURCEA(i)  (LPSTR)((ULONG_PTR)((WORD)(i)))

James


Charles Pegge

  • Guest
Re: New issues with 0.2.3
« Reply #10 on: July 23, 2019, 10:35:22 AM »
Hi James,

It casts an integer as a pseudo string-pointer.

The function being called with such a parameter detects that it is a fake pointer (having a value of less than 64k), and treats it as an equate.

Terrible hack to save on system calls!

in o2, it is sufficient to cast parameter i as a char*.

Ensure that i is an int or dword so that it has its upper 16 bits null. It may need to be a sys type for 64bit use.

 (char*) i

Code: [Select]
function f(char*s){}
sys i
#show f( (char*) i )

jcfuller

  • Guest
Re: New issues with 0.2.3
« Reply #11 on: July 23, 2019, 10:55:22 AM »
Charles,
  The test code should really not work. You need both the resource type and the resource ID (or name).
This is the translated code for a bc9 example.
James

Code: [Select]
void PlayRcSound (HINSTANCE  hInst, char* SndName)
{
    HRSRC    hr = {0};
    HGLOBAL  hg = {0};
    LPVOID   lpSndData = {0};
    hr = FindResource( hInst, SndName, RT_RCDATA);
    if(hr != 0 )
    {
        hg = LoadResource( hInst, hr);
        if(hg != 0 )
        {
            lpSndData = LockResource( hg);
            if(lpSndData != 0 )
            {
                PlaySound((LPCTSTR)lpSndData, 0, SND_MEMORY);
                return;
            }
        }
    }
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM  wParam, LPARAM  lParam)
{
    if(Msg == WM_COMMAND )
    {
        if(LOWORD(wParam) == ID_Button1 )
        {
            PlayRcSound(hInstance, MAKEINTRESOURCE(12345));
        }
        goto L1001;
    }
    if(Msg == WM_DESTROY )
    {
        PostQuitMessage(0);
        return 0;
    }
L1001:
    ;
    return DefWindowProc(hWnd, Msg, wParam, lParam);
}


Charles Pegge

  • Guest
Re: New issues with 0.2.3
« Reply #12 on: July 23, 2019, 11:14:17 AM »
Apparently PlaySound is smart enough to do it all in one line:

https://docs.microsoft.com/en-gb/windows/win32/multimedia/playing-wave-resources


C++
PlaySound("SoundName", hInst, SND_RESOURCE | SND_ASYNC);

Brian Alvarez

  • Guest
Re: New issues with 0.2.3
« Reply #13 on: July 23, 2019, 11:14:45 AM »
Hey guys, I fell asleep last night, thanks for the responses.

No matter what i try i cannot get it to play a sound. I copy paste the code and it doesnt make a sound.
So it must be some of this reasons:

  • how i compile the resources
  • how i link the resources
  • my oxygen's version having an issue (yesterday's version)
  • my stupid antivirus (again)

This is my compilation log (with some notes added after generation):

Code: [Select]
PluriBASIC® 6.0.237326.0 for Oxygen BASIC for Windows

=================STEP 1 / 3 =====================
   COMMANDS:
 EXECUTABLE: C:\Users\Diamante\Documents\PluriBASIC\Oxygen\Exodus.exe (NOTE: Exodus is a custom DLL invoker, works fine)
WORKING DIR: C:\Users\Diamante\Documents\PluriBASIC\Clean
COMMANDLINE: c:\users\diamante\documents\pluribasic\Temp\Sound.o2bas
    TIMEOUT: 300
      TAKEN: 0.61
     OUTPUT:
SUCCESS COMPILING
=================STEP 2 / 3 =====================
 EXECUTABLE: C:\Users\Diamante\Documents\PluriBASIC\Oxygen\GoRC.exe
WORKING DIR: C:\Users\Diamante\Documents\PluriBASIC\Clean
COMMANDLINE: /r "C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.RC"
    TIMEOUT: 300
      TAKEN: 0.02
     OUTPUT:
GoRC.Exe   Version 1.0.2.1  Copyright Jeremy Gordon 1998-2019   info@goprog.com

Warnings ......................

Line 2 of Resource Script (C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.RC):-
An ID was not evaluated and was assumed to be a name:-
AAAAAAAAAAAAA_APPICON  (NOTE: This works, the executable displays the icon correctly in the windows explorer)

Line 4 of Resource Script (C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.RC):-
An ID was not evaluated and was assumed to be a name:-
xWAV0001 (NOTE: I added an x before the name as Charles suggested)

Line 4 of Resource Script (C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.RC):-
A resource type was not recognised and assumed to be user-defined:-
WAVE

Output file: C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.res
=================STEP 3 / 3 =====================
 EXECUTABLE: C:\Users\Diamante\Documents\PluriBASIC\Oxygen\GoRL.exe  (NOTE: I changed the name of the linker to GoRL.exe, i dont remember why, but it works)
WORKING DIR: C:\Users\Diamante\Documents\PluriBASIC\Clean
COMMANDLINE: "C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.RES" "C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.exe"
    TIMEOUT: 300
      TAKEN: 0.02
     OUTPUT: ** no console output **

This is my resource file:
Code: [Select]
AAAAAAAAAAAAA_APPICON  ICON DISCARDABLE "C:\\Users\\Diamante\\Documents\\PluriBASIC\\Clean\\appicon.ico"

xWAV0001 WAVE "C:\\Users\\Diamante\\Documents\\PluriBASIC\\Clean\\executing.wav"

This is my code (With some bells and whistles added by pluribasic):
Code: [Select]
'Generated with PluriBASIC 6.0.237326.0

$ filename "C:\Users\Diamante\Documents\PluriBASIC\Clean\Sound.exe"

uses rtl32
uses console

DIM STRING ¤SYSTEM_UDT_OFFSETS(0)
STRING ¤TMPS = "" ' a temporary string.
DECLARE FUNCTION ¤GetLastError        Lib "Kernel32.dll" Alias "GetLastError" () AS LONG
DECLARE FUNCTION ¤GetAsyncKeyState    Lib "User32.dll"   Alias "GetAsyncKeyState" (ByVal vKey AS LONG) AS short
DECLARE SUB ¤Sleep                    lib "Kernel32.dll" alias "Sleep" (dword mSec)

function ¤INI_QUAD(dword v1, v2) as quad
    quad v = 0
    copy @v+0, @v2, 4
    copy @v+4, @v1, 4
    return v
end function

DECLARE FUNCTION ¤OpenProcess         Lib "KERNEL32.DLL"  Alias "OpenProcess" (ByVal dwDesiredAccess AS DWORD, ByVal bInheritHandle AS LONG, ByVal dwProcessId AS SYS) AS SYS
DECLARE FUNCTION ¤TerminateProcess    Lib "KERNEL32.DLL"  Alias "TerminateProcess" ( ByVal hProcess AS SYS, ByVal uExitCode AS DWORD) AS LONG
DECLARE FUNCTION ¤CloseHandle         Lib "KERNEL32.DLL"  Alias "CloseHandle" (ByVal hObject AS SYS) AS LONG
DECLARE FUNCTION ¤GetCurrentProcessId Lib "KERNEL32.DLL"  Alias "GetCurrentProcessId" () AS SYS

MACRO ¤SET_ERR(n)
    Err.err = n
    Err.erl = Err.erp
END MACRO

MACRO ¤ONERR(l, e)
   Err.err = e
   IF (Err.err>0) THEN
      Err.ers = Err.erp
      Err.erl = l   
      IF Err.Oe1 THEN
         JMP Err.Oe1
      ELSEIF Err.Oe2 THEN
         CALL Err.Oe2
      END IF
   else
      Err.ers = ""
      Err.erl = 0   
   END IF
END MACRO

MACRO ERRCLEAR
    Err.err = 0
    Err.erl = 0
    Err.ers = ""
END MACRO

CLASS ¤SYSERR
    public sys Oe1 = 0
    public sys Oe2 = 0
    public int err = 0
    public int erl = 0
    public string erp = ""
    public string ers = ""
END CLASS

' STARTS PLURIBASIC_PREPARE.BIN
' This code is executed before anything else, if you want to do something after defining other things, see PLURIBASIC_INIT

int ¤i = 0
' STARTS SYSTEM_OPERATORS.BIN

FUNCTION ¤BytOvf(byte b) AS byte
    return b
END FUNCTION

FUNCTION ¤ISTRUE(byval quad v1) AS QUAD   
    IF v1 = 0 then
        return 0
    ELSE
        return -1
    END IF
END FUNCTION

FUNCTION ¤ISFALSE(byval quad v1) AS QUAD
    IF v1 = 0 then
        return -1
    ELSE
        return 0
    END IF
END FUNCTION

FUNCTION ¤NOT(byval quad v1) AS QUAD
    dword w1
    dword w2
    quad r   
    copy @w1, @v1, 4
    copy @w2, @v1+4, 4   
    w1 = not(w1)
    w2 = not(w2)   
    copy @r,   @w1, 4
    copy @r+4, @w2, 4
    return r
END FUNCTION

FUNCTION ¤AND(byval quad v1, v2) as quad
    dword w1
    dword w2
    quad r
    copy @w1, @v1, 4
    copy @w2, @v2, 4   
    w1 = (w1 and w2)   
    copy @r, @w1, 4   
    copy @w1, @v1+4, 4
    copy @w2, @v2+4, 4
    w1 = (w1 and w2)   
    copy @r+4, @w1, 4   
    return r   
end function

FUNCTION ¤OR(byval int v1, v2) as int
    return v1 or v2
end function

'FUNCTION ¤OR(byval quad v1, v2) as quad
'    dword w1
'    dword w2
'    quad r
'    copy @w1, @v1, 4
'    copy @w2, @v2, 4   
'    w1 = (w1 or w2)   
'    copy @r, @w1, 4   
'    copy @w1, @v1+4, 4
'    copy @w2, @v2+4, 4
'    w1 = (w1 or w2)   
'    copy @r+4, @w1, 4   
'    return r   
'end function

FUNCTION ¤IMP(byval quad v1, v2) as quad
    if v1 then return -1
    if v2 then return -1
end function

FUNCTION ¤EQV(byval quad v1, v2) as quad
    if v1=0 then return 0
    if v2=0 then return 0
    return -1
end function

FUNCTION ¤MOD(quad v1, v2) as quad
    return MOD(v1, v2)
end function
' END OF SYSTEM_OPERATORS.BIN
' CONTINUES (12) PLURIBASIC_PREPARE.BIN



#DEF HANDLE SYS






TYPE ¤SYSNMHDR
    hwndFrom AS SYS
    idFrom   AS SYS
    Code     AS DWORD
END TYPE


class ¤SYSF


                             
    FUNCTION CONSTRUCTOR()
    END FUNCTION       
           
END CLASS

new ¤SYSF EXE()


' END OF PLURIBASIC_PREPARE.BIN
' STARTS PLURIBASIC_INIT.BIN
' This code is executed before anything else, if you want to do something before nything else, see PLURIBASIC_PREPARE
' END OF PLURIBASIC_INIT.BIN
' STARTS CALLBACKDATA.BIN
' END OF CALLBACKDATA.BIN


DECLARE FUNCTION PBMAIN() AS INT


' Initializes various things in the script.
FUNCTION PluriBASIC_Initialize() AS LONG
END FUNCTION

DECLARE FUNCTION PLAYSOUND LIB "WINMM.DLL" ALIAS "PlaySoundA" (P1 AS ASCIIZ, BYVAL P2 AS SYS, BYVAL P3 AS DWORD) AS INT
FUNCTION PBMAIN() AS INT
   INT ¤RETVAL = 0
   ¤SYSERR Err
   SYS h
        h = GETMODULEHANDLE(0)
       
       IF PLAYSOUND("WAV0001", h, 262148) THEN
          print "Sound played"
       ELSE
          print "Could not play sound"
       END IF       
   RETURN ¤RETVAL
END FUNCTION

PBMAIN() ' invoke entry point

Attached is the generated executable.
« Last Edit: July 23, 2019, 02:31:54 PM by Brian Alvarez »

Charles Pegge

  • Guest
Re: New issues with 0.2.3
« Reply #14 on: July 23, 2019, 11:34:00 AM »
Brian, your binary works on my PC, after unblocking :)