### Author Topic: Can events flags be set in Internal Debugger?  (Read 3560 times)

0 Members and 1 Guest are viewing this topic.

#### Kawa

##### Re: Can events flags be set in Internal Debugger?
« Reply #15 on: January 14, 2024, 08:24:09 AM »
Does it mean in LSL3's room's initial room 200 when you look at the plaque, flag event 18 is set in global 112 due to 111+int(18/16) (111+1) and likewise when you use binocular for flag event 16 due to 111+int(16/16)?
In the OG code, global 111 is named flagArray and its definition is followed by an enumeration of flags by name. Each first flag in a set of sixteen has its matching global number in a comment, so it goes:
Code: [Select]
`logging ;*** 111loadDebugNext....inQAforceAtestbeenIn206 ;*** 112beenIn200beenIn203...beenIn266 ;*** 113...`and so on.

beenIn206 is the binocular peep show and beenIn203 is the plaque. So your math does not check out. Both events are global 112: 16 (plaque) divided by 16 is 1, so [flagArray 1] aka global 112. Then 16 modulo 16 makes 0, so it's the first (zeroth) bit in that global. Likewise, 18 (peepshow) divided by 16 is also 1, but 18 mod 16 is 2, so it's the second-from-zeroth bit of that same global.

(Note that LSL3 uses most-to-least flag ordering so it's actually \$8000 for the plaque and \$2000 for the peepshow, not 1 and 4. But ScummVM is aware of this and the script debugger uses the same flag procedures as the rest of the game so this doesn't matter.)

(And of course "zeroth" in this case just means it takes \$8000 and shifts it left/divides it by two zero times. Or takes 1 and shifts it right/multiplies it by two zero times for least-to-most flag ordering.)
« Last Edit: January 14, 2024, 08:36:33 AM by Kawa »

#### lwc

##### Re: Can events flags be set in Internal Debugger?
« Reply #16 on: January 14, 2024, 10:04:06 AM »
So your math does not check out. Both events are global 112: 16 (plaque) divided by 16 is 1, so [flagArray 1] aka global 112. Then 16 modulo 16 makes 0, so it's the first (zeroth) bit in that global. Likewise, 18 (peepshow) divided by 16 is also 1, but 18 mod 16 is 2, so it's the second-from-zeroth bit of that same global.
Sorry, but your line seems to contradict itself: "Both events are global 112" is exactly what my math indicated ("when you look at the plaque, flag event 18 is set in global 112...and likewise when you use binocular for flag event 16"), so why does it not check out?
Also note Plaque is 18, not 16 and binocular is 16, not 18.

#### Kawa

##### Re: Can events flags be set in Internal Debugger?
« Reply #17 on: January 14, 2024, 10:13:49 AM »
I was more tired than the size of my post would indicate.

#### lwc

##### Re: Can events flags be set in Internal Debugger?
« Reply #18 on: January 14, 2024, 10:44:05 AM »
So if we have a working math formula to discover which global to use in the debugger. Now all that's left is a formula to know what to write into that global.
Some examples:
• The initial value of 112 is \$4000.
• If your only action is looking at the plaque (flag 18), it turns 112 from \$4000 to \$6000.
• If your only action is using the binocular (flag 16), it turns 112 from \$4000 to \$c000.
• If you do both, it turns 112 to \$e080.
Is there any formula to know what to write in the debugger to 112 in order to trigger those flags?

#### Kawa

##### Re: Can events flags be set in Internal Debugger?
« Reply #19 on: January 14, 2024, 11:04:25 AM »
You take the value that's already there, calculate \$8000 >> (flagNum % 16), and combine 'em with a binary (not logical) OR. That's what SetFlag does, and that's what you can do.

Going by your example, \$4000 would be 0100'0000'0000'0000 in binary. Flag 18 % 16 is 2, so we take \$8000 >> 2 = \$2000 is 0010'0000'0000'0000. (If LSL3 were least-first ordered you'd do \$0001 << 2 instead to get 4)

0100'0000'0000'0000 => \$4000, your initial state
0010'0000'0000'0000 => \$2000, looking at the plaque
OR that together (the |= in SetFlag) and you get
0110'0000'0000'0000 => \$6000

If we [t]then[/t] look at the binoculars, it takes \$8000 >> (16 % 16) = still \$8000, and we get
0110'0000'0000'0000 => \$6000, previous state
1000'0000'0000'0000 => \$8000, looked through binoculars
makes
1110'0000'0000'0000 => \$E000

#### lskovlun

##### Re: Can events flags be set in Internal Debugger?
« Reply #20 on: January 14, 2024, 01:59:15 PM »
And since four bits equals one hex digit, you can make a simple table and use that. You're only going to need four columns, assuming you only set/clear one bit at a time.
« Last Edit: January 14, 2024, 02:00:49 PM by lskovlun »

#### lwc

##### Re: Can events flags be set in Internal Debugger?
« Reply #21 on: January 14, 2024, 04:22:13 PM »
And since four bits equals one hex digit, you can make a simple table and use that. You're only going to need four columns, assuming you only set/clear one bit at a time.
Any way to replace this table with a simple formula (like the one to find the relevant global)?

#### lskovlun

##### Re: Can events flags be set in Internal Debugger?
« Reply #22 on: January 14, 2024, 07:04:36 PM »
As explained several times, \$8000 >> (x % 16). It is equivalent to 215/2x. Then OR with that to set the bit, or AND with the complement to clear it.
« Last Edit: January 15, 2024, 07:16:57 AM by lskovlun »

#### doomlazer

##### Re: Can events flags be set in Internal Debugger?
« Reply #23 on: January 17, 2024, 08:55:34 PM »
@lwc, I've updated the LSL3 debug info on the SCIWiki and created a patch file in my personal repo that adds flag testing and toggling.

#### lwc

##### Re: Can events flags be set in Internal Debugger?
« Reply #24 on: January 18, 2024, 05:06:05 AM »
Nice! You might want to fix that Alt+I does work in the regular debug (allows typing during cutscenes), and maybe link to your patch there.
« Last Edit: January 19, 2024, 04:37:29 AM by lwc »

#### Collector

##### Re: Can events flags be set in Internal Debugger?
« Reply #25 on: January 18, 2024, 06:28:32 AM »
You can upload the patch to the Wiki. You should have upload rights. Just look at the source for the EQ1CD debug package to see how to create the link. After you save it just click on the red link it creates to open the upload dialog.

#### lwc

##### Re: Can events flags be set in Internal Debugger?
« Reply #26 on: January 18, 2024, 11:14:58 AM »
You can upload the patch to the Wiki. You should have upload rights. Just look at the source for the EQ1CD debug package to see how to create the link. After you save it just click on the red link it creates to open the upload dialog.
Do you mean me? I don't even have edit rights, since the wiki is closed for registering.