Author Topic: Memory Fragmentation in QFG2  (Read 7078 times)

0 Members and 1 Guest are viewing this topic.

Offline mrprmiller

Memory Fragmentation in QFG2
« on: October 26, 2017, 11:11:13 PM »
Hey all.

I'm a speedrunner of the Quest for Glory series.  Right now, I'm helping to work on a tool-assisted speedrun of QFG2.  We worked already on a speedrun of the first game , and as we were finishing the second game, we're running into a fragmentation error at the literal (not figurative) worst possible spot in the run: the final screen transition after killing the final enemy.

In a normal playthrough, this isn't a problem.  In a TAS, it's a frustrating problem.  While we can look through the code, we're both very ignorant of memory and the SCI engine.  Is there anyone who can help us understand what's going on and how to avoid this?



Offline lskovlun

Re: Memory Fragmentation in QFG2
« Reply #1 on: October 27, 2017, 11:35:05 AM »
Well, two things:
  • From the "memory fragmented" dialog, enter the debugger, then press f to get the free heap display.
    This will tell us the size and location of the fragments. I'm not too experienced with the interpretation, though. Inspecting the given memory addresses might help as well. (if the object header 34 12 shows up close to the base address, it's a freed object for example). There is a file in the - now public - SCI distribution which shows some others. https://github.com/OmerMor/SCI16/blob/master/DOC/FRAGMENT.DOC
  • A savegame, as close as possible to the crash. If it is possible to recreate the situation "by hand" starting from that savegame, so much the better.

Offline c-square

Re: Memory Fragmentation in QFG2
« Reply #2 on: November 01, 2017, 09:44:27 PM »
Hi lskovlun,

Here's the code that's causing the issue:

Code: [Select]
(if (u> (MemoryInfo 1) (+ 20 (MemoryInfo 0)))
If that triggers, it gives the error message.

MemoryInfo 1 is the free heap.  MemoryInfo 0 is the largest ptr.  I don't understand what u> is, so I don't know what kind of comparison it's looking for.

I don't know how to use 'f' to get to the debugger.  The only debug mode I can seem to access is the one you get by typing "Suck Blue Frog".

I tried jumping to the end to create a save file, however it doesn't load the save file properly, so I'm out of luck on that account.

Cheers!
« Last Edit: November 01, 2017, 09:53:06 PM by c-square »

Offline mrprmiller

Re: Memory Fragmentation in QFG2
« Reply #3 on: November 02, 2017, 09:53:17 AM »
MemoryInfo 1 is the free heap.  MemoryInfo 0 is the largest ptr.  I don't understand what u> is, so I don't know what kind of comparison it's looking for.

I don't know how to use 'f' to get to the debugger.  The only debug mode I can seem to access is the one you get by typing "Suck Blue Frog".
That's actually how to start it.  "suck blue frog" and then <ALT+F> to give the memory information.

I tried jumping to the end to create a save file, however it doesn't load the save file properly, so I'm out of luck on that account.
Bah.  Emulators.  :D

Offline Kawa

Re: Memory Fragmentation in QFG2
« Reply #4 on: November 02, 2017, 10:00:24 AM »
I don't understand what u> is
Unsigned Larger Than. Is the free heap space larger than the largest pointer plus another 20, as unsigned values. With large enough values, they might be mistaken for negative if it used regular >.

Offline lskovlun

Re: Memory Fragmentation in QFG2
« Reply #5 on: November 02, 2017, 01:23:37 PM »
But you did get it to work. Was that by luck, or did you do something?

Offline lskovlun

Re: Memory Fragmentation in QFG2
« Reply #6 on: November 02, 2017, 02:19:50 PM »
That's actually how to start it.  "suck blue frog" and then <ALT+F> to give the memory information.
Actually, I meant this:

Offline c-square

Re: Memory Fragmentation in QFG2
« Reply #7 on: November 19, 2017, 12:40:59 AM »
Actually, I meant this:
Woah!  I have no clue how to bring that up.  Please let me know how you did that.

Offline MusicallyInspired

Re: Memory Fragmentation in QFG2
« Reply #8 on: November 19, 2017, 01:22:50 AM »
Hold down both SHIFT keys plus the "-" symbol on your numpad to being up the SCI debug.
Brass Lantern Prop Competition

Offline lskovlun

Re: Memory Fragmentation in QFG2
« Reply #9 on: November 19, 2017, 12:43:55 PM »
I'm a bit confused here. I was expecting QfG2 to show the same two-button dialog as the later SCI1 games (Memory fragmented  [Who cares] [Debug]). The one in QfG2 actually has only one button, but it should still bring up the debugger as shown (from which the procedure in my first post was supposed to work). It also seems that, for QfG2 to check for fragmentation at all, it must be in the 'suck blue frog' mode? I wanted a snapshot as close to the crash as possible, so this would be preferable to opening the debugger manually, but if there's no other way...

Also, you did finish your playthrough, didn't you?


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.035 seconds with 23 queries.