Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Generation I Glitch Discussion

WTW mechanics discussions - Page 2

Re: WTW mechanics discussions

Posted by: SatoMew
Date: 2015-02-23 10:07:23

Because it is an array index of CCD3. If you execute this code in Red/Blue:
call $3486
while CD38 is set to 4 and CCD3-CCD6 are filled with 08 (start button joypad constant). You can see that the game starts to act like you pressed start button 4 times and the value at CD38 will decrease. Since the script mostly load direction buttons to CCD3, one may mistake that it's a step counter.


Thanks for the explanation :)

So what exactly happens when CD38 is set to 01 (which is what the well-known "walk through walls" GameShark code 010138CD does)?

Re: WTW mechanics discussions

Posted by: pigdevil2010
Date: 2015-02-23 13:10:46


Because it is an array index of CCD3. If you execute this code in Red/Blue:
call $3486
while CD38 is set to 4 and CCD3-CCD6 are filled with 08 (start button joypad constant). You can see that the game starts to act like you pressed start button 4 times and the value at CD38 will decrease. Since the script mostly load direction buttons to CCD3, one may mistake that it's a step counter.


Thanks for the explanation :)

So what exactly happens when CD38 is set to 01 (which is what the well-known "walk through walls" GameShark code 010138CD does)?


Collision check will check this value. If it's non-zero, it won't block the player (this thing may applied to avoid a player bumping with an NPC or unwanted objects during walking I suppose?)
. But since the joypad simulation script is not running, this value won't be decremented.

Also, I found out that the code at $3486 also involves setting bit 7 of D730 ([D730] = [D730] | $80) too. Maybe this is used for overworld movement script.

Re: WTW mechanics discussions

Posted by: SatoMew
Date: 2015-02-23 15:17:21

Collision check will check this value. If it's non-zero, it won't block the player (this thing may applied to avoid a player bumping with an NPC or unwanted objects during walking I suppose?)
. But since the joypad simulation script is not running, this value won't be decremented.

Also, I found out that the code at $3486 also involves setting bit 7 of D730 ([D730] = [D730] | $80) too. Maybe this is used for overworld movement script.


Thanks. Do you know if there's an equivalent to CD38 in the Generation II games?

Re: WTW mechanics discussions

Posted by: bbbbbbbbba
Date: 2015-03-11 16:25:55



Because it is an array index of CCD3. If you execute this code in Red/Blue:
call $3486
while CD38 is set to 4 and CCD3-CCD6 are filled with 08 (start button joypad constant). You can see that the game starts to act like you pressed start button 4 times and the value at CD38 will decrease. Since the script mostly load direction buttons to CCD3, one may mistake that it's a step counter.


Thanks for the explanation :)

So what exactly happens when CD38 is set to 01 (which is what the well-known "walk through walls" GameShark code 010138CD does)?


Collision check will check this value. If it's non-zero, it won't block the player (this thing may applied to avoid a player bumping with an NPC or unwanted objects during walking I suppose?)
. But since the joypad simulation script is not running, this value won't be decremented.

Also, I found out that the code at $3486 also involves setting bit 7 of D730 ([D730] = [D730] | $80) too. Maybe this is used for overworld movement script.


Right, bit 7 of D730 determines whether "the joypad simulation script is running". More accurately, that bit is checked every time the game reads joypad input in the overworld. If it is set, a simulated input is read from a sequence (starting at CCD3), with CD38 as an decreasing index (it is decreasing so that the game knows to end the simulation when it goes to 0).

Re: WTW mechanics discussions

Posted by: ISSOtm
Date: 2015-06-10 10:42:27
Something else : for the ledge method of WTW, we simply have CD38 non-zero with bit 7 of D730 deactivated.
However, the Museum guy method is different.

