Logic resource length

lemur Hi,
Does someone know what maximum length in bytes logics have? For example how big can Logic.002 be without getting problems?

Just wondering cause I've gotten some strange errors where prints are cut and only the first 5 characters are printed. Everything seems to be correct in the code and I get no complaints when I compile.
sonneveld Well you usually have 32k of free memory when you get to load your own resources. However, it sounds like a compiler problem though.

- Nick
Andrew_Baker I didn't know there was a maximum script length. I know from experimentation that you can only have 256 #messages, though..
Joel I think the maximum size of any resource is 65535 bytes, because all the resources have to be stored in the VOL files for the game, and the VOL file only allocates two bytes to store the length of each resource.

I think the limit on messages goes something like this: no more than 256 different messages and the combined length of the messages can't make the whole compiled logic file more than 65535 bytes. You also have to factor in that, for each message number, there has to be a two byte offset that tells where the message is relative to the start of the message section in the compiled logic. Those are included in the 65535 byte limit.
Joel BTW, just because the max. resource size is 65535 byte doesn't mean that a game would work with resources that big. There is a limited amount of memory in each room (65535 bytes total, I think, which includes loading logic 0 and all the views).
sonneveld actually I think you can access more than 256 messages but I haven't played around with it too much since I think the current compiler won't allow it.

commands like print and display can only access the first 256 messages since you can only send a byte as an argument.. but you can also refer to messages within messages..

"message = %m500"

I'm pretty sure that internally, the agi interpreter reads these numbers as a 16 bit number but I haven't been able to check if it will work properly (I haven't checked load routines 'n stuff yet).

The only reason why I'm interested is because I'm looking into ways to sort of "compress" messages by looking for common strings and taking them out. If you already have 256 messages defined (like in a quiz or a debug logic) then it would be nice if you could resort to other methods.

- Nick
Joel According to the AGI Specs, at the beginning of the text section, the compiled logic stores how many messages there are in a one-byte value (probably so the message offset list can be compressed significantly in the average case...with that byte, only the messages that actually exist need offsets stored).

So, actually, the limit is 255, not 256.
sonneveld heh.. whoops. like I said, I still hadn't really looked into it much. easy to miss (if you don't read the specs) since a lot of values are passed around as words in the interpreter.

the compression idea still stands though. it might not be as effective as I hoped, but I'll still look into it.

- Nick
lemur Thanks guys, I'll see if this will cast some light on this troublesome bugshadow. (?) :-)
sonneveld once again, if you want, post me the compiled logic and it's source and I'll have a look if you want.

- Nick
Eigen Sometimes I get a error message: "Need -56435 have -45348" But if delete some code lines it disseapears. Any thoughts?
sonneveld depends.. it might not depend on your logic as much as other things. it might depend on whether you load too many views or you've converted some music to agi format and it's very large.

- Nick
Andrew_Baker Off-topic: Also, if you use the teleport ("tp") command, you won't reclaim your buffer like you would if you entered a room normally.

On-topic: So, I'm looking for a way to accurately gauge the limit of my logic files. Can I view the file size of the compiled logic and use that as a proper yardstick?
Joel What makes you think that you don't get your buffer back if you use "tp"?

In my game, the tp command is carried out by calling new.room.v(). Unless yours is implemented differently, it should behave no differently than a call to new.room().

I don't believe the max. buffer or max. script numbers ever go down, but the actual amount of memory used does go down.
lemur Must've been some temporary glitch with the compiler. Now everything's working as it should. But this way I learnt alot of good to know things about memory handling in AGI.
Andrew_Baker I don't know why "tp" doesn't recover my buffer, but I've tested it empirically by checking the memory every time I tp to a new room, and the memory isn't reclaimed. I've also had some "out of memory" errors after tp'ing, like, three times.
Joel I was able to duplicate the problem, but not with Jen's Quest. It appears to be a problem with the updated template game. I tested it with multiple interpreter versions (the hacked 2.936 that ships with the template game, the unhacked 2.936 on agidev.com, and the 2.917 I use with Jen's Quest), and the problem occurred with every interpreter version I tried.

Jen's Quest is based off the template game that shipped with AGI Studio 1.31...whatever the problem is, it was introduced into the template game since then, because the problem doesn't exist with my game.

To get some info about the nature of the problem...I tp'ed to room 2 over and over again, and the "now" memory did increase every time. However, it did not double, which means that it's not simply a matter of the buffer not being reclaimed. As I said, I'm able to tp to my own room 2 as much as I like and the "now" memory stays constant.

I'd say this problem warrants some investigation, because you're probably not the only one it's going to hit.
Eigen But I only have some inputs and two views loaded and I still get the message.
Joel "Need -56435 have -45348"

Are those intended to be negative signs? I'm going to operate under the assumption that they are not.

It sounds like you have lots of free memory but one of your lines of code is attempting to load a HUGE resource (of size 56435), and the load is failing.
Andrew_Baker How big (pixel X pixel) are the views?