How heavy using layers are for classic machines?

Find quick help here to get you started with Hollywood
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

How heavy using layers are for classic machines?

Post by Bugala »

So i took a test with hollywood 6 and made a version using the hw6 feature of playing two musics at same time in hopes of getting the load less on my game, but as far as I am testing with Amikit, result seems like it would be hopeless to get it to work on classic machines.

I am using layers that stay still, as can be seen in this video: https://www.youtube.com/watch?v=KRQ4XK1wWQE

when using amikit on fastest possible speed, beginning of game works very fast. But at point it gets to that point that this video is showing, it starts crawling quite bad, and i wonder why.

As far as i can see, even at that fast beginning spot there was HD res picture and on top of that was layer picture and text with bubbles picture, exactly same that is happening in this video.

On top of that, at that beginning spot there was also two music streams (in reality another is talk sample) playing at same time, and it was very very fast, but when it gets to this spot, and there is only one music (talk samples) playing at same time, and yet, it is very slow.

So i wonder first of all, why this difference when they should be doing pretty much the same thing?
And second, is it so that when using layers in HD resolution, even when they are still like these, it is not realistic to expect it to work on classics anymore?

For when i tried to emulate 040 and was able to get sysinfo to show 0.66 times the speed of 040/25Mhz machines speed, it was so slow that even at beginnign of game there is this full screen of text and you just push mouse button to continue and that text gets off, but when i changed that speed on the fly to that, it wouldnt even empty that text from screen until i changed that speed back to "fastest possible" in amikit.

Is it so that it is hopeless to think that any classic could run any program with layers, or is there still a possiblity that real amiga with GFX card could actually handle it fine and nice?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How heavy using layers are for classic machines?

Post by airsoftsoftwair »

Sure it can run fine on a classic. I don't see anything in that video that is particularly heavy. There's not much drawing going on so it should be perfectly manageable even on slower machines. If it isn't, then you're probably doing something in a wrong or inefficient way.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: How heavy using layers are for classic machines?

Post by Bugala »

I am copy pasting here some of the codes to do with those parts in case you can find out something that would cause it:

Code: Select all

MakeButton(1, #LAYERBUTTON, "dovelayer", False, False, {OnMouseUp = Function()
                                                       - - - Just showing some of the stuff happening and that it is inside a button - - - 
							
															p_TalkText("Ha! These are no Sheep, these are Ducks - XIAN Ducks!", "none", "goose17", 800, 400)
															p_TalkText("I know exactly what to do with these!", "none", "goose18", 800, 400)
															p_Init_Level2()
														     EndFunction})

Code: Select all

Function p_Init_Level2()
Cls()
DisplayBGPic(3)
p_PlayMusic("none")
ClickToContinue()
p_TalkText("Your Honor!", "level2goosetalk", "goose19", 300, 300)
p_TalkText("Here are the XIAN Ducks which are guilty of following!", "level2goosetalk", "goose1", 300, 400)
- - - Continues further, but just showing that right when the previous codes have happened, next thing to happen should be this - - -
and functions being used:

Code: Select all

Function p_TalkText(text, talker, sample, x, y)
If x = Nil Then x = 500
If y = Nil Then y = 400
If sample = Nil Then sample = "none"

If sample<>"none" Then p_PlayTalkSample(sample)

If talker<>"none" Then DisplayBrush(brushes[talker], x-100, y, {name="talkerlayer"})

