• Welcome to Jose's Read Only Forum 2023.
 

Get prepared to move on.

Started by Patrice Terrier, January 11, 2013, 02:44:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

I found there is a 64bit version of bass.dll.

I am working my way through the code and I am learning much.

BYVAL / BYREF are supported so a lot less editing

James

Patrice Terrier

James--

Yes, there is a 64-bit version of Bass.dll (but so far i have not translated the header to 64-bit yet)
If BC9 is able to convert the existing PB's code correctly to 32-bit C (VS 2010), then that would be already a good step forward and i think i could start from there.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Marc Pons

Hy James

I am also interrested in BC9 , I tested some months ago using BCX with pelleC but the results where not very efficient.

May you post your software here , I've tried in the BCX forum, I was thinking it could be there, but I can't register.

Thank's,  Marc

James C. Fuller

I am still working on a few issues for a new release.
I don't think a PowerBASIC board would be a place for such a package.

One thing that is mandatory for converting PB code to Bc9: Your PowerBASIC code must have #DIM ALL !

I will keep you updated here.

James

Patrice Terrier

#19
James,

This section is not an exclusive PowerBASIC board, you can speak of any programming language or translator here.  ;D

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller


While I look for a new home for bc9 would it be appropriate  to attach the package to a message here?
It's about 8000KB in rar format. 4400KB 7z but it appears that is not allowed.

James

Patrice Terrier

Perhaps you could you split it into two or three parts.

Then i would rebuild the whole package into one single ZIP file, and host it on my web-site,
then i could post a link here to download the full zip file for those who want it.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

QuoteHi Patrice,

In my experience, PB SDK style coding converted fairly well 70% - 80% with most issues being solved using search & replace in your favorite editor.

I haven't done much since PB 8.x, so I don't know how true that holds for PB9 /PB10.


Also, I only use BCX 6.22 (with a few personal modifications), so I don't can't say what issues you might experience with any of the newer variations of BCX.

My hunch is that for large blocks of code, BCX can do much of the translation pretty well but you should expect to have to do some editing of the translated code.


Hope that helps -- GOOD LUCK!

Kevin
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

Patrice,
  It states that max attachment per msg here is 12000KB so, unless there is a problem with hosting it here, it appears it is well under the max size???

James

James C. Fuller

#24
One thing to note and decide is if you want to ignore warnings.

Example.
This compiles fine but if warnings are on you'll get a warning on this code.

Pb and Bc9 code is the same

SUB SyncProc(BYVAL nSync AS LONG, BYVAL nChannel AS DWORD, BYVAL nData AS LONG, BYVAL nUser AS DWORD)
    LOCAL nRet AS LONG
    nRet = ChannelSetPosition(nChannel, gnPos, 0)
    IF nSync = gnLastSync AND WM_BASSSYNC THEN PostMessage(nUser, WM_BASSSYNC, 0, 0)
END SUB


translation

void SyncProc (long nSync,DWORD nChannel,long nData,DWORD nUser)
{
  static long     nRet;
  memset(&nRet,0,sizeof(nRet));
  nRet= ChannelSetPosition( nChannel, gnPos, 0);
  if(nSync==gnLastSync&&WM_BASSSYNC )
    {
      PostMessage(nUser,WM_BASSSYNC,0,0);
    }
}



warning: passing argument 1 of 'PostMessageA' makes pointer from integer without a cast [enabled by default]

gcc wants nUser to be of type HWND

The warning actually tells you what it wants so you don't have to go look it up.

note: expected 'HWND' but argument is of type 'DWORD'


James

Frederick J. Harris


Frederick J. Harris

Quote
I got a bit carried away with the shortcuts. One of the best aspects of Bc9 is it's versitility.
This is also quite acceptable:



I'm glad you posted that James.  I was studying your examples, and couldn't imagine what happened to the parameters to WinMain() and WndProc() in the BC9 version!

Patrice Terrier

James--

I do not agree with the translation of the PowerBASIC LOCAL keyword, into C static

In PowerBASIC, Local variables retain their values only until the end of the procedure.

In C, when you declare a variable in a function, the static keyword specifies that the variable retains its state between calls to that function. It means it is exatly the same than using the STATIC powerBASIC keyword.

