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.

Emulation & ROM Hacking

GBZ80 - Teleportation - Page 1

GBZ80 - Teleportation

Posted by: Th3B0r3d
Date: 2017-11-08 12:45:24
I'm trying to make item in Pokémon red  that after using warps to predefined location. How to do such thing in assembly? (I know how to edit item's usage but I still need code that will warp you)

Re: GBZ80 - Teleportation

Posted by: ISSOtm
Date: 2017-11-09 05:39:28
What are you trying to do exactly, editing the warps in the current map ? All warps, or just one ?

Re: GBZ80 - Teleportation

Posted by: Th3B0r3d
Date: 2017-11-09 12:53:17
I'm trying to make item that after usage warps you to some place.

Re: GBZ80 - Teleportation

Posted by: ISSOtm
Date: 2017-11-09 18:14:07
You mean, that warps you to a given map once you use the item (but after closing the menu), right ?

Re: GBZ80 - Teleportation

Posted by: Th3B0r3d
Date: 2017-11-10 09:03:50

Re: GBZ80 - Teleportation

Posted by: Torchickens
Date: 2017-11-10 10:38:54
I have an answer that's incomplete as I don't actually know without further research how to properly execute this either, sorry.

However you can try:

ld a,(map ID)
ld (d35e),a
ld h, d3
ld l, 6e
ld a,41
ld (hli),a
ld a,12 [1241 is LoadMapData in pokered disassembly]
ld (hli),a

After closing the menu, this will warp you anywhere but Glitch Cities may appear depending on exactly where you warped from. Refreshing the map is also possible by placing X Attack x18 into item 41 (level-script pointer, D36E-D36F) and the map's ID into item 33 (D35E).

For more complex purposes, as Glitch Cities can appear depending on where you warp from, you may have to specify the data for these addresses in some way or get the game to look them up:

D35F-D360 = Top-left block pointer
D361 - 1 byte integer = Current Player Y-Position
D362 - 1 byte integer = Current Player X-Position
D363 = Current Player Y-Position (Current Block)
D364 = Current Player X-Position (Current Block)
D3B1 = Entrance position ID (affects D35F-D360)
D3B5 = Entrance position ID (affects D35F-D360)

(Note all of these addresses (for Red/Blue) are -1 in Yellow)

If you just want to warp and don't mind having to walk through the exit of a door, you can modify D365. This address is the location specific exits like those from Pokémon Centers and many houses take you. But the entrance position ID stays the same as the one from the original map, so you've got to find one that works, use cheat code 010xxB5D3 01xxB1D3 to modify the entrance position ID, or alternatively do this:

Change D3B1 to the entrance position ID (e.g. 01).
Change D3B2 to the desired map (or FF for the map stored in D365).

Then you need to walk through the first warp of the building. (In a Pokémon Center this should be the left-side of the exit mat).

Also for what it's worth D3AF-D3B0 are the y and x-coordinates of the warp, but you'll need a proper map tile for this to work.

Hope this helps and I hope somebody with better coding knowledge than me is able to assist. :)