There is a path, indeed, that is written and that you follow; but it is THAT large, that it actually overwrites another very important byte : wOverrideSimulatedJoypadStatesMask (according to Pokéred's disassembly), which is CD3B.

To make things clear, this is a piece of pseudo-code that seems to be the game's logic for movement.

If D730 's 7th bit is set, then
  Perform logical AND of CD3B and joypad input
  If result is non-zero then
    Put joypad input in _move
  Else
    Read the byte at CCD3 + [content of CD37], and put it into _move
    Increase CD37
    Decrease CD38
    If CD38 is zero, then
      Reset bit 7 of D730
    EndIf
  EndIf
Else
  Put the joypad state into _move
EndIf
Change direction the player is facing
If the tile the player is facing is non-solid OR CD38 is non-zero
  Move once in the direction the player is facing
EndIf

Note : _move isn't the content of a memory address, I suppose it is any of the 8-bit z80 registers.
There is a logic behind collision deactivation if CD38 is non-zero : as much more code is read if CD38 is non-zero, it seems legit do skip collision detection to compensate. Also pre-programmed paths should never fail (we all know that when glitches are thrown into the mix, pre-programmed paths DO fail :P)
All this code and hypotheses are totally empirical, and have NOT been checked against the disassembly. It just seems that it works so.

I'd then categorize WTW methods as follows :
1. CD38 non-zero, but bit 7 of D730 reset (ledge method, select bug/ACE methods)
2. CD38 non-zero, bit 7 of D730 set, but CD3B is non-zero (Museum guy, Youngster methods)

According to this post of mine, a spot for "Museum guy" WTW disallows up/down movement. However, holding left/right will allow up/down movement, and as up/down key presses are checked first in the overworld movement script, you may go up/down. (e.g. it wouldn't work if only U/D was allowed)



This means if you Trainer-Flied from Route 8, beat a Trainer from another route, viewed that sign in Lavender Town then returned to Route 8 the game would bring up her text (I confirmed it bringing up her text from after battle and I previously beat her, maybe the game would bring up her text before battle if you didn't beat her?)

Absolutely, tested it on VBA and real hardware.


Right, bit 7 of D730 determines whether "the joypad simulation script is running". More accurately, that bit is checked every time the game reads joypad input in the overworld. If it is set, a simulated input is read from a sequence (starting at CCD3), with CD38 as an decreasing index (it is decreasing so that the game knows to end the simulation when it goes to 0).

Looks like CD37 is an increasing index, to track the position of the player in the guide list ? Or is it a step counter ?
Still, CD38 is used by the collision engine, and D730 by the overworld movement script.

I have a theory about guidance list reading :
# Either the list is read backwards, then the game reads byte at CCD3 + [content of CD38] if CD38 is non-zero;
# Or the list is read forwards, then the game uses the formula presented in the above pseudo-code section.
No idea which is correct.
[EDIT after testing on BGB]
The list is read backwards.

Initialization seems to work like so :
1. Start at CCD3
2. Increment (CD38).
3. Is it $FF ?
4. If no, repeat from step 2, looking at the next address in RAM.
(like this asm ?)

  ld bc, CCD3
  ld hl, CD38
guidanceInitLoop:
  inc (hl)
  ld a, (bc)
  inc bc
  cp $FF
  jr nz, guidanceInitLoop




Collision check will check this value. If it's non-zero, it won't block the player (this thing may applied to avoid a player bumping with an NPC or unwanted objects during walking I suppose?)
.

Actually, you're right : you partially clip into the NPC guiding you.
[img]http://i.imgur.com/ViH15wX.png[/img]
Should try changing the collision detection to still work during guidance. I think you'll bump into Oak ? (If yes, you'll freeze after a while, when Oak enters the lab, much like the glitch using the girl to prevent Red correctly following Oak and thus, never entering the lab)




Collision check will check this value. If it's non-zero, it won't block the player (this thing may applied to avoid a player bumping with an NPC or unwanted objects during walking I suppose?)
. But since the joypad simulation script is not running, this value won't be decremented.

Also, I found out that the code at $3486 also involves setting bit 7 of D730 ([D730] = [D730] | $80) too. Maybe this is used for overworld movement script.


Thanks. Do you know if there's an equivalent to CD38 in the Generation II games?

More or less. Looks like Generation II uses a different method : there are four addresses that control collision (one per direction). That's the "WTW" part of CD38. For the "guidance" part, there must be an equivalent of CD38, but I have no idea where it is located in memory.

I'll peek at the disassembly later to (in-)validate my "bullshit theories", I'll be back !

Re: WTW mechanics discussions

Posted by: Torchickens
Date: 2015-06-12 09:21:44
Cheers for your research, ISSOtm.