// 足下のアイテム public static Item FromGround(Snes snes) { int shirenX = snes.U8(0x7E85C8); int shirenY = snes.U8(0x7E85DC); int itemAddr = 0x7E9EDF + (shirenY * 0x40) + shirenX; int itemIndex = snes.U8(itemAddr); if (itemIndex < 0x80) return Item.FromTable(snes, itemIndex); else return Item.Invalid(); }
public static Item FromTable(Snes snes, int index) { Debug.Assert(index < 0x80); int code = snes.U8(0x7E8B8C + index); var item = new Item() { Valid = code != 0xFF, Code = code, TableData = code != 0xFF ? Item.Names[code] : null, Type = code != 0xFF ? Item.Names[code].Type : ItemType.Invalid, Name = code != 0xFF ? Item.Names[code].Name : "", InStore = snes.U8(0x7E8E8C + index) != 0, }; if (item.Valid) { switch (item.Type) { case ItemType.Invalid: break; case ItemType.Sword: item.Attack = snes.S8(0x7E8C8C + index); break; case ItemType.Arrow: item.ArrowCount = snes.U8(0x7E8C8C + index); break; case ItemType.Shield: item.Defense = snes.S8(0x7E8C8C + index); break; case ItemType.Grass: break; case ItemType.Scroll: break; case ItemType.Wand: item.WandLife = snes.U8(0x7E8C8C + index); break; case ItemType.Bracelet: break; case ItemType.RiceBall: break; case ItemType.Pot: { item.PotSizeLeft = snes.U8(0x7E8C8C + index); // 壺の中のアイテムリスト var nextIndex = index; while (true) { nextIndex = snes.U8(0x7E8E0C + nextIndex); if (nextIndex == 0xFF) break; item.Contents.Add(Item.FromTable(snes, nextIndex)); } } break; case ItemType.Flower: break; case ItemType.Meat: break; case ItemType.Event: break; case ItemType.Gitan: item.GitanAmount = snes.U8(0x7E8D0C + index) << 8 | snes.U8(0x7E8C8C + index); break; case ItemType.Others: break; default: break; } } return item; }
public static Item FromShiren(Snes snes, int index) { Debug.Assert(index < 20); var tableIndex = snes.U8(0x7E894F + index); if (tableIndex == 0xFF) return Item.Invalid(); return Item.FromTable(snes, tableIndex); }