GLBasic forum

Main forum => GLBasic - en => Topic started by: Sokurah on 2011-Mar-24

Title: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-24
Argh, I've lost so much time to this already. It's a VERY weird problem so this will be a long post.

A few days ago I decided to port my Omega Race 2009 remake to GLBasic so I can get it running on the iPad and I've finished most of it already (probably because I've been able to work on it both at home and at work ;)). But now I've run into a weird problem that I just can't figure out.

Early on in the porting process I ported my 'textwrite' function and it worked beautifully and didn't give me any problems at all. Then last night I was working the intro for the game and suddenly the textwrite function started behaving weirdly. I sat with it last night hoping I'd just confused some variables and somehow fooked it up, so I kept tweaking and tweaking and hoping I'd get it right...although it should've been working. It's not the first time I've made a textwrite function after all, so I know what goes into it.

In the end - last night - I decided that I couldn't solve the problem, so I just dropped it and decided to just continue at work today with the functioning version I had there. And it worked...just like it did yesterday.
So all day today I've been working on it - mostly on the menu system, and it's been working as it should. What a relief.

So I did what I always do after a session...at home or at work  - I RAR everything down and put it in my DropBox so I can pick up where I left.
Which I did tonight when I got home. Guess what? It didn't work at home. But it did at work. Gahh!!!

The problem with the textdrawing routine is that instead of drawing the expected characters I get the "unknown" character instead (the one I'm using when the program can't find data for it). For some reason it's usually the second character in a string that it can't find.

First a bit of code, but to be quite honest I don't think it's my code, because it's worked nicely in the original Windows version, in and Binary Land (which I also did in GLB) and in countless other games...until here last night.

To print text I do this; (the ¤ is the copyright character)

VectorFont("ipad",26.5,8.75,RGB(255,80,80),0,1,1,0)
VectorFont("¤(2011) by sokurah - www.tardis.dk", 9, 35, RGB(255,0,0), 0, 0.75, 0.75, 0)
VectorFont("play", 7.8, 7.5, RGB(255,64,64), 0, 2,1.5, 0)
VectorFont("settings", 8.75, 9, RGB(64,64,255), 0, 1.5,1.5, 0)
VectorFont("  credits", 7.25, 10.5, RGB(64,255,64), 0, 1.5,1.5, 0)


(the parameters are: text,x,y,color,rotation,xsize,ysize,not-important)

Now, the strange thing is that if I reverse those two first lines - like this - I get very different results.

VectorFont("¤(2011) by sokurah - www.tardis.dk", 9, 35, RGB(255,0,0), 0, 0.75, 0.75, 0)
VectorFont("ipad",26.5,8.75,RGB(255,80,80),0,1,1,0)
VectorFont("play", 7.8, 7.5, RGB(255,64,64), 0, 2,1.5, 0)
VectorFont("settings", 8.75, 9, RGB(64,64,255), 0, 1.5,1.5, 0)
VectorFont("  credits", 7.25, 10.5, RGB(64,255,64), 0, 1.5,1.5, 0)


Next up are two pictures showing how it looks with the 2 first code lines, then a picture where they are reversed. It's worth noting that although I said it's usually the second character that is fooked up - in the first picture it doesn't seem to be the case where it says 'credits', but it is - because there's two spaces before it, so the # character is actually in the second position. Also note that the copyright message at the bottom doesn't work at all with the lines the first way, but perfectly in the other way.

But when I change those two first lines around I get a lot more "unknown characters" - but the copyright message works...it doesn't make sense.