CreateTextObject(1, text, { WordWrap=800, color=#BLACK })
DisplayTextObject(1, x + 250, y + 50)
Local bgpic = GetAttribute(#DISPLAY, 1, #ATTRBGPIC)
laynum = GetAttribute(#BGPIC, bgpic, #ATTRLAYERS)
SetLayerName(laynum, "textlayer")
Local t_layer
t_layer = GetLayerStyle(laynum)
Local width
Local height
width = GetAttribute(#LAYER, laynum, #ATTRWIDTH)
height = GetAttribute(#LAYER, laynum, #ATTRHEIGHT)
SetFillStyle(#FILLCOLOR)
Box(t_layer.x - 5, t_layer.y - 5, width+10, height+10, #WHITE, {RoundLevel = 50})
Local laynum2
laynum2 = GetAttribute(#BGPIC, 1, #ATTRLAYERS)
SetLayerName(laynum2, "textbox")
LayerToFront(laynum)

ClickToContinue()

Local playing = IsMusicPlaying(currentsample)
If playing = True Then StopMusic(currentsample)


If talker<>"none" Then RemoveLayer("talkerlayer")
RemoveLayer("textlayer")
RemoveLayer("textbox")

EndFunction

Essentially, it is first displaying text, then it gets that text objects id by taking attribute from bgpic, and then that texts attributes are taken to make the box behind the text, and when using amikit, you can clearly see this progress happening step by step making it ugly. On fast machines you dont notice that happening since it happens fast enough, hence no blitting used.

Code: Select all

Function p_PlayMusic(name)
If name="none"
	If musicplaying = True
		StopMusic(currentmusic)
		musicplaying = False
	EndIf
Else
	If musicplaying = True And currentmusic <> musics[name] Then StopMusic(currentmusic)
	If currentmusic <> musics[name]
		PlayMusic(musics[name], {times=0, volume=32} )
		currentmusic = musics[name]
		musicplaying = True
	EndIf
EndIf
EndFunction
]
Essentially just stops playing music, i doubt this has to do with it, since it is done only once, but on the other hand, problem starts after this possibly.

Code: Select all

Function ClickToContinue()
Local skip=False
While skip=False
   If IsLeftMouse() = False And IsRightMouse() = False Then skip=True
Wend

Local skip = False
While skip = False
   If IsLeftMouse()= True Or IsRightMouse() = True Then skip = True
Wend
EndFunction
This is just to avoid double clicking and to make it continue on clicking.





So thing is, that first code snipped works fine and very fast in amikit as long as i use the "fastest possible" processor option. But when it moves to that "p_Init_Level2" (which is what you see in video) it starts crawling real bad. Takes maybe second to display the next text to the screen with the box, and you can see them come to screen separately.

Is it possible that using CLS has something to do with it? For I am simply using CLS to get rid of all the buttons (Layer buttons) and everything, but does it still leave there something?

Also, I am using WaitEvent() to handle the clicks. that essentially the whole game is either waiting for Mouseclick (ClickToContinue) to continue program flow forward, or then there are buttons on screen, which are waiting for "WaitEvent" to happen in which case it continues forward.

That the mainloop is simply:

Code: Select all

Function Main()
Repeat
WaitEvent()
Forever
EndFunction

Does something stick into your eye here as something that would cause the sudden slowdown? For essentially what happens in practice is:

Code: Select all

p_TalkText("Ha! These are no Sheep, these are Ducks - XIAN Ducks!", "none", "goose17", 800, 400)
	p_TalkText("I know exactly what to do with these!", "none", "goose18", 800, 400)
        p_Init_Level2()
        Cls()
       DisplayBGPic(3)
  - - - Works up to this point very very fast.
      p_PlayMusic("none") 
     ClickToContinue()
     p_TalkText("Your Honor!", "level2goosetalk", "goose19", 300, 300)
    - - - And this previous p_TalkText line is the first line where there is great slowdown for sure, dont really know if there is also slowdown on previous two lines, since they dont show anything. - - -
       
And these are all executed in a row, that it doesnt get back to waitevent until the great slowdown have already happened.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: How heavy using layers are for classic machines?

Post by Bugala »

I realised there is one difference that happens when moving from quick part of game to cawling part of game.

On that quick part of game, i am always using "none" as attribute to "talker" variable on p_talk() function.

However, when it starts crawling, I am using something else than "none".

however, as far as i can see, there will be only two differences:

Code: Select all

If talker<>"none" Then DisplayBrush(brushes[talker], x-100, y, {name="talkerlayer"})
and

Code: Select all

If talker<>"none" Then RemoveLayer("talkerlayer")

Is there something that would trigget problem?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How heavy using layers are for classic machines?

Post by airsoftsoftwair »

I'm afraid I don't have the time to read through all this code. You'll have to analyze this on your own. You can use DumpLayers() to find out how many layers are there. The more you have, the slower it will get. If it is getting slower and slower, then you probably have a layer leak somewhere leaving you with a constantly increasing number of layers. Again, this can easily be detected by using DumpLayers() or the resource monitor offered by Hollywood.

Concerning Cls(), it will wipe all your layers in the current BGPic so everything will be gone after a Cls(). But be advised that layers are BGPic-private. Thus, if you're switching BGPics, the layers of the old BGPic won't be freed automatically. They will be kept unless you explicitly kill them.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: How heavy using layers are for classic machines?

Post by Bugala »

mainly put so much code in hopes you would have noticed for example some inefficient command in there that would be causing the problem.

however, That Dumplayer and resourcemonitor are both good tips. I plan to use that resourcemnitor to look for the problem. I didnt know there was such thing in Hollywood, but I do have been wishing for something like that. It is very useful.
Post Reply