Project of a multiplatform version of FreeBasic Miner

General FreeBASIC programming questions.
badidea
Posts: 2594
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Project of a multiplatform version of FreeBasic Miner

Post by badidea »

Roland Chastain wrote:So I have to install fbc 32 bits under Linux... or to find the cause of the problem. If someone has an idea, please let me know.
Check the use of timer variables, they need to be of type double on linux, else you get weird behavior.
I can have a look at the code this weekend. Hope I don't forget.
badidea
Posts: 2594
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Project of a multiplatform version of FreeBasic Miner

Post by badidea »

SARG wrote:
Avast is not very happy when downloading. It reports a malware
Maybe a false positive.
I don't know. Not my website, not my program and most likely the virus does not support my OS as well.
SARG
Posts: 1774
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Project of a multiplatform version of FreeBasic Miner

Post by SARG »

Tourist Trap wrote:I've throwed the exe away from the zip and put the result there.
Thanks I could download it.
badidea wrote:Not my website, not my programl.
I know that. Sorry I should have quoted without your pseudo.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

Thank you all for your help.

I installed fbc 32-bits. The result seems to be the same as when I replaced Integer with Integer<32>: the initial menu is frozen.

Before that, I had to replace "Lt" with "Lt_".
badidea wrote:Check the use of timer variables, they need to be of type double on linux, else you get weird behavior.
I can have a look at the code this weekend. Hope I don't forget.
Thank you. I will look at timer variables.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

All timer variables seem to be declared as double.
badidea
Posts: 2594
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Project of a multiplatform version of FreeBasic Miner

Post by badidea »

How can the declaration below work? Freebasic is not case sensitive I thought?

Code: Select all

Dim Shared hMidiOut As HMIDIOUT
And, do you compile with -exx? I get an 'out of bounds' on:

Code: Select all

If g < LargArqFonte - 1 Then PosLetra (h, 0) = g + 1
Hum, this may be a consequence of not loading images here it seems.

Code: Select all

Carregou = BLoad ("Res\Fonte.bmp", Grafx2)
Above fails here, not sure why yet. Ah, the "\". Changed to "../Res/xxx.bmp"

Now it compiles and starts without directly crashing, but behavior between 32 and 64-bit fbc is different here as well.
With 64-bit it seems I can start a game, but the map is empty.
With 32-bit I get stuck in the menu: https://nr100.home.xs4all.nl/badidea/mi ... -09-18.png

The main sub-routine is a 1500-line select case / end select block :-)

This looks bad and seems to get the 32-bit version stuck here:

Code: Select all

NTimer = Int(Timer * 1000)
Timer returns a very large number on linux (seconds since 1970), multiply that by 1000 and try to store it in 32 bits. In TrocaTelas() or SwapScreens()
As a quick solution, you could try to make a "timer2" function which returns the number of seconds since program start. And use that everywhere instead of "timer". Something like this:

Code: Select all

function timer2() as double
	static as integer init = 0
	static as double startTimer
	if init = 0 then
		init = 1
		startTimer = timer()
	end if
	return timer - startTimer
end function
Maybe timer_(), timer2 is already used.
Menu unstuck: https://nr100.home.xs4all.nl/badidea/mi ... MinerX.bas

Next problem: Get a map loaded... This seems like really messy code.
But any binary file reading/writing should be checked for (u)integers. E.g.:

Code: Select all

Get #1, , Object (MXR + f, MYR + g).tp

Code: Select all

'Objects
Type TObj
	Tp			As UByte    'Object type
	IsFalling	As Byte     '0=no; 1=yes
	WasFalling	As Byte     'Was falling in previous Cycle
	BeingPushed As Byte     '0=no; 1=to right; 2=to left
	StepNumber	As Integer  'Of movement
End Type
So 'StepNumber' could cause problems. But so far, I get no or empty maps.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

@badidea

Thank you very much. I replaced timer with your function. The program works now, when it is compiled to 32-bits. (I installed a 32-bits compiler for that project.)

