October 18, 2019, 06:25:50 PM

Author Topic: Gridwars : "Compile Error: Unable to convert from Byte Ptr to Int."  (Read 108 times)

Offline echdareez

  • Jr. Member
  • **
  • Posts: 2
Hi there,

Gridwars is one of my favourite games and I was shocked to realize last weekend that the sources were present all those years in my installdir  ;D
As I was planning on learning to code a 2D game, I thought : why not take this game as an example?
Downloaded BlitzMax_win32_x64_0.105.3.35.7z (78.292.684 bytes), ran MaxIDE, opened gridwars.bmx, verified the compilation options (Win32 on x86 - verbosed debug build) and immediately stumbled upon an error while trying to do a test build :

Code: [Select]
"Compile Error: Unable to convert from Byte Ptr to Int.  [C:/apps/BlitzMax/GridWars-master/bass.bmx;310;0] "
Had a look around : there's an Import in the gridwars.bmx towards sound.bmx and in here an Import to bass.bmx. The culprit line is :

Code: [Select]
Local dll:Int = LoadLibraryA("bass.dll")
Also found this article in here :
https://www.syntaxbomb.com/index.php?topic=3233.0
And this didn't get me further (tried -w on the command line, using bmk.exe directly, etc...)

Any pointers for a starting programmer? :-)
tx!
/e

Offline Derron

  • Hero Member
  • *****
  • Posts: 2486
Re: Gridwars : "Compile Error: Unable to convert from Byte Ptr to Int."
« Reply #1 on: September 30, 2019, 06:11:34 PM »
Dunno if it is the bass-module from Brucey?
https://github.com/maxmods/bah.mod/tree/master/bass.mod


Byte Ptr -> Int
This problem arises from NG no longer accepting such stuff and is a bit more strict. DLLs want "pointers", not integers.


Means here LoadLibraryA("bass.dll") returns a "Byte Ptr" and not a "Int".
Code: [Select]
Local dll:Byte Ptr = LoadLibraryA("bass.dll")
should correct this line - but I assume there is more stuff to come.


bye
Ron

Offline echdareez

  • Jr. Member
  • **
  • Posts: 2
Re: Gridwars : "Compile Error: Unable to convert from Byte Ptr to Int."
« Reply #2 on: October 01, 2019, 08:12:19 AM »
Thanks a lot for your reply Ron!

And yes, it's that one as far as I can see.
Changing the INT to BYTE PTR did indeed get me further, but there's another function blocking the build later on (expecting an INT as a return) - no worries, it's a challenge but worthwile as a case study and a learning process ;-) 

Out of curiosity : also tried an older version (Blitzmax 1.5) : this DID compile is without any errors but the .exe gives an exception_access_violation when launching... Something for later :-)   Now for some "real work" and some Powershell coding - something I *do* have the knowledge for :-D

/e

Offline Derron

  • Hero Member
  • *****
  • Posts: 2486
Re: Gridwars : "Compile Error: Unable to convert from Byte Ptr to Int."
« Reply #3 on: October 01, 2019, 08:51:10 AM »
that 1.5 blitzmax is BlitzMax 1.50 - and we call it "legacy" for a reason. It is no longer supported, only able to compile for 32 bit and the target platforms are also more limited.

With BlitzMax NG you gain 64 Bit compatibility, more platforms, updates, fixes ... but it comes with a price: it behaves more correct ("strict"). With 64 Bit in mind you seem to be no longer able to pass a Byte Pointer as Integer anymore.

So old code which did "advanced stuff" (handling DLLs, mangling memory...) needs to get adjusted here and there. Non-Strict code might now throw errors.
But all of them are no "logic changes" but language-ones. Means once you fixed the thrown errors the game should run as planned.


Feel free to post other issues you have with the code - maybe we can fix it together.

bye
Ron