Main Menu
Main Page
Forums
New pages
Recent changes
Random page
Help

Glitches
Arbitrary code execution
Pokémon cloning
Pomeg glitch and Glitzer Popping
Tweaking and voiding
Glitches by generation
Glitch categories

References/Resources
Databases
Disassembly projects
The Big HEX List
Pokémon cheat codes
Pokémon glitch terminology
Useful tools
More

Affiliates
Legendary Star Blob 2 (Hakuda) (日本語/Japanese)
Pokémon Speedruns wiki (English)
PRAMA Initiative (Français/French)
MissingNo. Glitch City (Italiano/Italian)
Become an affiliate!

Technical
Site source code

Search Wiki

 

Search Forums

 

Author Topic: WTW mechanics discussions  (Read 3470 times)

0 Members and 1 Guest are viewing this topic.

SatoMew

  • Member+
  • *
  • Offline Offline
  • Gender: Female
    • View Profile
Re: WTW mechanics discussions
« Reply #15 on: February 23, 2015, 10:07:23 am »
Because it is an array index of CCD3. If you execute this code in Red/Blue:
Code: [Select]
call $3486while 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)?

pigdevil2010

  • Member+
  • Offline Offline
  • Gender: Male
  • Welcome to the 40 ERROR.
    • View Profile
Re: WTW mechanics discussions
« Reply #16 on: February 23, 2015, 01:10:46 pm »
Because it is an array index of CCD3. If you execute this code in Red/Blue:
Code: [Select]
call $3486while 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.

SatoMew

  • Member+
  • *
  • Offline Offline
  • Gender: Female
    • View Profile
Re: WTW mechanics discussions
« Reply #17 on: February 23, 2015, 03:17:21 pm »
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?

bbbbbbbbba

  • Wiki Contributor
  • *****
  • Offline Offline
  • CHARIZRAD 'M ROXORX or is it.
    • View Profile
Re: WTW mechanics discussions
« Reply #18 on: March 11, 2015, 03:25:55 pm »
Because it is an array index of CCD3. If you execute this code in Red/Blue:
Code: [Select]
call $3486while 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).

ISSOtm

  • The French Lord of Laziness (and a huge The Legend Of Zelda fan)
  • Staff
  • *****
  • Offline Offline
  • Gender: Male
  • Pewter City (B)rocks !
    • View Profile
    • My Little Website
Re: WTW mechanics discussions
« Reply #19 on: June 10, 2015, 09:42:27 am »
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.
Code: [Select]
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 ?)
Code: [Select]
  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.

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 !
« Last Edit: June 10, 2015, 11:56:41 am by ISSOtm »
"THOU SHALL NOT PASS !!"  RIVAL's effect, Gandalf.

Proudly glitching Pokémon Red and Yellow on a Black & White GB, Pocket GB, GB Color, GBA SP and new 3DS.

My Twitter (beware, I'm French)
My YouTube (same warning)

Here is an online tool to build 8F setups : GBz80 to Items !

They see me layzin', they ha-tin'...
Heavy contributor of the global augmentation of entropy (my room's is too damn high !)

Princess Torchic Owl Lover ☽ ❤

  • Head Administrator
  • *****
  • Offline Offline
  • Gender: Female
  • Aspiring mother. 🦋 ✿
    • View Profile
Re: WTW mechanics discussions
« Reply #20 on: June 12, 2015, 08:21:44 am »
Cheers for your research, ISSOtm.

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post ^^
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory)

✿ Hi, I'm Evie. Sex male, and spiritually doesn't believe 'male'/'female' needs to be defined; lives more stereotypically like a woman. Call me whichever pronouns you like. :)

Feel free to contact me here about anything regarding the site.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3