Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: MRide on August 13, 2010, 02:50:39 pm

Title: Dual Layer display - speed increase
Post by: MRide on August 13, 2010, 02:50:39 pm
I can upload the program if you like, but here is an outline of the code:

Code: [Select]
ClrDraw
If not(L
Then
If not(M
Then
mapdata->Str1
mapdata->Str2
End
If M=1
Then
.
.
.
End
End
display code

The problem isn't with the display code, that part runs plenty fast.
When I run the program, it takes a second or two to begin displaying the map.
Is there a way to speed this up?  It doesn't matter which room I choose, it still displays slow.
I have 15 rooms (so 30 8x16 strings).
Title: Re: Dual Layer display - speed increase
Post by: thepenguin77 on August 13, 2010, 03:02:48 pm
I would assume that the delay comes from the fact that the OS has to keep skipping your if statements. 15 is quite a bit of skipping.

I would suggest that instead of your if then, you make one big string and use sub(. Each room is 16*8= 128. So you would make a string, "roomA[128]roomB[128]roomC[128]...". All one after the other. Then to access them:

sub(str0,(room)*128,128->Str1

Will this work for you? Because this should be near instant once you have your string stored. Or if you can't afford to give up a string for this, you could use:

sub("roomA[128]roomB[128]...",(room)*128,128.   

It will be a little slower, but it doesn't kill any variables.
Title: Re: Dual Layer display - speed increase
Post by: MRide on August 13, 2010, 03:07:41 pm
It should work for what I'm doing.  It's not really a lot to rearrange, either.
Thanks.
Now I'm off to write more code. O0
Title: Re: Dual Layer display - speed increase
Post by: meishe91 on August 13, 2010, 03:31:22 pm
Ya, I would agree with Penguin on that one. Just have them lined up in an order that makes sense for when you go room to room then just display the whole thing at once. Though are you doing this on the homescreen or graphscreen? You said Dual Layers so I'm assuming graphscreen which means you can't display the whole map at once (unless I'm mistaken).
Title: Re: Dual Layer display - speed increase
Post by: MRide on August 13, 2010, 05:55:50 pm
It is on the graph screen (and dual layers too).
Everything is in one string, but the display routine isn't that difficult.

Code: [Select]
For(J,0,7
Text(-1,8J,0,sub(Str1,16J+1+256R,16
StorePic 6
Text(-1,8J,0,sub(Str1,16J+256R+129,16
RecallPic6
End
StorePic 6

R is the room number, where the first room is room 0.
Title: Re: Dual Layer display - speed increase
Post by: Hot_Dog on August 13, 2010, 07:22:57 pm
I just saw this, so something for people who don't have rooms (or something similar) the same size and yet want to have a bunch of rooms in a string:  it helps if you have someway to tell the calculator "this is how big the first room is, this is how big the second room is," etc. so that you can have quicker searching for the calculator.  If you have a room that is 150 bytes in length, another 200 bytes, and a 3rd 100, and if your calculator has to search through the first 350 bytes to find out where the 3rd room begins, that is going to be terribly slow.

I have a function that takes a sprite--and its mask--and draws it out.  The mask data occurs immediately after the sprite data.  However, instead of having the calculator compute where the mask is, I just tell it "This is where the mask is."  It saves quite a bit of time.
Title: Re: Dual Layer display - speed increase
Post by: MRide on August 13, 2010, 08:38:44 pm
I just experienced the severe slowdown in drawing the map when you get to room 15 (R=14).
I wonder if it would be faster if I had two strings (one for each layer)?
Also, thanks for the info, Hot Dog.
Title: Re: Dual Layer display - speed increase
Post by: meishe91 on August 13, 2010, 08:47:34 pm
Ya, I was gonna suggest that since the further you get into a string the slower it goes. If you wanted to make the make drawing as even as possible you could flip the strings around (so one starts with room one and then the other ends with room one). I don't know if that would actually work but in theory it does :P Just a thought.
Title: Re: Dual Layer display - speed increase
Post by: MRide on August 13, 2010, 08:51:47 pm
Thanks, I'll have to try that.
Does anyone know how the maps are stored/displayed in Metroid Pi?  As I recall, there were quite a few rooms in that game, and the display was decently fast.
Title: Re: Dual Layer display - speed increase
Post by: Builderboy on August 14, 2010, 01:23:38 am
I believe they were displayed the same way you are doing yours :) I believe each layer was a single string, and they were displayed in a similar way

Title: Re: Dual Layer display - speed increase
Post by: MRide on August 14, 2010, 12:11:08 pm
Okay, thanks.