Community

SCI Programming => SCI Syntax Help => Topic started by: mrprmiller on October 26, 2017, 11:11:13 PM

Title: Memory Fragmentation in QFG2
Post by: mrprmiller 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 https://www.youtube.com/watch?v=K4CU5VHU1Gg (https://www.youtube.com/watch?v=K4CU5VHU1Gg), 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?
Title: Re: Memory Fragmentation in QFG2
Post by: lskovlun on October 27, 2017, 11:35:05 AM
Well, two things:
Title: Re: Memory Fragmentation in QFG2
Post by: c-square 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!
Title: Re: Memory Fragmentation in QFG2
Post by: mrprmiller 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
Title: Re: Memory Fragmentation in QFG2
Post by: Kawa 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 >.
Title: Re: Memory Fragmentation in QFG2
Post by: lskovlun on November 02, 2017, 01:23:37 PM
But you did get it to work. Was that by luck, or did you do something?
Title: Re: Memory Fragmentation in QFG2
Post by: lskovlun 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:
Title: Re: Memory Fragmentation in QFG2
Post by: c-square 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.
Title: Re: Memory Fragmentation in QFG2
Post by: MusicallyInspired 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.
Title: Re: Memory Fragmentation in QFG2
Post by: lskovlun 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?