From e37cc7de9583b00166e96a6632ba25edefff43ca Mon Sep 17 00:00:00 2001 From: slipstream/RoL Date: Sun, 26 Feb 2017 14:27:20 +0000 Subject: Major changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added saveblock structures. - Changed example payload, now it warps to Hall of Fame. - Added helper library for PokĂ©mon manipulation, checksum calculation, etc. - Removed libSave, it's not needed. --- gba/source/payload.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'gba/source/payload.c') diff --git a/gba/source/payload.c b/gba/source/payload.c index 7015774..665af70 100644 --- a/gba/source/payload.c +++ b/gba/source/payload.c @@ -12,7 +12,61 @@ // Your payload code should obviously go into the body of this, the payload function. void payload(pSaveBlock1 SaveBlock1,pSaveBlock2 SaveBlock2,pSaveBlock3 SaveBlock3) { - // This example payload will modify the first character of the player's name. - // It will change to 'z'. You can see the character encoding table here: http://bulbapedia.bulbagarden.net/wiki/Character_encoding_in_Generation_III - SaveBlock2[0] = 0xee; // 'z' + // HoF-warp example payload! + + // Structure offsets are different between R/S, FR/LG, and Emerald. + // The beginning of the structures are the same but do NOT take shortcuts here, it's not good practise. + // If you want to support multiple games, make specific checks for games, use the right structure for each game. + SaveBlock1_RS* sb1rs = &SaveBlock1->rs; + SaveBlock1_FRLG* sb1frlg = &SaveBlock1->frlg; + SaveBlock1_E* sb1e = &SaveBlock1->e; + if (GAME_FRLG) { + sb1frlg->location.mapGroup = 1; // generic indoors? + sb1frlg->location.mapNum = 80; // Hall of Fame + // set coords to the same place that the champions' room script sets them to + sb1frlg->location.x = sb1frlg->pos.x = 5; + sb1frlg->location.y = sb1frlg->pos.y = 12; + sb1frlg->mapDataId = 0xDA; // from HoF map-header + sb1frlg->location.warpId = 0xff; + // make sure the HoF script doesn't crash, which it will do if 0 pokémon + if (sb1frlg->playerPartyCount == 0) { + sb1frlg->playerPartyCount = 1; + // this isn't enough, the heal animation recalculates the party count ignoring empty spots + // so let's hack together one. i don't care about it becoming a bad egg at all. + sb1frlg->playerParty[0].box.personality++; + } + return; + } else if (GAME_RS) { + sb1rs->location.mapGroup = 16; // Ever Grande City + sb1rs->location.mapNum = 11; // Hall of Fame + // set coords to the same place that the champions' room script sets them to + sb1rs->location.x = sb1rs->pos.x = 7; + sb1rs->location.y = sb1rs->pos.y = 16; + sb1rs->mapDataId = 299; // from HoF map-header + sb1rs->location.warpId = 0xff; + // make sure the HoF script doesn't crash, which it will do if 0 pokémon + if (sb1rs->playerPartyCount == 0) { + sb1rs->playerPartyCount = 1; + // this isn't enough, the heal animation recalculates the party count ignoring empty spots + // so let's hack together one. i don't care about it becoming a bad egg at all. + sb1rs->playerParty[0].box.personality++; + } + return; + } else if (GAME_EM) { + sb1e->location.mapGroup = 16; // Ever Grande City + sb1e->location.mapNum = 11; // Hall of Fame + // set coords to the same place that the champions' room script sets them to + sb1e->location.x = sb1e->pos.x = 7; + sb1e->location.y = sb1e->pos.y = 16; + sb1e->mapDataId = 298; // from HoF map-header + sb1e->location.warpId = 0xff; + // make sure the HoF script doesn't crash, which it will do if 0 pokémon + if (sb1e->playerPartyCount == 0) { + sb1e->playerPartyCount = 1; + // this isn't enough, the heal animation recalculates the party count ignoring empty spots + // so let's hack together one. i don't care about it becoming a bad egg at all. + sb1e->playerParty[0].box.personality++; + } + return; + } } \ No newline at end of file -- cgit 1.4.1