Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Jimmy Cool
23
Years of Service
User Offline
Joined: 6th Mar 2003
Location: United States
Posted: 17th Aug 2003 05:31
Don't know what to call this problem.. other than annoying

In the code below I simply open a large data file and load a section I specify from it, which will be converted to my 2D landscape.. tada a 2D engine. The code works JUST fine when I don't have 'load image "media/grass.bmp",33' at the top.. otherwise, It gets stuck in the _loadmap subroutine (I can't make it a function either, NOR can I use the chr$() command, doesn't matter where, it just gets stuck when reading the world.dat file) Plus, without those commands the text is smaller and clearer, with them, the screen goes to the default resolution and it gets stuck.. STUCK STUCK STUCK.. bah.. headache.. bah....
thanks..
***********************************************
(shameless plug) http://www.dbpcommunity.com/ - FREE Subdomain and Domain hosting for Development related sites! EAT THAT EAT IT!
Jimmy Cool
23
Years of Service
User Offline
Joined: 6th Mar 2003
Location: United States
Posted: 17th Aug 2003 06:27
Update: It does not get stuck, it just takes an EXTREMELY long time to run through the file, when in graphics mode.. or whatever the crap load image command takes it to

***********************************************
(shameless plug) http://www.dbpcommunity.com/ - FREE Subdomain and Domain hosting for Development related sites! EAT THAT EAT IT!
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Aug 2003 06:34
A few things - none of which will probably solve your problem - after all it is DBPro we are talking about here!

First of all, it's very common to see the / symbol used in file paths, when it should be \. Forward slashes should only be used in web URLs, though it's so common, it must work in DB!

Secondly, in the code, if whereStr$ is not found, the program jumps to _notfound: which is after the file is closed. Subsequently, the file isn't closed.

Thirdly, you should never use Goto to get out of a subroutine you have called with Gosub. Set a flag in the procedure and jump to the Goto if absolutely necessary after you have returned from the Gosub.

Finally, have you tried opening the file with channel 1 instead of 2? There may be a good reason why 1 wasn't used, but if not, it's worth trying.

You also seem to have more tiles down than across in your For...Next loop. Is this intentional or do you have the X and Y back to front?

Maybe one of these 'unconnected' points will help.

TDK
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Aug 2003 06:36
Addendum!

You are using gosub _notfound - not Goto. Sorry, I misread that bit.

But, on return from there, it's still in the Repeat...Until loop it came from so it carries on...

TDK
Jimmy Cool
23
Years of Service
User Offline
Joined: 6th Mar 2003
Location: United States
Posted: 17th Aug 2003 06:59
I'm asking for a solution, not for someone to pick apart my crappy code

hmm, the x and y thing, that was me changing the variables right before i copied without testing, but I did catch it before you posted..

I made all your pretty changes and it's the same..

umm, what I think it all comes down to is that when the graphics are fully initialized (by commands like load image) file access is SLOW.. I mean come on, 20 seconds to put 1600 bytes into an array? crazy.. and that's just the first section of my file, hate to see how long it took to load the last one... disgusting.. heh, so, problem solved! DBPro hates me

***********************************************
(shameless plug) http://www.dbpcommunity.com/ - FREE Subdomain and Domain hosting for Development related sites! EAT THAT EAT IT!
Jimmy Cool
23
Years of Service
User Offline
Joined: 6th Mar 2003
Location: United States
Posted: 17th Aug 2003 07:01
oh and _notfound doesn't return, it ends.. see i'm not a COMPLETE moron

***********************************************
(shameless plug) http://www.dbpcommunity.com/ - FREE Subdomain and Domain hosting for Development related sites! EAT THAT EAT IT!
haggisman
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 17th Aug 2003 12:59
Any chance you could post the media/files?
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 17th Aug 2003 13:35
I'll take a look if you want to. Really do need to see world.dat and possibly grass.bmp

Feel free to email them to me directly.

The programmer formerly known as sonic
Jimmy Cool
23
Years of Service
User Offline
Joined: 6th Mar 2003
Location: United States
Posted: 18th Aug 2003 01:51
but it's not the media files.. *sigh* lol, ok i got a shortened version of my world.dat file AND grass.bmp which is just a little green thing, but whatever, plus I have a better form of my code

here
http://www.dbpcommunity.com/temp.zip

the best way to test this BUG is to first run it the way it is, then enter :a01 (it takes like 20 seconds) then it'll show a small portion of the readout, which is correct. Then comment out the line 'load image 33,"media\grass.bmp"' and enter the same string.. or even :a40 and it'll take 1 second, maybe less, print some bytes then done. You'll see I'm not crazy, i'm really not

***********************************************
(shameless plug) http://www.dbpcommunity.com/ - FREE Subdomain and Domain hosting for Development related sites! EAT THAT EAT IT!
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 18th Aug 2003 02:50
Just some liberal use of sync command sorts that out! Everything in now instant!

The programmer formerly known as sonic
Jimmy Cool
23
Years of Service
User Offline
Joined: 6th Mar 2003
Location: United States
Posted: 18th Aug 2003 03:34
awww, i messed with sync too... heh, thanks man, you are indeed

***********************************************
(shameless plug) http://www.dbpcommunity.com/ - FREE Subdomain and Domain hosting for Development related sites! EAT THAT EAT IT!
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Aug 2003 05:45
I have to confess. I didnt really analyse your code in detail, but I think files in db generally are really slowly handled. The file isnt loaded into memory and then read from. Every time you read a byte, that block is copied into memory, time and time again (or so I believe). This could be your slow down.

The possible solution could be to make a memblock from the file, so its loaded into memory completely and then access the data from there.

Two things:
(1) I'm speculating on this as the problem and solution.
(2) Sorry if I'm not actually answering your question cos it's too late and I'm tired.

Insiiiiiiiiiiiiiiiiiiiiiiiide!

Login to post a reply

Server time is: 2026-07-22 18:53:52
Your offset time is: 2026-07-22 18:53:52