And please remember that it works perfectly at work, but not on my two computers at home. Sometimes I "only" get this problem...sometimes it just crashes and locks up.  :(

...and if you want a bit more code, then I'll insert a bit of the textroutine at the bottom, but to be honest I think it's somehow a combination of GLB and the hardware it's running on. I would be happy to get some help here.  :nw:

(http://tardis.dk/retro/omegarace2009/images/ipador1.jpg)

(http://tardis.dk/retro/omegarace2009/images/ipador2.jpg)

Code (glbasic) Select

//This is used to define the characters allowed, at the top of the program
GLOBAL font$=" abcdefghijklmnopqrstuvwxyz¤0123456789.,?=/-+()':;@!*>#"

//Then a bit of the print itself
FUNCTION VectorFont:str$, x#, y#, col%, ang#, xzoom#, yzoom#, precise%
FOR b = 0 TO LEN(str$)-1
str3$ = LCASE$(MID$(str$, b, 1))
a=INSTR(font$,str3$,0)
IF a<0 THEN a=54//replace unknown char.
//Do the vectorstuff here
x = x + 1
NEXT
ENDFUNCTION

Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
Looks nice!  Could you provide the complete executable (with graphics etc) so we can run it here.  And, importantly whether we get anything similar here.  By the way, there was a bug in INSTR in a previous version of GLBasic - are you running 9.033 ?

Have you minimised the game window whilst it's loading data ?
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
I forgot to mention it, but I'm running version 9.040 on all 3 computers.

Here's a Windows executable. It's VERY incomplete, but you'll see right away if it works or not.
...for some reason the 'settings' menu crashes for now...it didn't earlier (and I haven't changed anything).  :sick:

I'm not minimising anything - just pressing F5 and letting the game start.

Edit: Removed link to demoversion.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
I get :

By the way, is :

Code (glbasic) Select
a=INSTR(font$,str3$,0) correct, as the passed string is str$.

The most obvious place to start is, in debug mode, to find out what values are held in str$, a and font$.  It sounds like a is not finding characters, therefore something is wrong with str$ or font$.

If A is >=0 then its time to check to make sure the correct graphic is drawn...

One other thing to try is toggle between the two compiler modes, and delete everything in %TEMP%, or %TEMP%\glbasic if you like storing files in %TEMP%...

[attachment deleted by admin]
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
How strange...that it seems to work for you.  :doubt:

Quote from: MrTAToad on 2011-Mar-25
By the way, is :

Code (glbasic) Select
a=INSTR(font$,str3$,0) correct, as the passed string is str$.

The most obvious place to start is, in debug mode, to find out what values are held in str$, a and font$.  It sounds like a is not finding characters, therefore something is wrong with str$ or font$.

If A is >=0 then its time to check to make sure the correct graphic is drawn...

One other thing to try is toggle between the two compiler modes, and delete everything in %TEMP%, or %TEMP%\glbasic if you like storing files in %TEMP%...

Yes, it's correct. I'm passing str$ from the function call, then picking out the character I need, by finding its index in font$ and then placing it in str3$
I can't run the program in debug mode. Well, I can, but I only get this;

Quote_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.7.861 SN:9adeaed7 - 2D, WIN32
Wordcount:1802 commands
compiling:

linking:
success
_______________________________________
*** Finished ***
Elapsed: 27.0 sec. Time: 01:18
Build: 1 succeeded.

Start debug session.
_______________________________________
Injection started

All I get is a window the right size, for a brief moment, but nothing actually starts up and I'm returned to the IDE (in debug mode only).

I've just tried deleting everyting in my TEMP folder, but that didn't help.

I've tried using PRINT and write above each character what the calue of A is, and when I get the "unknown" char it's always -1.

My version of MingW isn't the latest version - could that be the problem...is it even needed? (I don't even think I've got it on all 3 computers).
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
MinGW isn't needed, but older versions do cause problems, usually only when compiling though.

What operating system are you using ?
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: LineOf7s on 2011-Mar-25
I'm not sure if this is helpful to you or not, but I stumbled across this thread and just for fun I thought I'd download your test file and see what happened.

Downloaded, extracted, run.  Got the screenshot.  WinXP SP3, nVidia Geforce 7300 SE.





[attachment deleted by admin]
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
@LineOf7s
Yes, that is very useful - it shows it's not just my computer that's behaving weirdly.

@MrTAToad
Yes, let's talk specs. I've tried it on 7 computers now.
It works on the two green ones, but doesn't work on the 5 red ones.

First one has 32bit Windows 7 with a NVIDIA GeForce 9300 GE (plug-in card)

Second one runs WinXP SP3 with an Intel Q965/Q963 Express GPU (onboard). Processor is 3GHz P4.

Third one has WinXP SP3 and a Radeon HD 4670 GPU (plug-in card). Processor is an AMD 4050E (or something).

Fourth one has WinXP SP3 and a NVIDIA GeForce Go 7600 (onboard). Processor is Intel Core 2 T5600 @1.83GHz

Fifth one runs Windows Vista and has a Intel Core Duo T8100 @2.10GHz processor and a Mobile Intel 965 Express GPU (onboard).

Sixth one runs WinXP, SP2 and has a Intel Core Duo T8100 @2.10GHz processor and a Mobile Intel 965 Express GPU (onboard).

Seventh one runs Vista Business, SP1, uses a Core Duo E4600 @2.40GHz processor and has a ATI Radeon HD 2400 XT GPU.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Kitty Hello on 2011-Mar-25
debug what the INSTR returns to a text file. That sound much like a bug with buffer overflow or something.

It works fine on my PC (see specs in sig - ATI card - I have to update, wait ;) )
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
Its probably time to get all Sweeny on the program, and thus I suggest the following :

Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
The weirdness continues.

I just took the game and copied the font and linedrawing stuff only, to a fresh project, just to see how a minimal version runs.
Then I ran it on one of the computers that has problems with the full program...and that runs without problems?
...so clearly it's not my code that is the problem (not in the font and linedrawing functions, anyway  :P).

@LineOf7s
What happens if you run this - does it look right or wrong?
http://dl.dropbox.com/u/2697142/OmegaFontTest1.rar

@Gernot
Is there some sort of built-in limitations in the free version?
Also, can you give me an easy way to show on screen how much memory is in use by the program?

Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Kitty Hello on 2011-Mar-25
I have no idea how to get the used memory. Just just a task manager.

There's no limitations in the free version if it does not show "DEMO" in the topleft corner when running. If it does that, your game will end after 10 minutes (you used 3D, networking or a non-free platform then).
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
Quote from: Kitty Hello on 2011-Mar-25
I have no idea how to get the used memory. Just just a task manager.

There's no limitations in the free version if it does not show "DEMO" in the topleft corner when running. If it does that, your game will end after 10 minutes (you used 3D, networking or a non-free platform then).

Using the task manager it says that it uses 23MB of memory.

And, no, it doesn't use any non-free stuff.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Kitty Hello on 2011-Mar-25
ok, fine. Omega font test runs fine here :(.

To test it - can you use the opengl32.dll from the Samples/3D/Shaders directory (that's a MESA software renderer) and put it in the exe directory to test? That way we can be sure it's (not) the driver.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Enigma on 2011-Mar-25
I have checked this and it works no problem for me. I have Windows 7 32bit SP1, nVidia GeForce 8800GTX.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
Quote from: Kitty Hello on 2011-Mar-25
To test it - can you use the opengl32.dll from the Samples/3D/Shaders directory (that's a MESA software renderer) and put it in the exe directory to test? That way we can be sure it's (not) the driver.

Good test. Tried it. Haha, goodbye framerate. :D

It's still the same though - I get the "unknown" (-1) characters (with the gametest...haven't tried the fonttest as that seems to work anyway).

For what it's worth, if it's of any help, the sourcecode is about 70kb spread over 14 files.

Could it be something with the size of the program? (although that doesn't make sense either, as the same gametest works on some computers but not others).
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
I wonder if putting the whole thing in a new project will solve it ?
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
Quote from: MrTAToad on 2011-Mar-25
I wonder if putting the whole thing in a new project will solve it ?

Even if that would magically work, it doesn't explain why the already compiled version works perfectly on some computers, and not on others.

Could it somehow be a GLBasic dependency related to the processor or OS?
...or could there be an upper limit in GLBasic of "something" that I've touched on with this game?
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: LineOf7s on 2011-Mar-25
Sorry for the delay - I was at work before, and... now am not.  :)

I was concerned I wouldn't be able to replicate the problem here on my home computer (it's somewhat more capable), but luckily (?!) your original test code didn't work here either.  Did the same as before, but now I'm running on WinXP SP3 with an nVidia GTS250 (1GB of memory on it).

If it makes you feel any better at all, as far as I can tell the second test you posted (just the font test) seemed to work perfectly.  No weird letters or anything (see attached).


[attachment deleted by admin]
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
Are you using CREATESCREEN multiple times with the same screen number, but with different sprites and/or sizes ?

It wont be the file size nor number of source files as I'm using well over 20 different files with Spots.  Nor is it processor specific

The important thing is to get the debug mode working - that way debugging of strings etc etc can commence.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
Quote from: MrTAToad on 2011-Mar-25
Are you using CREATESCREEN multiple times with the same screen number, but with different sprites and/or sizes ?

The important thing is to get the debug mode working - that way debugging of strings etc etc can commence.

Nope, I'm not even using CREATESCREEN once. :D There's also just the one sprite - a gradient dot (and the backdrop).

I'm going to strip some stuff out of the program and see if I can figure out what's causing it, and if I can get the debug mode working again. Nice little project for the weekend...although I'd rather be working on the gameplay. ;)
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
I would go for the uninstall/re-install route first.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Minion on 2011-Mar-25
Hope you find out was is causeing this as ive had a similar effect on the pandy. Everything works fine with my text routines on the PC (And other machines) but on the pandy the whole thing goes screwy and reuses the same (last) piece of text for everything text based on the screen !
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Kitty Hello on 2011-Mar-25
write the ASC values and the returns of MID$ and INSTR to a debug log file. I have the slight feeling that there's a bug in INSTR or MID$.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
Quote from: MrTAToad on 2011-Mar-25
I would go for the uninstall/re-install route first.

  • 1. Upgrade MinGW to the latest version
  • 2. Update all drivers
  • 3. Uninstall GLBasic, and remove program directory
  • 4. Download, install and update GLBasic
  • 5. Try compiling in debug mode

Good point, although I've already done most of them.

1. MinGW is only installed on one of all these computers. I think it's 2 revisions behind, but it's easily done.
2. I've already updated the graphics drivers on two of them, but I can try again. What about DirectX?...is that needed?
3 & 4. Already tried that. Also cleared the TEMP folder.
5. Doesn't work. I've described what happens here (http://www.glbasic.com/forum/index.php?topic=6003.msg47285#msg47285).

:help: :help: :help:  :'(
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
Quote from: Kitty Hello on 2011-Mar-25
write the ASC values and the returns of MID$ and INSTR to a debug log file. I have the slight feeling that there's a bug in INSTR or MID$.

Will do. Good idea. I'll try to do that tonight.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Kitty Hello on 2011-Mar-25
your no-debug problem sounds very strange.  If it works with a fresh or sample project, please bother to send me your project. You are overwriting some bad memory then. (My fault then, but I need code to debug).
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-25
that's a good idea - create a project with, say, a DEBUG line and compile in debug mode - see if that works
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: ampos on 2011-Mar-25
To get the debug working, just un-fold all your SUBs and FUNCTIONs.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-25
EUREKA!!..

I seem to have solved the problem, but I can't tell you exactly what the problem was, though.  :blink:

I started by putting a DEBUG line in almost at the top of the program, then compiling and seeing what happened, then moving it down through the source one line at the time - to narrow in on where the problem was.

I checked every line, every piece of resource, twice, removed a few things, changed some around

At first I thought I might be a problem with the initialization of some arrays, as it seemed to work sometimes when I removed parts of code related to that, but in the end I think it may have been a problem loading some resources, but I honestly can't say for sure, but it works now...on 3 computers where it didn't work correctly before.

The strange thing is - if it indeed was a problem stemming from loading resources, why would it behave completely randomly the way it did?
I guess we'll never know now...  :-[

Most importantly - I'm glad it seems to have been me that made a mistake and it's not GLBasic that has some weird bug in it.
I'm also happy for all the help and good suggestions I got along the way (I didn't even know of the DEBUG command).

Thank you all.

...it may just end up being finished anyway. :D

Oh, and I just ordered an iPad 2 today. I wonder how it'll run and if it won't choke from all the vectors being drawn, but that's something we can check once it's closer to being done.   :)
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-26
You weren't using JPEG's were you ?
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-26
Yes and no.

The backdrop is a JPG. It's always been and I haven't changed it. Should I use PNG instead?
The dot used for the lines is a BMP and the pausebutton was PNG but is now a BMP too.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-26
Yes, JPEGs shouldn't be used at the moment - they do cause problems...
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Millerszone on 2011-Mar-26
Nice looking game!

I waisted a lot of quarters in the arcades playing the original Omega Race.

From what I read the iPad 2's GPU is about 9x faster than the iPad 1.
Would be nice to test on an iPad 1.

I'm going to try this website for my next app:
http://www.testflightapp.com (http://www.testflightapp.com)
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Ian Price on 2011-Mar-26
JPEGs cause highly erratic problems on all formats - they might appear to work, but underneath they are messing with everything else in your code. Definitely use .PNG or .BMP instead.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-26
Quote from: Ian Price on 2011-Mar-26
JPEGs cause highly erratic problems on all formats - they might appear to work, but underneath they are messing with everything else in your code. Definitely use .PNG or .BMP instead.

Thanks, good to know. Besides, just because a JPG is smaller than other formats I doubt is faster to draw - if anything it should take longer as it needs to be uncompressed, so there's no reason to use that anyway.

BMP is out of the question as they take up too much room, but I'll use PNG for the final version then, as that's more reasonable in size.

@millerszone
If you like it you can get my PC version - it's free and looks just like this version.

Yes, I guess I'll have to screw it seriously up to not have it run on the iPad 2, but I hope it'll run on the first generation too. But we'll see about that once it's relevant.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Ian Price on 2011-Mar-26
QuoteBMP is out of the question as they take up too much room, but I'll use PNG for the final version then, as that's more reasonable in size.
WRONG!!! .PNGs take up exactly the same amount of space when loaded into RAM as a .BMP.

.PNGs also don't compress as well as .BMP in a zip file. Try it - you'll be very surprised. Often the .PNGs will take up more space when zipped.

It's only when .PNGs are sitting in files that they are smaller in size. Once opened and being used they take up the same amount of memory as every other graphics format.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: Sokurah on 2011-Mar-26
Quote from: Ian Price on 2011-Mar-26
QuoteBMP is out of the question as they take up too much room, but I'll use PNG for the final version then, as that's more reasonable in size.
WRONG!!! .PNGs take up exactly the same amount of space when loaded into RAM as a .BMP.

Well, I'm not really wrong - I know they're the same size once they're loaded...so we agree on that.
I just meant that BMP files are much bigger as external files than PNG. And I have no need for a filetype that compresses better when zipped, in this case.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: ampos on 2011-Mar-26
Notice that a .ipa file is a .zip file, so the ipa will be smaller with bmp than pngs, although it will eat more space on iPhone "disk" with bmp. Once run, they will eat the same amount of ram.
Title: Re: Weird weird problem with game (Omega Race 2009 for the iPad).
Post by: MrTAToad on 2011-Mar-26
Glad its working now.

This is one reason why tests should be made on multiple machines, preferably with totally different configurations - and its this one important area that most people cant do.

I, for example, have 4 machines - 2 run XP and 2 run Windows 7.  One uses an Intel internal graphics card and the rest are nVidia.

So, I've no idea what a program runs like on ATI cards, for example, nor on Vista...