However in C, when you declare a variable or function at file scope (global and/or namespace scope), the static keyword specifies that the variable or funcion has internal linkage. Whe you declare a variable, the variable has static duration and the compiler initializes it to 0 unless you specify another value.

See below the use of the static keyword outside procedure or function to mimic a string constant:// GDImage.cpp : définit les fonctions exportées pour l'application DLL.
//
#include <windows.h>
#include <iostream>
#include <string.h>

#include "stdafx.h"
#include "GDImage.h"

typedef struct {
HWND    hWnd;
LONG anchor;
RECT rc;
LONG TiledBitmap;
CHAR order[METADATA_SIZE];
LONG ordersize;
LONG WMBit[25];
DWORD WMCodePtr[25 * 32];
LONG centerx;
LONG centery;
LONG Composited;
} ZIMAGEPROP;

static char *Version = "6.06";

/* Add two integers */
//_declspec (dllexport) long add_num(long a, long b){
//     return((long)(a+b));}
long add_num(long a, long b){
     return((long)(a + b));}

char* ZI_Version () {
    return Version; // Version number of the form "#.#"
}


Indeed, inside the SyncProc procedure
PB: LOCAL nRet AS LONG
should be just translated to
C: long nRet (without the static keyword)

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#28
Fred,

I totaly agree with Damien Katz, for a SDK coder like myself, C it is the only manageable way to replace my existing PB's SDK code, to keep producing small, fast, and runtime free DLLs.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

#29
Patrice,
  In actuality LOCAL in bc9 works the same as PowerBASIC. Why the static I don't know but the results are the
same although the initialization each time the function is called is overhead that might want to be considered.
Note the AS type may also follow the var as in:
  Raw I2 As Integer

From the help file:
A variable dimensioned with DIM or LOCAL in a subroutine or function retains the value on exit,
but will lose it on re-entry due to the automatic initialization.
James

This bc9 line

LOCAL AS Integer I1


produces this c code


  static int      I1;
  memset(&I1,0,sizeof(I1));


These are 4 different ways to declare variables.
here is bc9 sample code

'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Test LOCAL,RAW
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

$NOMAIN
$ONEXIT "GWGCC.BAT $FILE$ -m32 con"
Sub DoTest()
    LOCAL AS Integer I1
    RAW AS Integer I2
    Raw As Integer I3=0
    STATIC As Integer I4
   
    Print "I1 = ", I1
    PRINT "I2 = ", I2
    PRINT "I3 = ", I3
    PRINT "I4 = ", I4
    PRINT "----------"
    I1 = 1
    I2 = 2
    I3 = 3
    I4++
    PRINT "I1 = ", I1
    PRINT "I2 = ", I2
    PRINT "I3 = ", I3
    PRINT "I4 = ", I4       
End Function
'==============================================================================
Function main(argc As Integer,argv As PCHAR ptr ) As Integer
Raw As Integer i

For i = 1 To 3
    DoTest()
    PRINT "********"
Next
Pause
End Function



c translation:

SNIP

void DoTest (void)
{
  static int      I1;
  memset(&I1,0,sizeof(I1));
  int      I2;
  int      I3=0;
  static int      I4;
  printf("%s% d\n","I1 = ",(int)I1);
  printf("%s% d\n","I2 = ",(int)I2);
  printf("%s% d\n","I3 = ",(int)I3);
  printf("%s% d\n","I4 = ",(int)I4);
  printf("%s\n","----------");
  I1= 1;
  I2= 2;
  I3= 3;
  I4++;
  printf("%s% d\n","I1 = ",(int)I1);
  printf("%s% d\n","I2 = ",(int)I2);
  printf("%s% d\n","I3 = ",(int)I3);
  printf("%s% d\n","I4 = ",(int)I4);
}


int main (int argc,PCHAR* argv)
{
  int      i;
  for(i=1; i<=3; i+=1)
    {
      DoTest();
      printf("%s\n","********");
    }

  Pause();
  return 0;
}



and the output:

I1 =  0
I2 =  0
I3 =  0
I4 =  0
----------
I1 =  1
I2 =  2
I3 =  3
I4 =  1
********
I1 =  0
I2 =  0
I3 =  0
I4 =  1
----------
I1 =  1
I2 =  2
I3 =  3
I4 =  2
********
I1 =  0
I2 =  0
I3 =  0
I4 =  2
----------
I1 =  1
I2 =  2
I3 =  3
I4 =  3
********