Author Topic: Dual Layer display - speed increase  (Read 5244 times)

0 Members and 3 Guests are viewing this topic.

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Dual Layer display - speed increase
« 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).

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Dual Layer display - speed increase
« Reply #1 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.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Dual Layer display - speed increase
« Reply #2 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

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Dual Layer display - speed increase
« Reply #3 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).
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Dual Layer display - speed increase
« Reply #4 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.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Dual Layer display - speed increase
« Reply #5 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.
« Last Edit: August 13, 2010, 07:26:44 pm by Hot_Dog »

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Dual Layer display - speed increase
« Reply #6 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.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Dual Layer display - speed increase
« Reply #7 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.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Dual Layer display - speed increase
« Reply #8 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.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Dual Layer display - speed increase
« Reply #9 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


Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Dual Layer display - speed increase
« Reply #10 on: August 14, 2010, 12:11:08 pm »
Okay, thanks.