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

Documenting Item Underflow Item slots. - Page 1

Documenting Item Underflow Item slots.

Posted by: luckytyphlosion
Date: 2014-05-04 14:37:48
Now that I know much more about Item Underflow (and have the wram map disassembly), I have a more clear understanding of each item:

items 1-20 + quantity = normal stuff
item 21 = end of list
quantity = first money byte
item 22 = second money byte
quantity = third money byte
item 23-27 + quanity = rival name
item 28 = rival name
item 28 quantity = options
item 29 = badges (written in binary)
item 29 quantity = ???
item 30 = ???
item 30 quantity = First part of tid
item 31 = second part of tid
item 31 quantity = ???
item 32 = ??? (usually ultra ball/brightness)
item 32 quantity = brightness/palletes
item 33 = map id
item 33 quantity = first part of top left block pointer
item 34 = second part of top left block pointer
item 34 quantity = y coord
item 35 = x coord
item 36 quantity = block y coord
item 37 = block x coord
item 37 quantity = last outside map visited (warping)
item 38 = ??? (appears to be based on last map)
item 38 quantity = map tileset, controls fly/dig/teleport (Executed upon entry)
item 39 = map height
item 39 quantity = map width
item 40 = first part of map pointer (executed upon entry)
item 40 quantity = second part of map pointer
item 41 = first part of text pointer (executed upon talking to someone)
item 41 quantity = second part of text pointer
item 42 = first part of map script pointer (executed upon closing menu)
item 42 quantity = second part of map script pointer
item 43 = map connections
item 43 quantity = north connection data ("walking" warp for north)
item 44-48 + quantity = ??? (based off of north connection data)
item 49 = south connection data
item 49 quantity to item 54= ??? (based off south connection data)
item 54 quantity = west connection data
item 55 to item 59 quantity = ??? (etc)
item 60 = east connection data
item 60 quantity to item 64 = ??? (etc)
item 64 quantity to item 69 quantity = sprites on the map
item 70 = sprite set id
item 70 quantity = ???
item 71 = ???
item 71 quantity = ???
item 72 = ???
item 72 quantity = ???
item 73 = number of warps
item 73 quantity =

Then the items get really weird from here, so I'm not sure exactly to put. In an outside map the item 73 and below represent all the outside to inside warps, and it looks like warps are displayed in this format:

Item 1 quantity = Y coord
Item 2 = X Coord
Item 2 quantity = Map Index
Item 3 = Map to Warp to.

Most warps are accessible, but then the game warps but the inventory loops back to the top after 128 items, while the warps keep going. This format also works for inside maps, except there's much less warps, and item 3 is map 255, which corresponds to the last outside map.

Will add more discoveries later.

Re: Documenting Item Underflow Item slots.

Posted by: pokechu22
Date: 2014-05-04 15:11:40
You probably could use a ram map.  The first item is [tt]D31E[/tt], so that can help. 

Re: Documenting Item Underflow Item slots.

Posted by: luckytyphlosion
Date: 2014-05-04 15:43:58
The only problem with that RAM Map is that it doesn't have anything past address D39C, which is most of the unknown item slots.

Re: Documenting Item Underflow Item slots.

Posted by: bbbbbbbbba
Date: 2014-05-05 01:01:56
As a first step, maybe you should see wram.asm in iimarkus's disassembly, https://bitbucket.org/iimarckus/pokered/src. It is slightly more complete.

Edit: well, there is still a laaaarge gap in the area you care about the most. I do have one thing to add: $d3ae is the number of warps in the current map, and the actual warp data begins from $d3af. There are 4 bytes for a warp: the Y coordinate, the X coordinate, target warp ID and target warp.

Edit: seems that I have one more thing.


Item 30: ??? (always Master Ball)


This, $d358, is some bit flags used by the text processor. It is normally 1 (hence the master ball), and it becomes 3 whenever the game prints a message "one letter at a time" (like NPC quotes and messages in battles).

I have never seen the LSB zeroed (values 0 or 2) except when resetting the game; the code suggests that this will happen when you successfully enter the cable club, but it is hard to verify on an emulator. Anyway, setting the LSB to 0 seems to cause the game to disregard the text speed in options, and always use "fast".

Re: Documenting Item Underflow Item slots.

Posted by: camper
Date: 2014-05-05 05:02:35
Item 34 quantity is the Y-coordinate. (D361)

Item 36 quantity is used for previous speedruns to change the map ID when you walk from an indoor map to an outdoor map. (D365)

Re: Documenting Item Underflow Item slots.