The 64-bits version doesn't work. As you say, there is a problem with map loading. I don't understand well what you said about uinteger, but I will study the question.

I can start to think to the sound problem. My first idea would be to modify the existing code to create MIDI files. I am not sure that it is possible but I will try. The other idea would be to find a replacement for MMSystem functions (but using the same data), either in angros47 sfx library or in FBSound.

I know almost nothing about sound and MIDI programming, but it will be an occasion to learn.
badidea
Posts: 2594
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Project of a multiplatform version of FreeBasic Miner

Post by badidea »

Roland Chastain wrote:I know almost nothing about sound and MIDI programming, but it will be an occasion to learn.
Neither do I, but the sfx library form angros47 (using ALSA on linux) seems to have midi subroutines.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

badidea wrote:
Roland Chastain wrote:I know almost nothing about sound and MIDI programming, but it will be an occasion to learn.
Neither do I, but the sfx library form angros47 (using ALSA on linux) seems to have midi subroutines.
Yes, I saw that. So there is hope. :)

I created a git repository with my version of the code. I started a french language file. It's a way to get to know the program. :)
badidea
Posts: 2594
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Project of a multiplatform version of FreeBasic Miner

Post by badidea »

Using your git-version now. I added chdir ".." so I can run from the source directory directly. Map(s) are now ok for 32-bit. I'll have a look at the 64-bit map issue later today.
What is going on with the "freebasicminer(englishvariables).bas" version? That does not compile at all. Do you plan to switch to this version. Having 2 source versions sounds like trouble.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

badidea wrote:Using your git-version now. I added chdir ".." so I can run from the source directory directly. Map(s) are now ok for 32-bit. I'll have a look at the 64-bit map issue later today.
Thank you for testing the files of the git repository.

For me, I use a compilation script, which is in the main directory and creates the executable in the main directory. When I work on an application, I always start it from the command line. That way I see many things that I wouldn't see otherwise.
badidea wrote:What is going on with the "freebasicminer(englishvariables).bas" version? That does not compile at all. Do you plan to switch to this version. Having 2 source versions sounds like trouble.
I uploaded it by mistake. I don't intend to use it. I keep it for reference, in case I don't understand something. I will delete it from the repository.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

Just found two very interesting discussions. If I correctly understand, there is what i am looking for.

MIDI event in Linux
Cross-platform MIDI

And also this one:
Midi softsynth
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

I moved all sound variables and functions to a separate file and restored all the code for Windows. The game should compile and work, with sounds if you are on Windows. I cannot test for now, because I don't have a Windows under the hand.

I give up the idea of using MIDI for Linux. I think it's too dependent of the user system. So I am starting to use FBSound with sound files.

I have not yet had time to search why map loading doesn't work in 64-bits.

The repository has been updated.
https://github.com/rchastain/freebasic-miner

P.-S. If you try to compile the program, the executable must be in the main directory (with config.min and minas.bin). And don't forget that you must compile to 32-bits.
Roland Chastain
Posts: 1007
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Project of a multiplatform version of FreeBasic Miner

Post by Roland Chastain »

The Linux version has sounds. I included a binary, in case someone wishes to try the game but doesn't have a 32-bits compiler installed.

By the way, I am not sure that all files (*.a, *.bi, *.so) are needed. I will check that later.
Last edited by Roland Chastain on Sep 24, 2020 0:48, edited 1 time in total.
badidea
Posts: 2594
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Project of a multiplatform version of FreeBasic Miner

Post by badidea »

In type TMina change:
Tempo as uinteger 'Tempo para concluir a mina
to:
Tempo as ulong 'Tempo para concluir a mina

And also in type TObj (not 100% sure, but 'long' does not hurt):
Passo as integer 'Número do passo no movimento
to:
Passo as long 'Número do passo no movimento

And 64-bit compile and run seems ok (if you add the 64-bit fbsound libs).
Post Reply