Posted by: Bent`
Date: 2014-05-05 05:55:41

As a first step, maybe you should see wram.asm in iimarkus's disassembly,

The current link for that is on Github. I try to keep the BitBucket link updated but it has a tendency to fall behind.

Re: Documenting Item Underflow Item slots.

Posted by: luckytyphlosion
Date: 2014-10-26 22:30:41
Bump because majorly fixing/editing first post.

Re: Documenting Item Underflow Item slots.

Posted by: luckytyphlosion
Date: 2014-11-11 21:13:24
More discoveries I was too lazy to post!

You-know-who posted the raw connection data from "somewhere", which is this:
struct Connection { u8 mapIndex, u16 connectedMapBlockData, u16 currentMapPositionRAM, u8 connectionWidth, u8 connectedMapWidth, u8 yAlign, u8 xAlign, u16 topLeftPointerAfterEnteringMap

In item underflow, after the map index, South and East Connections are structured like this:

1.  item 1Q = First part of Connected map block data
2.  item 2  = Second Part of connected map block data
3.  item 2Q = 1st part of Current map position in ram (???)
4.  item 3  = 2nd part of Current map position in ram (???)
5.  item 3Q = connection width (doesn't seem to change, most likely loaded upon entering map)
6.  item 4  = connected map width
7.  item 4Q = Y coord align (positive numbers (signed) will add (down) to the player's y coord depending on that number while negative numbers will subtract (up) from the player's y coord depending on that number. Note that this doesn't reflect a change in what the overworld looks like, but reflects a change on the ycoord)
8.  item 5  = X coord align (same case as above except with xcoord. Positive numbers add (right) while negative numbers subtract (left))
9.  item 5Q = 1st part of top left block Pointer
10. item 6  = 2nd part of top left block Pointer

While North and West are structured like this:

1.  item 1  = First part of Connected map block data
2.  item 1Q = Second Part of connected map block data
3.  item 2  = 1st part of Current map position in ram (???)
4.  item 2Q = 2nd part of Current map position in ram (???)
5.  item 3  = connection width (doesn't change from what I'm seeing)
6.  item 3Q = connected map width
7.  item 4  = Y coord align(positive numbers (signed) will add (down) to the player's y coord depending on that number while negative numbers will subtract (up) from the player's y coord depending on that number. Note that this doesn't reflect a change in what the overworld looks like, but reflects a change on the ycoord)
8.  item 4Q = X coord align (same case as above except with xcoord. Positive numbers add (right) while negative numbers subtract (left))
9.  item 5  = 1st part of top left block Pointer
10. item 5Q = 2nd part of top left block Pointer

Something I found out today is that changing tileset data to a positive number results in the blocky, blockx, top left pointer, y coord and x coord to shift somewhere else when loading another map from connection data. The amount changed to doesn't matter, but what does matter is the last map's tileset visited. If the last map's tileset was 0 and the map you're currently on has a tileset of 0, then nothing happens. If the last map's tileset was 2, and the map you're currently on is 0, then you would get shifted, but I don't know the exact number/figure.

If you change the tileset data to a "negative" number, and load another map through connection data, then the map, text and script pointer are not loaded (not sure about top left pointer though). Usually if you swap script pointer, you can either get crazy effects, or the game will crash. There are probably other addresses that aren't updated either, but I haven't looked into it much.

Re: Documenting Item Underflow Item slots.

Posted by: Torchickens
Date: 2015-01-01 12:29:53
Can somebody give memory addresses for the start of the North and West connection and South and East connection structure please? I want to do a custom "instaCT" and lucky says in this post that you have to change the top left block pointer (I assume as part of that structure), and map width, and align yourself to the correct BlockY/X position.

As map index (item 75?) is D3B2, I tried corrupting the bytes after it and using a north connection, but nothing happened? Am I on the wrong address.

I tried the first instaCT described here, but it seems to be of a different sort. All it did was change one byte of the event displacement data (D360).

If that is a different sort of instaCT, I think that you should give these connection instaCTs a different name to avoid confusion in my opinion, like "connection instaCT" but of course, you don't have to.

Edit: Thanks to Datacrystal, apparently D371-D37B = Map's 1st Connection Data, D37C-D386 = Map's 2nd Connection Data, D387-D391 = Map's 3rd Connection Data, D392-D39C = Map's 4th Connection Data.

I didn't search through it good enough. But that doesn't seem to be the same thing. It has a different structure (starting with the first byte being the destination, as described in item 43 quantity).

Re: Documenting Item Underflow Item slots.

Posted by: Dabomstew
Date: 2015-01-01 15:22:50
The topleft block pointer you need to change for instaCTs is this:


item 33 quantity = first part of top left block pointer
item 34 = second part of top left block pointer


Edit: For that particular instaCT (the Dratini one), the first part of the instructions uses the "item 35 = x coord" to mutate a Poke Doll into a Nugget in order to allow us to do it in the speedrun with an item from Celadon Mart. The actual instaCT bit is only the bit after the Nugget is created.

Re: Documenting Item Underflow Item slots.

Posted by: Torchickens
Date: 2015-01-01 15:29:46

The topleft block pointer you need to change for instaCTs is this:


item 33 quantity = first part of top left block pointer
item 34 = second part of top left block pointer



Oh. OK. Thank you. That was simpler than I thought. I did that for the first example listed on the Cooltrainer page in the instaCT section (I got the screen data for Dratini CT originally so I may have been on the right tracks the whole time, I just didn't know the event displacement data was that data) I was under the impression you had to change something else and load a specific (north/east/south/west) connection.

Re: Documenting Item Underflow Item slots.

Posted by: Torchickens
Date: 2018-08-08 10:33:40
*bump*

Lucky, I think there was an error somewhere in making the list as I looked into the "level-script pointer" map script address and it's item 41 and item 41's quantity. Confirmed this both with counting and checking the value of CC35 after pressing Select on the relevant item (which would change after using a code to modify D36E) on my Xploder cheating device.

Is it OK if you could you update the list please?

Re: Documenting Item Underflow Item slots.

Posted by: Guy
Date: 2018-08-08 15:30:30
A list of specific correspondences between item slots and memory addresses would be a good addition to this page, as the formula combined with the disassembly could be annoying to work with after a while. If the list here is inaccurate, though, I'll wait before adding it.