From e44640b0088dad5856d7a6f60ad930779931b251 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Fri, 15 Dec 2017 21:22:26 -0500 Subject: [PATCH] Move more main.asm code into individual files --- constants/battle_tower_constants.asm | 4 +- constants/misc_constants.asm | 5 + engine/empty_sram.asm | 19 + engine/init_hof_credits.asm | 79 ++ engine/init_list.asm | 54 + engine/link.asm | 11 + engine/{mysterygift.asm => mystery_gift.asm} | 0 .../{mysterygift2.asm => mystery_gift_2.asm} | 0 engine/pack_f.asm | 20 + engine/place_graphics.asm | 56 + engine/pokegear_2.asm | 25 + engine/printhoursmins.asm | 64 ++ engine/save.asm | 40 +- engine/{selectmenu.asm => select_menu.asm} | 0 engine/{startmenu.asm => start_menu.asm} | 0 engine/switch_party_mons.asm | 145 +++ engine/tempmon.asm | 127 +++ event/buena_menu.asm | 58 ++ event/bug_contest/caught_mon.asm | 38 + .../contest.asm} | 0 .../contest_2.asm} | 0 .../display_stats.asm} | 0 .../judging.asm} | 0 .../heal_machine_anim.asm | 0 event/poisonstep_pals.asm | 48 + event/print_photo.asm | 61 ++ event/{photo.asm => print_unown.asm} | 62 -- event/print_unown_2.asm | 111 ++ macros/wram.asm | 1 - main.asm | 965 +----------------- maps/BattleTower1F.asm | 4 +- mobile/battle_tower_5c.asm | 20 +- mobile/get_trainer_class.asm | 46 + sram.asm | 243 ++--- wram.asm | 6 +- 35 files changed, 1159 insertions(+), 1153 deletions(-) create mode 100644 engine/empty_sram.asm create mode 100644 engine/init_hof_credits.asm create mode 100644 engine/init_list.asm rename engine/{mysterygift.asm => mystery_gift.asm} (100%) rename engine/{mysterygift2.asm => mystery_gift_2.asm} (100%) create mode 100644 engine/pack_f.asm create mode 100644 engine/place_graphics.asm create mode 100644 engine/pokegear_2.asm create mode 100644 engine/printhoursmins.asm rename engine/{selectmenu.asm => select_menu.asm} (100%) rename engine/{startmenu.asm => start_menu.asm} (100%) create mode 100644 engine/switch_party_mons.asm create mode 100644 engine/tempmon.asm create mode 100644 event/buena_menu.asm create mode 100644 event/bug_contest/caught_mon.asm rename event/{bug_contest.asm => bug_contest/contest.asm} (100%) rename event/{bug_contest_2.asm => bug_contest/contest_2.asm} (100%) rename event/{bug_contest_mon_stats.asm => bug_contest/display_stats.asm} (100%) rename event/{bug_contest_judging.asm => bug_contest/judging.asm} (100%) rename engine/healmachineanim.asm => event/heal_machine_anim.asm (100%) create mode 100644 event/poisonstep_pals.asm create mode 100755 event/print_photo.asm rename event/{photo.asm => print_unown.asm} (76%) mode change 100755 => 100644 create mode 100644 event/print_unown_2.asm create mode 100644 mobile/get_trainer_class.asm diff --git a/constants/battle_tower_constants.asm b/constants/battle_tower_constants.asm index 0436e4e22..74df3a36a 100755 --- a/constants/battle_tower_constants.asm +++ b/constants/battle_tower_constants.asm @@ -20,8 +20,8 @@ const BATTLETOWERACTION_11 ; store 0 in 5:aa8d const BATTLETOWERACTION_12 ; store 1 in 5:aa8d const BATTLETOWERACTION_13 ; check 5:aa8d - const BATTLETOWERACTION_14 ; if save file is yours: bit 0, [s1_be4f] - const BATTLETOWERACTION_15 ; set 0, [s1_be4f] + const BATTLETOWERACTION_14 ; if save file is yours: bit 0, [sBattleTowerSaveFileFlags] + const BATTLETOWERACTION_15 ; set 0, [sBattleTowerSaveFileFlags] const BATTLETOWERACTION_16 ; update time in SRAM bank 5 const BATTLETOWERACTION_17 ; check time in SRAM bank 5 const BATTLETOWERACTION_LEVEL_CHECK diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 7510fdf50..cbdbf3f98 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -65,6 +65,11 @@ HMENURETURN_SCRIPT EQU %10000000 HMENURETURN_ASM EQU %11111111 +; save file corruption check values +SAVE_CHECK_VALUE_1 EQU 99 +SAVE_CHECK_VALUE_2 EQU 127 + + ; time of day boundaries MORN_HOUR EQU 4 ; 4 AM DAY_HOUR EQU 10 ; 10 AM diff --git a/engine/empty_sram.asm b/engine/empty_sram.asm new file mode 100644 index 000000000..aa4b28e0d --- /dev/null +++ b/engine/empty_sram.asm @@ -0,0 +1,19 @@ +EmptyAllSRAMBanks: ; 4cf1f + ld a, $0 + call .EmptyBank + ld a, $1 + call .EmptyBank + ld a, $2 + call .EmptyBank + ld a, $3 + call .EmptyBank + ret + +.EmptyBank: ; 4cf34 + call GetSRAMBank + ld hl, SRAM_Begin + ld bc, SRAM_End - SRAM_Begin + xor a + call ByteFill + call CloseSRAM + ret diff --git a/engine/init_hof_credits.asm b/engine/init_hof_credits.asm new file mode 100644 index 000000000..0f55a10ab --- /dev/null +++ b/engine/init_hof_credits.asm @@ -0,0 +1,79 @@ +InitDisplayForHallOfFame: ; 4e881 + call ClearBGPalettes + call ClearTileMap + call ClearSprites + call DisableLCD + call LoadStandardFont + call LoadFontsBattleExtra + hlbgcoord 0, 0 + ld bc, VBGMap1 - VBGMap0 + ld a, " " + call ByteFill + hlcoord 0, 0, AttrMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + xor a + call ByteFill + xor a + ld [hSCY], a + ld [hSCX], a + call EnableLCD + ld hl, .SavingRecordDontTurnOff + call PrintText + call WaitBGMap2 + call SetPalettes + ret + +.SavingRecordDontTurnOff: ; 0x4e8bd + ; SAVING RECORD… DON'T TURN OFF! + text_jump UnknownText_0x1bd39e + db "@" + +InitDisplayForRedCredits: ; 4e8c2 + call ClearBGPalettes + call ClearTileMap + call ClearSprites + call DisableLCD + call LoadStandardFont + call LoadFontsBattleExtra + hlbgcoord 0, 0 + ld bc, VBGMap1 - VBGMap0 + ld a, " " + call ByteFill + hlcoord 0, 0, AttrMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + xor a + call ByteFill + ld hl, UnknBGPals + ld c, 4 tiles +.load_white_palettes + ld a, (palred 31 + palgreen 31 + palblue 31) % $100 + ld [hli], a + ld a, (palred 31 + palgreen 31 + palblue 31) / $100 + ld [hli], a + dec c + jr nz, .load_white_palettes + xor a + ld [hSCY], a + ld [hSCX], a + call EnableLCD + call WaitBGMap2 + call SetPalettes + ret + +ResetDisplayBetweenHallOfFameMons: ; 4e906 + ld a, [rSVBK] + push af + ld a, $6 + ld [rSVBK], a + ld hl, wDecompressScratch + ld bc, wScratchAttrMap - wDecompressScratch + ld a, " " + call ByteFill + hlbgcoord 0, 0 + ld de, wDecompressScratch + ld b, 0 + ld c, 4 tiles + call Request2bpp + pop af + ld [rSVBK], a + ret diff --git a/engine/init_list.asm b/engine/init_list.asm new file mode 100644 index 000000000..e2b7235ab --- /dev/null +++ b/engine/init_list.asm @@ -0,0 +1,54 @@ +InitList: ; 50db9 + ld a, [wInitListType] + + cp INIT_ENEMYOT_LIST + jr nz, .check_party_ot_name + ld hl, OTPartyCount + ld de, OTPartyMonOT + ld a, ENEMY_OT_NAME + jr .done + +.check_party_ot_name + cp INIT_PLAYEROT_LIST + jr nz, .check_mon_name + ld hl, PartyCount + ld de, PartyMonOT + ld a, PARTY_OT_NAME + jr .done + +.check_mon_name + cp INIT_MON_LIST + jr nz, .check_item_name + ld hl, CurMart + ld de, PokemonNames + ld a, PKMN_NAME + jr .done + +.check_item_name + cp INIT_BAG_ITEM_LIST + jr nz, .check_ob_item_name + ld hl, NumItems + ld de, ItemNames + ld a, ITEM_NAME + jr .done + +.check_ob_item_name + ld hl, CurMart + ld de, ItemNames + ld a, ITEM_NAME +.done + ld [wNamedObjectTypeBuffer], a + ld a, l + ld [wListPointer], a + ld a, h + ld [wListPointer + 1], a + ld a, e + ld [wUnusedD102], a + ld a, d + ld [wUnusedD102 + 1], a + ld bc, ItemAttributes + ld a, c + ld [wItemAttributesPtr], a + ld a, b + ld [wItemAttributesPtr + 1], a + ret diff --git a/engine/link.asm b/engine/link.asm index 7f71f4880..619d5bae3 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -2581,3 +2581,14 @@ UnusedGen1LinkCommsBorderGFX: ; 29f54 ; unreferenced INCBIN "gfx/trade/unused_gen_1_border_tiles.2bpp" ; 29fe4 + +Function29fe4: ; unreferenced + ld a, BANK(sPartyMail) + call GetSRAMBank + ld d, $0 + ld b, CHECK_FLAG + predef FlagPredef + call CloseSRAM + ld a, c + and a + ret diff --git a/engine/mysterygift.asm b/engine/mystery_gift.asm similarity index 100% rename from engine/mysterygift.asm rename to engine/mystery_gift.asm diff --git a/engine/mysterygift2.asm b/engine/mystery_gift_2.asm similarity index 100% rename from engine/mysterygift2.asm rename to engine/mystery_gift_2.asm diff --git a/engine/pack_f.asm b/engine/pack_f.asm new file mode 100644 index 000000000..f71e43db8 --- /dev/null +++ b/engine/pack_f.asm @@ -0,0 +1,20 @@ +DrawKrisPackGFX: ; 48e81 + ld hl, PackFGFXPointers + add hl, de + add hl, de + ld a, [hli] + ld e, a + ld d, [hl] + ld hl, VTiles2 tile $50 + lb bc, BANK(PackFGFX), 15 + call Request2bpp + ret + +PackFGFXPointers: ; 48e93 + dw PackFGFX + (15 tiles) * 1 + dw PackFGFX + (15 tiles) * 3 + dw PackFGFX + (15 tiles) * 0 + dw PackFGFX + (15 tiles) * 2 + +PackFGFX: ; 48e9b +INCBIN "gfx/pack/pack_f.2bpp" diff --git a/engine/place_graphics.asm b/engine/place_graphics.asm new file mode 100644 index 000000000..d72364776 --- /dev/null +++ b/engine/place_graphics.asm @@ -0,0 +1,56 @@ +PlaceGraphic: ; 2ef6e +; Fill wBoxAlignment-aligned box width b height c +; with iterating tile starting from hGraphicStartTile at hl. +; Predef $13 + + ld de, SCREEN_WIDTH + + ld a, [wBoxAlignment] + and a + jr nz, .right + + ld a, [hGraphicStartTile] +.x1 + push bc + push hl + +.y1 + ld [hl], a + add hl, de + inc a + dec c + jr nz, .y1 + + pop hl + inc hl + pop bc + dec b + jr nz, .x1 + ret + +.right +; Right-aligned. + push bc + ld b, 0 + dec c + add hl, bc + pop bc + + ld a, [hGraphicStartTile] +.x2 + push bc + push hl + +.y2 + ld [hl], a + add hl, de + inc a + dec c + jr nz, .y2 + + pop hl + dec hl + pop bc + dec b + jr nz, .x2 + ret diff --git a/engine/pokegear_2.asm b/engine/pokegear_2.asm new file mode 100644 index 000000000..a5cceecfd --- /dev/null +++ b/engine/pokegear_2.asm @@ -0,0 +1,25 @@ +TownMap_ConvertLineBreakCharacters: ; 1de2c5 + ld hl, StringBuffer1 +.loop + ld a, [hl] + cp "@" + jr z, .end + cp "%" + jr z, .line_break + cp "¯" + jr z, .line_break + inc hl + jr .loop + +.line_break + ld [hl], "" + +.end + ld de, StringBuffer1 + hlcoord 9, 0 + call PlaceString + ret + + +PokegearGFX: ; 1de2e4 +INCBIN "gfx/pokegear/pokegear.2bpp.lz" diff --git a/engine/printhoursmins.asm b/engine/printhoursmins.asm new file mode 100644 index 000000000..711ff89b6 --- /dev/null +++ b/engine/printhoursmins.asm @@ -0,0 +1,64 @@ +Function1dd6a9: ; 1dd6a9 +; XXX + ld a, b + ld b, c + ld c, a + push bc + push de + ld hl, sp+$2 + ld d, h + ld e, l + pop hl + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 + call PrintNum + pop bc + ret + +PrintHoursMins ; 1dd6bb (77:56bb) +; Hours in b, minutes in c + ld a, b + cp 12 + push af + jr c, .AM + jr z, .PM + sub 12 + jr .PM +.AM: + or a + jr nz, .PM + ld a, 12 +.PM: + ld b, a +; Crazy stuff happening with the stack + push bc + ld hl, sp+$1 + push de + push hl + pop de + pop hl + ld [hl], " " + lb bc, 1, 2 + call PrintNum + ld [hl], ":" + inc hl + ld d, h + ld e, l + ld hl, sp+$0 + push de + push hl + pop de + pop hl + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + pop bc + ld de, String_AM + pop af + jr c, .place_am_pm + ld de, String_PM +.place_am_pm + inc hl + call PlaceString + ret + +String_AM: db "AM@" ; 1dd6fc +String_PM: db "PM@" ; 1dd6ff diff --git a/engine/save.asm b/engine/save.asm index 74b0626c8..65339e0bb 100644 --- a/engine/save.asm +++ b/engine/save.asm @@ -500,12 +500,12 @@ HallOfFame_InitSaveIfNeeded: ; 14da0 ; 14da9 ValidateSave: ; 14da9 - ld a, BANK(s1_a008) + ld a, BANK(sCheckValue1) ; BANK(sCheckValue2) call GetSRAMBank - ld a, 99 - ld [s1_a008], a - ld a, " " - ld [s1_ad0f], a + ld a, SAVE_CHECK_VALUE_1 + ld [sCheckValue1], a + ld a, SAVE_CHECK_VALUE_2 + ld [sCheckValue2], a jp CloseSRAM ; 14dbb @@ -568,12 +568,12 @@ SaveChecksum: ; 14e13 ; 14e2d ValidateBackupSave: ; 14e2d - ld a, BANK(s0_b208) + ld a, BANK(sBackupCheckValue1) ; BANK(sBackupCheckValue2) call GetSRAMBank - ld a, 99 - ld [s0_b208], a - ld a, " " - ld [s0_bf0f], a + ld a, SAVE_CHECK_VALUE_1 + ld [sBackupCheckValue1], a + ld a, SAVE_CHECK_VALUE_2 + ld [sBackupCheckValue2], a call CloseSRAM ret ; 14e40 @@ -731,13 +731,13 @@ INCLUDE "data/default_options.asm" CheckPrimarySaveFile: ; 14f84 - ld a, BANK(s1_a008) + ld a, BANK(sCheckValue1) ; BANK(sCheckValue2) call GetSRAMBank - ld a, [s1_a008] - cp 99 + ld a, [sCheckValue1] + cp SAVE_CHECK_VALUE_1 jr nz, .nope - ld a, [s1_ad0f] - cp " " + ld a, [sCheckValue2] + cp SAVE_CHECK_VALUE_2 jr nz, .nope ld hl, sOptions ld de, Options @@ -753,13 +753,13 @@ CheckPrimarySaveFile: ; 14f84 ; 14faf CheckBackupSaveFile: ; 14faf - ld a, BANK(s0_b208) + ld a, BANK(sBackupCheckValue1) ; BANK(sBackupCheckValue2) call GetSRAMBank - ld a, [s0_b208] - cp 99 + ld a, [sBackupCheckValue1] + cp SAVE_CHECK_VALUE_1 jr nz, .nope - ld a, [s0_bf0f] - cp " " + ld a, [sBackupCheckValue2] + cp SAVE_CHECK_VALUE_2 jr nz, .nope ld hl, sBackupOptions ld de, Options diff --git a/engine/selectmenu.asm b/engine/select_menu.asm similarity index 100% rename from engine/selectmenu.asm rename to engine/select_menu.asm diff --git a/engine/startmenu.asm b/engine/start_menu.asm similarity index 100% rename from engine/startmenu.asm rename to engine/start_menu.asm diff --git a/engine/switch_party_mons.asm b/engine/switch_party_mons.asm new file mode 100644 index 000000000..cde9c82b2 --- /dev/null +++ b/engine/switch_party_mons.asm @@ -0,0 +1,145 @@ +_SwitchPartyMons: + ld a, [wd0e3] + dec a + ld [Buffer3], a + ld b, a + ld a, [wMenuCursorY] + dec a + ld [Buffer2], a + cp b + jr z, .skip + call .SwapMonAndMail + ld a, [Buffer3] + call .ClearSprite + ld a, [Buffer2] + call .ClearSprite +.skip + ret + +.ClearSprite: ; 50f34 (14:4f34) + push af + hlcoord 0, 1 + ld bc, 2 * SCREEN_WIDTH + call AddNTimes + ld bc, 2 * SCREEN_WIDTH + ld a, " " + call ByteFill + pop af + ld hl, Sprites + ld bc, $10 + call AddNTimes + ld de, $4 + ld c, $4 +.gfx_loop + ld [hl], $a0 + add hl, de + dec c + jr nz, .gfx_loop + ld de, SFX_SWITCH_POKEMON + call WaitPlaySFX + ret + +.SwapMonAndMail: ; 50f62 (14:4f62) + push hl + push de + push bc + ld bc, PartySpecies + ld a, [Buffer2] + ld l, a + ld h, $0 + add hl, bc + ld d, h + ld e, l + ld a, [Buffer3] + ld l, a + ld h, $0 + add hl, bc + ld a, [hl] + push af + ld a, [de] + ld [hl], a + pop af + ld [de], a + ld a, [Buffer2] + ld hl, PartyMon1Species + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + push hl + ld de, wd002 + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + ld a, [Buffer3] + ld hl, PartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + pop de + push hl + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + pop de + ld hl, wd002 + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + ld a, [Buffer2] + ld hl, PartyMonOT + call SkipNames + push hl + call .CopyNameTowd002 + ld a, [Buffer3] + ld hl, PartyMonOT + call SkipNames + pop de + push hl + call .CopyName + pop de + ld hl, wd002 + call .CopyName + ld hl, PartyMonNicknames + ld a, [Buffer2] + call SkipNames + push hl + call .CopyNameTowd002 + ld hl, PartyMonNicknames + ld a, [Buffer3] + call SkipNames + pop de + push hl + call .CopyName + pop de + ld hl, wd002 + call .CopyName + ld hl, sPartyMail + ld a, [Buffer2] + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + push hl + ld de, wd002 + ld bc, MAIL_STRUCT_LENGTH + ld a, BANK(sPartyMail) + call GetSRAMBank + call CopyBytes + ld hl, sPartyMail + ld a, [Buffer3] + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + pop de + push hl + ld bc, MAIL_STRUCT_LENGTH + call CopyBytes + pop de + ld hl, wd002 + ld bc, MAIL_STRUCT_LENGTH + call CopyBytes + call CloseSRAM + pop bc + pop de + pop hl + ret + +.CopyNameTowd002: ; 51036 (14:5036) + ld de, wd002 + +.CopyName: ; 51039 (14:5039) + ld bc, NAME_LENGTH + call CopyBytes + ret diff --git a/engine/tempmon.asm b/engine/tempmon.asm new file mode 100644 index 000000000..332cb0c6c --- /dev/null +++ b/engine/tempmon.asm @@ -0,0 +1,127 @@ +CopyPkmnToTempMon: ; 5084a +; gets the BaseData of a Pkmn +; and copys the PkmnStructure to TempMon + + ld a, [CurPartyMon] + ld e, a + call GetPkmnSpecies + ld a, [CurPartySpecies] + ld [CurSpecies], a + call GetBaseData + + ld a, [MonType] + ld hl, PartyMon1Species + ld bc, PARTYMON_STRUCT_LENGTH + and a + jr z, .copywholestruct + ld hl, OTPartyMon1Species + ld bc, PARTYMON_STRUCT_LENGTH + cp OTPARTYMON + jr z, .copywholestruct + ld bc, BOXMON_STRUCT_LENGTH + callab CopyBoxmonToTempMon + jr .done + +.copywholestruct + ld a, [CurPartyMon] + call AddNTimes + ld de, TempMon + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + +.done + ret + +CalcwBufferMonStats: ; 5088b + ld bc, wBufferMon + jr _TempMonStatsCalculation + +CalcTempmonStats: ; 50890 + ld bc, TempMon +_TempMonStatsCalculation: ; 50893 + ld hl, MON_LEVEL + add hl, bc + ld a, [hl] + ld [CurPartyLevel], a + ld hl, MON_MAXHP + add hl, bc + ld d, h + ld e, l + ld hl, MON_STAT_EXP - 1 + add hl, bc + push bc + ld b, $1 + predef CalcPkmnStats + pop bc + ld hl, MON_HP + add hl, bc + ld d, h + ld e, l + ld a, [CurPartySpecies] + cp EGG + jr nz, .not_egg + xor a + ld [de], a + inc de + ld [de], a + jr .zero_status + +.not_egg + push bc + ld hl, MON_MAXHP + add hl, bc + ld bc, 2 + call CopyBytes + pop bc + +.zero_status + ld hl, MON_STATUS + add hl, bc + xor a + ld [hli], a + ld [hl], a + ret + +GetPkmnSpecies: ; 508d5 +; [MonType] has the type of the Pkmn +; e = Nr. of Pkmn (i.e. [CurPartyMon]) + + ld a, [MonType] + and a ; PARTYMON + jr z, .partymon + cp OTPARTYMON + jr z, .otpartymon + cp BOXMON + jr z, .boxmon + cp TEMPMON + jr z, .breedmon + ; WILDMON + +.partymon + ld hl, PartySpecies + jr .done + +.otpartymon + ld hl, OTPartySpecies + jr .done + +.boxmon + ld a, BANK(sBoxSpecies) + call GetSRAMBank + ld hl, sBoxSpecies + call .done + call CloseSRAM + ret + +.breedmon + ld a, [wBreedMon1Species] + jr .done2 + +.done + ld d, 0 + add hl, de + ld a, [hl] + +.done2 + ld [CurPartySpecies], a + ret diff --git a/event/buena_menu.asm b/event/buena_menu.asm new file mode 100644 index 000000000..b453da783 --- /dev/null +++ b/event/buena_menu.asm @@ -0,0 +1,58 @@ +AskRememberPassword: ; 4ae12 + call .DoMenu + ld a, $0 + jr c, .okay + ld a, $1 + +.okay + ld [ScriptVar], a + ret + +.DoMenu: ; 4ae1f + lb bc, 14, 7 + push bc + ld hl, YesNoMenuDataHeader + call CopyMenuDataHeader + pop bc + ld a, b + ld [wMenuBorderLeftCoord], a + add $5 + ld [wMenuBorderRightCoord], a + ld a, c + ld [wMenuBorderTopCoord], a + add $4 + ld [wMenuBorderBottomCoord], a + call PushWindow + call VerticalMenu + push af + ld c, 15 + call DelayFrames + call Buena_ExitMenu + pop af + jr c, .refused + ld a, [wMenuCursorY] + cp $2 + jr z, .refused + and a + ret + +.refused + ld a, $2 + ld [wMenuCursorY], a + scf + ret + +Buena_ExitMenu: ; 4ae5e + ld a, [hOAMUpdate] + push af + call ExitMenu + call UpdateSprites + xor a + ld [hOAMUpdate], a + call DelayFrame + ld a, $1 + ld [hOAMUpdate], a + call ApplyTilemap + pop af + ld [hOAMUpdate], a + ret diff --git a/event/bug_contest/caught_mon.asm b/event/bug_contest/caught_mon.asm new file mode 100644 index 000000000..729033d8b --- /dev/null +++ b/event/bug_contest/caught_mon.asm @@ -0,0 +1,38 @@ +BugContest_SetCaughtContestMon: ; e6ce + ld a, [wContestMon] + and a + jr z, .firstcatch + ld [wd265], a + callba DisplayAlreadyCaughtText + callba DisplayCaughtContestMonStats + lb bc, 14, 7 + call PlaceYesNoBox + ret c + +.firstcatch + call .generatestats + ld a, [TempEnemyMonSpecies] + ld [wd265], a + call GetPokemonName + ld hl, .caughttext + call PrintText + ret + +.generatestats ; e6fd + ld a, [TempEnemyMonSpecies] + ld [CurSpecies], a + ld [CurPartySpecies], a + call GetBaseData + xor a + ld bc, PARTYMON_STRUCT_LENGTH + ld hl, wContestMon + call ByteFill + xor a + ld [MonType], a + ld hl, wContestMon + jp GeneratePartyMonStats + +.caughttext ; 0xe71d + ; Caught @ ! + text_jump UnknownText_0x1c10c0 + db "@" diff --git a/event/bug_contest.asm b/event/bug_contest/contest.asm similarity index 100% rename from event/bug_contest.asm rename to event/bug_contest/contest.asm diff --git a/event/bug_contest_2.asm b/event/bug_contest/contest_2.asm similarity index 100% rename from event/bug_contest_2.asm rename to event/bug_contest/contest_2.asm diff --git a/event/bug_contest_mon_stats.asm b/event/bug_contest/display_stats.asm similarity index 100% rename from event/bug_contest_mon_stats.asm rename to event/bug_contest/display_stats.asm diff --git a/event/bug_contest_judging.asm b/event/bug_contest/judging.asm similarity index 100% rename from event/bug_contest_judging.asm rename to event/bug_contest/judging.asm diff --git a/engine/healmachineanim.asm b/event/heal_machine_anim.asm similarity index 100% rename from engine/healmachineanim.asm rename to event/heal_machine_anim.asm diff --git a/event/poisonstep_pals.asm b/event/poisonstep_pals.asm new file mode 100644 index 000000000..c556ba498 --- /dev/null +++ b/event/poisonstep_pals.asm @@ -0,0 +1,48 @@ +LoadPoisonBGPals: ; cbcdd + call .LoadPals + ld a, [hCGB] + and a + ret nz + ret ; ???? + +.LoadPals: ; cbce5 + ld a, [hCGB] + and a + jr nz, .cgb + ld a, [TimeOfDayPal] + and $3 + cp $3 + ld a, %00000000 + jr z, .convert_pals + ld a, %10101010 + +.convert_pals + call DmgToCgbBGPals + ld c, 4 + call DelayFrames + callba _UpdateTimePals + ret + +.cgb + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld hl, BGPals + ld c, $20 +.loop +; RGB 28, 21, 31 + ld a, (palred 28 + palgreen 21 + palblue 31) % $100 + ld [hli], a + ld a, (palred 28 + palgreen 21 + palblue 31) / $100 + ld [hli], a + dec c + jr nz, .loop + pop af + ld [rSVBK], a + ld a, $1 + ld [hCGBPalUpdate], a + ld c, 4 + call DelayFrames + callba _UpdateTimePals + ret diff --git a/event/print_photo.asm b/event/print_photo.asm new file mode 100755 index 000000000..448910355 --- /dev/null +++ b/event/print_photo.asm @@ -0,0 +1,61 @@ +PhotoStudio: ; 16dc7 + ld hl, .Text_AskWhichMon + call PrintText + callba SelectMonFromParty + jr c, .cancel + ld a, [CurPartySpecies] + cp EGG + jr z, .egg + + ld hl, .Text_HoldStill + call PrintText + call DisableSpriteUpdates + callba PrintPartymon + call ReturnToMapWithSpeechTextbox + ld a, [hPrinter] + and a + jr nz, .cancel + ld hl, .Text_Presto + jr .print_text + +.cancel + ld hl, .Text_NoPicture + jr .print_text + +.egg + ld hl, .Text_Egg + +.print_text + call PrintText + ret +; 16e04 + +.Text_AskWhichMon: ; 0x16e04 + ; Which #MON should I photo- graph? + text_jump UnknownText_0x1be024 + db "@" +; 0x16e09 + +.Text_HoldStill: ; 0x16e09 + ; All righty. Hold still for a bit. + text_jump UnknownText_0x1be047 + db "@" +; 0x16e0e + +.Text_Presto: ; 0x16e0e + ; Presto! All done. Come again, OK? + text_jump UnknownText_0x1be06a + db "@" +; 0x16e13 + +.Text_NoPicture: ; 0x16e13 + ; Oh, no picture? Come again, OK? + text_jump UnknownText_0x1c0000 + db "@" +; 0x16e18 + +.Text_Egg: ; 0x16e18 + ; An EGG? My talent is worth more… + text_jump UnknownText_0x1c0021 + db "@" +; 0x16e1d diff --git a/event/photo.asm b/event/print_unown.asm old mode 100755 new mode 100644 similarity index 76% rename from event/photo.asm rename to event/print_unown.asm index 55ac8e7d1..5e0162bad --- a/event/photo.asm +++ b/event/print_unown.asm @@ -231,65 +231,3 @@ PlaceUnownPrinterFrontpic: ; 16dac predef PlaceGraphic ret ; 16dc7 - -PhotoStudio: ; 16dc7 - ld hl, .Text_AskWhichMon - call PrintText - callba SelectMonFromParty - jr c, .cancel - ld a, [CurPartySpecies] - cp EGG - jr z, .egg - - ld hl, .Text_HoldStill - call PrintText - call DisableSpriteUpdates - callba PrintPartymon - call ReturnToMapWithSpeechTextbox - ld a, [hPrinter] - and a - jr nz, .cancel - ld hl, .Text_Presto - jr .print_text - -.cancel - ld hl, .Text_NoPicture - jr .print_text - -.egg - ld hl, .Text_Egg - -.print_text - call PrintText - ret -; 16e04 - -.Text_AskWhichMon: ; 0x16e04 - ; Which #MON should I photo- graph? - text_jump UnknownText_0x1be024 - db "@" -; 0x16e09 - -.Text_HoldStill: ; 0x16e09 - ; All righty. Hold still for a bit. - text_jump UnknownText_0x1be047 - db "@" -; 0x16e0e - -.Text_Presto: ; 0x16e0e - ; Presto! All done. Come again, OK? - text_jump UnknownText_0x1be06a - db "@" -; 0x16e13 - -.Text_NoPicture: ; 0x16e13 - ; Oh, no picture? Come again, OK? - text_jump UnknownText_0x1c0000 - db "@" -; 0x16e18 - -.Text_Egg: ; 0x16e18 - ; An EGG? My talent is worth more… - text_jump UnknownText_0x1c0021 - db "@" -; 0x16e1d diff --git a/event/print_unown_2.asm b/event/print_unown_2.asm new file mode 100644 index 000000000..057db5176 --- /dev/null +++ b/event/print_unown_2.asm @@ -0,0 +1,111 @@ +RotateUnownFrontpic: ; e0000 +; something to do with Unown printer + push de + xor a + call GetSRAMBank + ld hl, sScratch + ld bc, 0 +.loop + push bc + push hl + push bc + ld de, wd002 + call .Copy + call .Rotate + ld hl, UnownPrinter_OverworldMapRectangle + pop bc + add hl, bc + add hl, bc + ld a, [hli] + ld e, a + ld d, [hl] + ld hl, wd012 + call .Copy + pop hl + ld bc, $10 + add hl, bc + pop bc + inc c + ld a, c + cp 7 * 7 + jr c, .loop + + ld hl, OverworldMap + ld de, sScratch + ld bc, 7 * 7 tiles + call CopyBytes + pop hl + ld de, sScratch + ld c, 7 * 7 + ld a, [hROMBank] + ld b, a + call Get2bpp + call CloseSRAM + ret + +.Copy: ; e004e + ld c, $10 +.loop_copy + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .loop_copy + ret + +.Rotate: ; e0057 + ld hl, wd012 + ld e, %10000000 + ld d, 8 +.loop_decompress + push hl + ld hl, wd002 + call .CountSetBit + pop hl + ld a, b + ld [hli], a + push hl + ld hl, wd003 + call .CountSetBit + pop hl + ld a, b + ld [hli], a + srl e + dec d + jr nz, .loop_decompress + ret + +.CountSetBit: ; e0078 + ld b, 0 + ld c, 8 +.loop_count + ld a, [hli] + and e + jr z, .clear + scf + jr .apply + +.clear + and a + +.apply + rr b + inc hl + dec c + jr nz, .loop_count + ret + +overworldmaprect: MACRO +y = 0 +rept \1 +x = \1 * (\2 +- 1) + y +rept \2 + dw OverworldMap tile x +x = x +- \2 +endr +y = y + 1 +endr +endm + +UnownPrinter_OverworldMapRectangle: ; e008b + overworldmaprect 7, 7 diff --git a/macros/wram.asm b/macros/wram.asm index de258941c..7cead9158 100755 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -227,7 +227,6 @@ hof_mon: MACRO endm hall_of_fame: MACRO -\1:: \1WinCount:: db \1Mon1:: hof_mon \1Mon1 \1Mon2:: hof_mon \1Mon2 diff --git a/main.asm b/main.asm index 010895cf8..299b6ce5f 100644 --- a/main.asm +++ b/main.asm @@ -111,45 +111,7 @@ GetBreedMon2LevelGrowth: ; e6b3 ld d, a ret -BugContest_SetCaughtContestMon: ; e6ce - ld a, [wContestMon] - and a - jr z, .firstcatch - ld [wd265], a - callba DisplayAlreadyCaughtText - callba DisplayCaughtContestMonStats - lb bc, 14, 7 - call PlaceYesNoBox - ret c - -.firstcatch - call .generatestats - ld a, [TempEnemyMonSpecies] - ld [wd265], a - call GetPokemonName - ld hl, .caughttext - call PrintText - ret - -.generatestats ; e6fd - ld a, [TempEnemyMonSpecies] - ld [CurSpecies], a - ld [CurPartySpecies], a - call GetBaseData - xor a - ld bc, PARTYMON_STRUCT_LENGTH - ld hl, wContestMon - call ByteFill - xor a - ld [MonType], a - ld hl, wContestMon - jp GeneratePartyMonStats - -.caughttext ; 0xe71d - ; Caught @ ! - text_jump UnknownText_0x1c10c0 - db "@" - +INCLUDE "event/bug_contest/caught_mon.asm" INCLUDE "engine/item_effects.asm" KnowsMove: ; f9ea @@ -195,19 +157,19 @@ Script_AbortBugContest: ; 0x122c1 end INCLUDE "event/itemball.asm" -INCLUDE "engine/healmachineanim.asm" +INCLUDE "event/heal_machine_anim.asm" INCLUDE "event/whiteout.asm" INCLUDE "event/forced_movement.asm" INCLUDE "event/itemfinder.asm" -INCLUDE "engine/startmenu.asm" -INCLUDE "engine/selectmenu.asm" +INCLUDE "engine/start_menu.asm" +INCLUDE "engine/select_menu.asm" INCLUDE "event/elevator.asm" -INCLUDE "event/bug_contest.asm" +INCLUDE "event/bug_contest/contest.asm" INCLUDE "event/hidden_items.asm" INCLUDE "engine/collision_stdscripts.asm" -INCLUDE "event/bug_contest_judging.asm" +INCLUDE "event/bug_contest/judging.asm" INCLUDE "engine/pokerus_tick.asm" -INCLUDE "event/bug_contest_2.asm" +INCLUDE "event/bug_contest/contest_2.asm" INCLUDE "engine/unused_correct_party.asm" INCLUDE "engine/square_root.asm" @@ -226,7 +188,8 @@ INCLUDE "engine/money.asm" INCLUDE "data/items/marts.asm" INCLUDE "event/mom.asm" INCLUDE "event/daycare.asm" -INCLUDE "event/photo.asm" +INCLUDE "event/print_unown.asm" +INCLUDE "event/print_photo.asm" INCLUDE "engine/breeding.asm" INCLUDE "tilesets/data.asm" @@ -341,18 +304,6 @@ Kurt_SelectQuantity_InterpretJoypad: ; 27a28 SECTION "bankA", ROMX INCLUDE "engine/link.asm" - -Function29fe4: ; unreferenced - ld a, $0 - call GetSRAMBank - ld d, $0 - ld b, CHECK_FLAG - predef FlagPredef - call CloseSRAM - ld a, c - and a - ret - INCLUDE "engine/wildmons.asm" INCLUDE "battle/link_result.asm" @@ -369,68 +320,12 @@ INCLUDE "battle/trainer_huds.asm" INCLUDE "data/trainers/trainer_class_names.asm" INCLUDE "battle/ai/redundant.asm" INCLUDE "event/move_deleter.asm" -INCLUDE "engine/mysterygift2.asm" +INCLUDE "engine/mystery_gift_2.asm" INCLUDE "engine/tmhm2.asm" INCLUDE "battle/moves/move_descriptions.asm" INCLUDE "engine/pokerus.asm" INCLUDE "engine/start_battle.asm" - -PlaceGraphic: ; 2ef6e -; Fill wBoxAlignment-aligned box width b height c -; with iterating tile starting from hGraphicStartTile at hl. -; Predef $13 - - ld de, SCREEN_WIDTH - - ld a, [wBoxAlignment] - and a - jr nz, .right - - ld a, [hGraphicStartTile] -.x1 - push bc - push hl - -.y1 - ld [hl], a - add hl, de - inc a - dec c - jr nz, .y1 - - pop hl - inc hl - pop bc - dec b - jr nz, .x1 - ret - -.right -; Right-aligned. - push bc - ld b, 0 - dec c - add hl, bc - pop bc - - ld a, [hGraphicStartTile] -.x2 - push bc - push hl - -.y2 - ld [hl], a - add hl, de - inc a - dec c - jr nz, .y2 - - pop hl - dec hl - pop bc - dec b - jr nz, .x2 - ret +INCLUDE "engine/place_graphics.asm" SECTION "Effect Commands", ROMX @@ -474,95 +369,15 @@ INCLUDE "engine/mail.asm" SECTION "Crystal Unique", ROMX INCLUDE "engine/init_gender.asm" - -DrawKrisPackGFX: ; 48e81 - ld hl, PackFGFXPointers - add hl, de - add hl, de - ld a, [hli] - ld e, a - ld d, [hl] - ld hl, VTiles2 tile $50 - lb bc, BANK(PackFGFX), 15 - call Request2bpp - ret - -PackFGFXPointers: ; 48e93 - dw PackFGFX + (15 tiles) * 1 - dw PackFGFX + (15 tiles) * 3 - dw PackFGFX + (15 tiles) * 0 - dw PackFGFX + (15 tiles) * 2 - -PackFGFX: ; 48e9b -INCBIN "gfx/pack/pack_f.2bpp" - +INCLUDE "engine/pack_f.asm" INCLUDE "event/move_tutor.asm" INCLUDE "engine/crystal_colors.asm" INCLUDE "event/celebi.asm" INCLUDE "engine/main_menu.asm" INCLUDE "mobile/mobile_menu.asm" INCLUDE "engine/search.asm" - ; mobile battle selection INCLUDE "mobile/mobile_12_2.asm" - -AskRememberPassword: ; 4ae12 - call .DoMenu - ld a, $0 - jr c, .okay - ld a, $1 - -.okay - ld [ScriptVar], a - ret - -.DoMenu: ; 4ae1f - lb bc, 14, 7 - push bc - ld hl, YesNoMenuDataHeader - call CopyMenuDataHeader - pop bc - ld a, b - ld [wMenuBorderLeftCoord], a - add $5 - ld [wMenuBorderRightCoord], a - ld a, c - ld [wMenuBorderTopCoord], a - add $4 - ld [wMenuBorderBottomCoord], a - call PushWindow - call VerticalMenu - push af - ld c, 15 - call DelayFrames - call Buena_ExitMenu - pop af - jr c, .refused - ld a, [wMenuCursorY] - cp $2 - jr z, .refused - and a - ret - -.refused - ld a, $2 - ld [wMenuCursorY], a - scf - ret - -Buena_ExitMenu: ; 4ae5e - ld a, [hOAMUpdate] - push af - call ExitMenu - call UpdateSprites - xor a - ld [hOAMUpdate], a - call DelayFrame - ld a, $1 - ld [hOAMUpdate], a - call ApplyTilemap - pop af - ld [hOAMUpdate], a - ret +INCLUDE "event/buena_menu.asm" SECTION "bank13", ROMX @@ -577,26 +392,7 @@ endr ; 0x4ce1f INCLUDE "data/collision_permissions.asm" - -EmptyAllSRAMBanks: ; 4cf1f - ld a, $0 - call .EmptyBank - ld a, $1 - call .EmptyBank - ld a, $2 - call .EmptyBank - ld a, $3 - call .EmptyBank - ret - -.EmptyBank: ; 4cf34 - call GetSRAMBank - ld hl, SRAM_Begin - ld bc, SRAM_End - SRAM_Begin - xor a - call ByteFill - call CloseSRAM - ret +INCLUDE "engine/empty_sram.asm" SaveMenu_LoadEDTile: ; 4cf45 (13:4f45) ld a, [hCGB] @@ -677,18 +473,18 @@ endr ret CheckSave:: ; 4cffe - ld a, BANK(s1_a008) + ld a, BANK(sCheckValue1) ; BANK(sCheckValue2) call GetSRAMBank - ld a, [s1_a008] + ld a, [sCheckValue1] ld b, a - ld a, [s1_ad0f] + ld a, [sCheckValue2] ld c, a call CloseSRAM ld a, b - cp 99 + cp SAVE_CHECK_VALUE_1 jr nz, .ok ld a, c - cp " " + cp SAVE_CHECK_VALUE_2 jr nz, .ok ld c, $1 ret @@ -1060,133 +856,8 @@ INCLUDE "engine/search2.asm" INCLUDE "engine/stats_screen.asm" INCLUDE "event/catch_tutorial.asm" INCLUDE "engine/evolution_animation.asm" - -InitDisplayForHallOfFame: ; 4e881 - call ClearBGPalettes - call ClearTileMap - call ClearSprites - call DisableLCD - call LoadStandardFont - call LoadFontsBattleExtra - hlbgcoord 0, 0 - ld bc, VBGMap1 - VBGMap0 - ld a, " " - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - xor a - call ByteFill - xor a - ld [hSCY], a - ld [hSCX], a - call EnableLCD - ld hl, .SavingRecordDontTurnOff - call PrintText - call WaitBGMap2 - call SetPalettes - ret - -.SavingRecordDontTurnOff: ; 0x4e8bd - ; SAVING RECORD… DON'T TURN OFF! - text_jump UnknownText_0x1bd39e - db "@" - -InitDisplayForRedCredits: ; 4e8c2 - call ClearBGPalettes - call ClearTileMap - call ClearSprites - call DisableLCD - call LoadStandardFont - call LoadFontsBattleExtra - hlbgcoord 0, 0 - ld bc, VBGMap1 - VBGMap0 - ld a, " " - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - xor a - call ByteFill - ld hl, UnknBGPals - ld c, 4 tiles -.load_white_palettes - ld a, (palred 31 + palgreen 31 + palblue 31) % $100 - ld [hli], a - ld a, (palred 31 + palgreen 31 + palblue 31) / $100 - ld [hli], a - dec c - jr nz, .load_white_palettes - xor a - ld [hSCY], a - ld [hSCX], a - call EnableLCD - call WaitBGMap2 - call SetPalettes - ret - -ResetDisplayBetweenHallOfFameMons: ; 4e906 - ld a, [rSVBK] - push af - ld a, $6 - ld [rSVBK], a - ld hl, wDecompressScratch - ld bc, wScratchAttrMap - wDecompressScratch - ld a, " " - call ByteFill - hlbgcoord 0, 0 - ld de, wDecompressScratch - ld b, 0 - ld c, 4 tiles - call Request2bpp - pop af - ld [rSVBK], a - ret - -GetMobileOTTrainerClass: ; mobile function - ld h, b - ld l, c - call .GetMobileOTTrainerClass - ld c, a - ret - -.GetMobileOTTrainerClass: ; 4e930 - ld a, [hli] - xor [hl] - ld c, a - jr z, .skip_male_trainers - srl c - srl c -.male_trainer_loop - srl c - ld a, c - cp MaleTrainersEnd - MaleTrainers - 1 - jr nc, .male_trainer_loop - inc c - -.skip_male_trainers - ld a, [de] - cp $1 - ld hl, MaleTrainers - jr nz, .finished - - ld hl, FemaleTrainers - ld a, c - and a - jr z, .finished - -.female_trainer_loop - srl c - ld a, c - cp FemaleTrainersEnd - FemaleTrainers - 1 - jr nc, .female_trainer_loop - inc c - -.finished - ld b, $0 - add hl, bc - ld a, [hl] - ret - -INCLUDE "data/trainers/gendered_trainers.asm" +INCLUDE "engine/init_hof_credits.asm" +INCLUDE "mobile/get_trainer_class.asm" INCLUDE "battle/sliding_intro.asm" Mobile_PrintOpponentBattleMessage: ; 4ea0a @@ -1281,342 +952,13 @@ INCLUDE "event/squirtbottle.asm" INCLUDE "event/card_key.asm" INCLUDE "event/basement_key.asm" INCLUDE "event/sacred_ash.asm" - -CopyPkmnToTempMon: ; 5084a -; gets the BaseData of a Pkmn -; and copys the PkmnStructure to TempMon - - ld a, [CurPartyMon] - ld e, a - call GetPkmnSpecies - ld a, [CurPartySpecies] - ld [CurSpecies], a - call GetBaseData - - ld a, [MonType] - ld hl, PartyMon1Species - ld bc, PARTYMON_STRUCT_LENGTH - and a - jr z, .copywholestruct - ld hl, OTPartyMon1Species - ld bc, PARTYMON_STRUCT_LENGTH - cp OTPARTYMON - jr z, .copywholestruct - ld bc, BOXMON_STRUCT_LENGTH - callab CopyBoxmonToTempMon - jr .done - -.copywholestruct - ld a, [CurPartyMon] - call AddNTimes - ld de, TempMon - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - -.done - ret - -CalcwBufferMonStats: ; 5088b - ld bc, wBufferMon - jr _TempMonStatsCalculation - -CalcTempmonStats: ; 50890 - ld bc, TempMon -_TempMonStatsCalculation: ; 50893 - ld hl, MON_LEVEL - add hl, bc - ld a, [hl] - ld [CurPartyLevel], a - ld hl, MON_MAXHP - add hl, bc - ld d, h - ld e, l - ld hl, MON_STAT_EXP - 1 - add hl, bc - push bc - ld b, $1 - predef CalcPkmnStats - pop bc - ld hl, MON_HP - add hl, bc - ld d, h - ld e, l - ld a, [CurPartySpecies] - cp EGG - jr nz, .not_egg - xor a - ld [de], a - inc de - ld [de], a - jr .zero_status - -.not_egg - push bc - ld hl, MON_MAXHP - add hl, bc - ld bc, 2 - call CopyBytes - pop bc - -.zero_status - ld hl, MON_STATUS - add hl, bc - xor a - ld [hli], a - ld [hl], a - ret - -GetPkmnSpecies: ; 508d5 -; [MonType] has the type of the Pkmn -; e = Nr. of Pkmn (i.e. [CurPartyMon]) - - ld a, [MonType] - and a ; PARTYMON - jr z, .partymon - cp OTPARTYMON - jr z, .otpartymon - cp BOXMON - jr z, .boxmon - cp TEMPMON - jr z, .breedmon - ; WILDMON - -.partymon - ld hl, PartySpecies - jr .done - -.otpartymon - ld hl, OTPartySpecies - jr .done - -.boxmon - ld a, BANK(sBoxSpecies) - call GetSRAMBank - ld hl, sBoxSpecies - call .done - call CloseSRAM - ret - -.breedmon - ld a, [wBreedMon1Species] - jr .done2 - -.done - ld d, 0 - add hl, de - ld a, [hl] - -.done2 - ld [CurPartySpecies], a - ret - +INCLUDE "engine/tempmon.asm" INCLUDE "text/types.asm" INCLUDE "text/unused_gen_1_trainers.asm" INCLUDE "engine/mon_stats.asm" - -InitList: ; 50db9 - ld a, [wInitListType] - - cp INIT_ENEMYOT_LIST - jr nz, .check_party_ot_name - ld hl, OTPartyCount - ld de, OTPartyMonOT - ld a, ENEMY_OT_NAME - jr .done - -.check_party_ot_name - cp INIT_PLAYEROT_LIST - jr nz, .check_mon_name - ld hl, PartyCount - ld de, PartyMonOT - ld a, PARTY_OT_NAME - jr .done - -.check_mon_name - cp INIT_MON_LIST - jr nz, .check_item_name - ld hl, CurMart - ld de, PokemonNames - ld a, PKMN_NAME - jr .done - -.check_item_name - cp INIT_BAG_ITEM_LIST - jr nz, .check_ob_item_name - ld hl, NumItems - ld de, ItemNames - ld a, ITEM_NAME - jr .done - -.check_ob_item_name - ld hl, CurMart - ld de, ItemNames - ld a, ITEM_NAME -.done - ld [wNamedObjectTypeBuffer], a ; d265 - ld a, l - ld [wListPointer], a - ld a, h - ld [wListPointer + 1], a - ld a, e - ld [wUnusedD102], a - ld a, d - ld [wUnusedD102 + 1], a - ld bc, ItemAttributes ; ParseEnemyAction, HandleMapTimeAndJoypad, Music_LakeOfRage_Ch3, String_11a7c1 $67c1 - ld a, c - ld [wItemAttributesPtr], a - ld a, b - ld [wItemAttributesPtr + 1], a - ret - +INCLUDE "engine/init_list.asm" INCLUDE "engine/experience.asm" - -_SwitchPartyMons: - ld a, [wd0e3] - dec a - ld [Buffer3], a - ld b, a - ld a, [wMenuCursorY] - dec a - ld [Buffer2], a - cp b - jr z, .skip - call .SwapMonAndMail - ld a, [Buffer3] - call .ClearSprite - ld a, [Buffer2] - call .ClearSprite -.skip - ret - -.ClearSprite: ; 50f34 (14:4f34) - push af - hlcoord 0, 1 - ld bc, 2 * SCREEN_WIDTH - call AddNTimes - ld bc, 2 * SCREEN_WIDTH - ld a, " " - call ByteFill - pop af - ld hl, Sprites - ld bc, $10 - call AddNTimes - ld de, $4 - ld c, $4 -.gfx_loop - ld [hl], $a0 - add hl, de - dec c - jr nz, .gfx_loop - ld de, SFX_SWITCH_POKEMON - call WaitPlaySFX - ret - -.SwapMonAndMail: ; 50f62 (14:4f62) - push hl - push de - push bc - ld bc, PartySpecies - ld a, [Buffer2] - ld l, a - ld h, $0 - add hl, bc - ld d, h - ld e, l - ld a, [Buffer3] - ld l, a - ld h, $0 - add hl, bc - ld a, [hl] - push af - ld a, [de] - ld [hl], a - pop af - ld [de], a - ld a, [Buffer2] - ld hl, PartyMon1Species - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - push hl - ld de, wd002 - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - ld a, [Buffer3] - ld hl, PartyMon1 - ld bc, PARTYMON_STRUCT_LENGTH - call AddNTimes - pop de - push hl - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - pop de - ld hl, wd002 - ld bc, PARTYMON_STRUCT_LENGTH - call CopyBytes - ld a, [Buffer2] - ld hl, PartyMonOT - call SkipNames - push hl - call .CopyNameTowd002 - ld a, [Buffer3] - ld hl, PartyMonOT - call SkipNames - pop de - push hl - call .CopyName - pop de - ld hl, wd002 - call .CopyName - ld hl, PartyMonNicknames - ld a, [Buffer2] - call SkipNames - push hl - call .CopyNameTowd002 - ld hl, PartyMonNicknames - ld a, [Buffer3] - call SkipNames - pop de - push hl - call .CopyName - pop de - ld hl, wd002 - call .CopyName - ld hl, sPartyMail - ld a, [Buffer2] - ld bc, MAIL_STRUCT_LENGTH - call AddNTimes - push hl - ld de, wd002 - ld bc, MAIL_STRUCT_LENGTH - ld a, BANK(sPartyMail) - call GetSRAMBank - call CopyBytes - ld hl, sPartyMail - ld a, [Buffer3] - ld bc, MAIL_STRUCT_LENGTH - call AddNTimes - pop de - push hl - ld bc, MAIL_STRUCT_LENGTH - call CopyBytes - pop de - ld hl, wd002 - ld bc, MAIL_STRUCT_LENGTH - call CopyBytes - call CloseSRAM - pop bc - pop de - pop hl - ret - -.CopyNameTowd002: ; 51036 (14:5036) - ld de, wd002 - -.CopyName: ; 51039 (14:5039) - ld bc, NAME_LENGTH - call CopyBytes - ret - +INCLUDE "engine/switch_party_mons.asm" INCLUDE "gfx/load_pics.asm" INCLUDE "engine/move_mon_wo_mail.asm" INCLUDE "data/pokemon/base_stats.asm" @@ -1744,55 +1086,7 @@ SECTION "bank32", ROMX INCLUDE "battle/bg_effects.asm" INCLUDE "battle/anims.asm" - -LoadPoisonBGPals: ; cbcdd - call .LoadPals - ld a, [hCGB] - and a - ret nz - ret ; ???? - -.LoadPals: ; cbce5 - ld a, [hCGB] - and a - jr nz, .cgb - ld a, [TimeOfDayPal] - and $3 - cp $3 - ld a, %00000000 - jr z, .convert_pals - ld a, %10101010 - -.convert_pals - call DmgToCgbBGPals - ld c, 4 - call DelayFrames - callba _UpdateTimePals - ret - -.cgb - ld a, [rSVBK] - push af - ld a, $5 - ld [rSVBK], a - ld hl, BGPals - ld c, $20 -.loop -; RGB 28, 21, 31 - ld a, (palred 28 + palgreen 21 + palblue 31) % $100 - ld [hli], a - ld a, (palred 28 + palgreen 21 + palblue 31) / $100 - ld [hli], a - dec c - jr nz, .loop - pop af - ld [rSVBK], a - ld a, $1 - ld [hCGBPalUpdate], a - ld c, 4 - call DelayFrames - callba _UpdateTimePals - ret +INCLUDE "event/poisonstep_pals.asm" TheEndGFX:: ; cbd2e INCBIN "gfx/credits/theend.2bpp" @@ -1800,7 +1094,7 @@ INCBIN "gfx/credits/theend.2bpp" SECTION "bank33", ROMX -INCLUDE "event/bug_contest_mon_stats.asm" +INCLUDE "event/bug_contest/display_stats.asm" INCLUDE "battle/anim_commands.asm" INCLUDE "battle/anim_objects.asm" @@ -1843,117 +1137,7 @@ INCLUDE "gfx/pics/unown_frames.asm" SECTION "bank38", ROMX -RotateUnownFrontpic: ; e0000 -; something to do with Unown printer - push de - xor a - call GetSRAMBank - ld hl, sScratch - ld bc, 0 -.loop - push bc - push hl - push bc - ld de, wd002 - call .Copy - call .Rotate - ld hl, UnownPrinter_OverworldMapRectangle - pop bc - add hl, bc - add hl, bc - ld a, [hli] - ld e, a - ld d, [hl] - ld hl, wd012 - call .Copy - pop hl - ld bc, $10 - add hl, bc - pop bc - inc c - ld a, c - cp 7 * 7 - jr c, .loop - - ld hl, OverworldMap - ld de, sScratch - ld bc, 7 * 7 tiles - call CopyBytes - pop hl - ld de, sScratch - ld c, 7 * 7 - ld a, [hROMBank] - ld b, a - call Get2bpp - call CloseSRAM - ret - -.Copy: ; e004e - ld c, $10 -.loop_copy - ld a, [hli] - ld [de], a - inc de - dec c - jr nz, .loop_copy - ret - -.Rotate: ; e0057 - ld hl, wd012 - ld e, %10000000 - ld d, 8 -.loop_decompress - push hl - ld hl, wd002 - call .CountSetBit - pop hl - ld a, b - ld [hli], a - push hl - ld hl, wd003 - call .CountSetBit - pop hl - ld a, b - ld [hli], a - srl e - dec d - jr nz, .loop_decompress - ret - -.CountSetBit: ; e0078 - ld b, 0 - ld c, 8 -.loop_count - ld a, [hli] - and e - jr z, .clear - scf - jr .apply - -.clear - and a - -.apply - rr b - inc hl - dec c - jr nz, .loop_count - ret - -overworldmaprect: MACRO -y = 0 -rept \1 -x = \1 * (\2 +- 1) + y -rept \2 - dw OverworldMap tile x -x = x +- \2 -endr -y = y + 1 -endr -endm - -UnownPrinter_OverworldMapRectangle: ; e008b - overworldmaprect 7, 7 +INCLUDE "event/print_unown_2.asm" Unknown_e00ed: ; Graphics for an unused Game Corner @@ -2009,7 +1193,7 @@ SECTION "bank41", ROMX INCLUDE "engine/dma_transfer.asm" INCLUDE "gfx/emotes.asm" INCLUDE "engine/warp_connection.asm" -INCLUDE "engine/mysterygift.asm" +INCLUDE "engine/mystery_gift.asm" INCLUDE "battle/used_move_text.asm" INCLUDE "mobile/mobile_41.asm" INCLUDE "gfx/overworld_font.asm" @@ -2113,100 +1297,11 @@ INCLUDE "engine/print_party.asm" SECTION "bank77_2", ROMX -Function1dd6a9: ; 1dd6a9 -; XXX - ld a, b - ld b, c - ld c, a - push bc - push de - ld hl, sp+$2 - ld d, h - ld e, l - pop hl - lb bc, PRINTNUM_LEADINGZEROS | 2, 5 - call PrintNum - pop bc - ret - -PrintHoursMins ; 1dd6bb (77:56bb) -; Hours in b, minutes in c - ld a, b - cp 12 - push af - jr c, .AM - jr z, .PM - sub 12 - jr .PM -.AM: - or a - jr nz, .PM - ld a, 12 -.PM: - ld b, a -; Crazy stuff happening with the stack - push bc - ld hl, sp+$1 - push de - push hl - pop de - pop hl - ld [hl], " " - lb bc, 1, 2 - call PrintNum - ld [hl], ":" - inc hl - ld d, h - ld e, l - ld hl, sp+$0 - push de - push hl - pop de - pop hl - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - pop bc - ld de, String_AM - pop af - jr c, .place_am_pm - ld de, String_PM -.place_am_pm - inc hl - call PlaceString - ret - -String_AM: db "AM@" ; 1dd6fc -String_PM: db "PM@" ; 1dd6ff - +INCLUDE "engine/printhoursmins.asm" INCLUDE "engine/diploma.asm" INCLUDE "engine/pokedex_3.asm" INCLUDE "event/catch_tutorial_input.asm" - -TownMap_ConvertLineBreakCharacters: ; 1de2c5 - ld hl, StringBuffer1 -.loop - ld a, [hl] - cp "@" - jr z, .end - cp "%" - jr z, .line_break - cp "¯" - jr z, .line_break - inc hl - jr .loop - -.line_break - ld [hl], "" - -.end - ld de, StringBuffer1 - hlcoord 9, 0 - call PlaceString - ret - -PokegearGFX: ; 1de2e4 -INCBIN "gfx/pokegear/pokegear.2bpp.lz" - +INCLUDE "engine/pokegear_2.asm" INCLUDE "engine/european_mail.asm" diff --git a/maps/BattleTower1F.asm b/maps/BattleTower1F.asm index 9238d5dbd..c6b188b8d 100644 --- a/maps/BattleTower1F.asm +++ b/maps/BattleTower1F.asm @@ -60,7 +60,7 @@ ReceptionistScript_0x9e3e2: opentext writetext Text_BattleTowerWelcomesYou buttonsound - writebyte BATTLETOWERACTION_CHECK_EXPLANATION_READ ; if new save file: bit 1, [s1_be4f] + writebyte BATTLETOWERACTION_CHECK_EXPLANATION_READ ; if new save file: bit 1, [sBattleTowerSaveFileFlags] special BattleTowerAction if_not_equal $0, Script_Menu_ChallengeExplanationCancel jump Script_BattleTowerIntroductionYesNo @@ -85,7 +85,7 @@ Script_ChooseChallenge: ; 0x9e40f special Special_TryQuickSave iffalse Script_Menu_ChallengeExplanationCancel dotrigger $1 - writebyte BATTLETOWERACTION_SET_EXPLANATION_READ ; set 1, [s1_be4f] + writebyte BATTLETOWERACTION_SET_EXPLANATION_READ ; set 1, [sBattleTowerSaveFileFlags] special BattleTowerAction special BattleTowerRoomMenu if_equal $a, Script_Menu_ChallengeExplanationCancel diff --git a/mobile/battle_tower_5c.asm b/mobile/battle_tower_5c.asm index 462e4f75a..baa2e6159 100755 --- a/mobile/battle_tower_5c.asm +++ b/mobile/battle_tower_5c.asm @@ -1079,9 +1079,9 @@ BattleTowerAction_CheckExplanationRead: ; 17075f (5c:475f) BattleTowerAction $00 and a ret z - ld a, BANK(s1_be4f) + ld a, BANK(sBattleTowerSaveFileFlags) call GetSRAMBank - ld a, [s1_be4f] + ld a, [sBattleTowerSaveFileFlags] and $2 ld [ScriptVar], a call CloseSRAM @@ -1097,11 +1097,11 @@ BattleTowerAction_GetChallengeState: ; 170778 (5c:4778) BattleTowerAction $02 ret BattleTowerAction_SetExplanationRead: ; 170788 (5c:4788) BattleTowerAction $01 - ld a, BANK(s1_be4f) + ld a, BANK(sBattleTowerSaveFileFlags) call GetSRAMBank - ld a, [s1_be4f] + ld a, [sBattleTowerSaveFileFlags] or $2 - ld [s1_be4f], a + ld [sBattleTowerSaveFileFlags], a call CloseSRAM ret @@ -1583,20 +1583,20 @@ Function170abe: ; 170abe (5c:4abe) BattleTowerAction $14 and a ret z - ld a, BANK(s1_be4f) + ld a, BANK(sBattleTowerSaveFileFlags) call GetSRAMBank - ld a, [s1_be4f] + ld a, [sBattleTowerSaveFileFlags] and $1 ld [ScriptVar], a call CloseSRAM ret Function170ad7: ; 170ad7 (5c:4ad7) BattleTowerAction $15 - ld a, BANK(s1_be4f) + ld a, BANK(sBattleTowerSaveFileFlags) call GetSRAMBank - ld a, [s1_be4f] + ld a, [sBattleTowerSaveFileFlags] or $1 - ld [s1_be4f], a + ld [sBattleTowerSaveFileFlags], a call CloseSRAM ret diff --git a/mobile/get_trainer_class.asm b/mobile/get_trainer_class.asm new file mode 100644 index 000000000..37fe91c56 --- /dev/null +++ b/mobile/get_trainer_class.asm @@ -0,0 +1,46 @@ +GetMobileOTTrainerClass: ; mobile function + ld h, b + ld l, c + call .GetMobileOTTrainerClass + ld c, a + ret + +.GetMobileOTTrainerClass: ; 4e930 + ld a, [hli] + xor [hl] + ld c, a + jr z, .skip_male_trainers + srl c + srl c +.male_trainer_loop + srl c + ld a, c + cp MaleTrainersEnd - MaleTrainers - 1 + jr nc, .male_trainer_loop + inc c + +.skip_male_trainers + ld a, [de] + cp $1 + ld hl, MaleTrainers + jr nz, .finished + + ld hl, FemaleTrainers + ld a, c + and a + jr z, .finished + +.female_trainer_loop + srl c + ld a, c + cp FemaleTrainersEnd - FemaleTrainers - 1 + jr nc, .female_trainer_loop + inc c + +.finished + ld b, $0 + add hl, bc + ld a, [hl] + ret + +INCLUDE "data/trainers/gendered_trainers.asm" diff --git a/sram.asm b/sram.asm index 5853cd61c..163de6bda 100644 --- a/sram.asm +++ b/sram.asm @@ -1,9 +1,11 @@ SRAM_Begin EQU $a000 SRAM_End EQU $c000 + GLOBAL SRAM_Begin, SRAM_End SECTION "Scratch", SRAM + sScratch:: @@ -11,12 +13,12 @@ SECTION "SRAM Bank 0", SRAM ; a600 sPartyMail:: -sPartyMon1Mail:: mailmsg sPartyMon1Mail -sPartyMon2Mail:: mailmsg sPartyMon2Mail -sPartyMon3Mail:: mailmsg sPartyMon3Mail -sPartyMon4Mail:: mailmsg sPartyMon4Mail -sPartyMon5Mail:: mailmsg sPartyMon5Mail -sPartyMon6Mail:: mailmsg sPartyMon6Mail +sPartyMon1Mail:: mailmsg sPartyMon1Mail +sPartyMon2Mail:: mailmsg sPartyMon2Mail +sPartyMon3Mail:: mailmsg sPartyMon3Mail +sPartyMon4Mail:: mailmsg sPartyMon4Mail +sPartyMon5Mail:: mailmsg sPartyMon5Mail +sPartyMon6Mail:: mailmsg sPartyMon6Mail ; a71a sPartyMailBackup:: @@ -28,45 +30,45 @@ sPartyMon5MailBackup:: mailmsg sPartyMon5MailBackup sPartyMon6MailBackup:: mailmsg sPartyMon6MailBackup ; a834 -sMailboxCount:: ds 1 +sMailboxCount:: db sMailbox:: -sMailbox1:: mailmsg sMailbox1 -sMailbox2:: mailmsg sMailbox2 -sMailbox3:: mailmsg sMailbox3 -sMailbox4:: mailmsg sMailbox4 -sMailbox5:: mailmsg sMailbox5 -sMailbox6:: mailmsg sMailbox6 -sMailbox7:: mailmsg sMailbox7 -sMailbox8:: mailmsg sMailbox8 -sMailbox9:: mailmsg sMailbox9 -sMailbox10:: mailmsg sMailbox10 +sMailbox1:: mailmsg sMailbox1 +sMailbox2:: mailmsg sMailbox2 +sMailbox3:: mailmsg sMailbox3 +sMailbox4:: mailmsg sMailbox4 +sMailbox5:: mailmsg sMailbox5 +sMailbox6:: mailmsg sMailbox6 +sMailbox7:: mailmsg sMailbox7 +sMailbox8:: mailmsg sMailbox8 +sMailbox9:: mailmsg sMailbox9 +sMailbox10:: mailmsg sMailbox10 ; aa0b -sMailboxCountBackup:: ds 1 +sMailboxCountBackup:: db sMailboxBackup:: -sMailbox1Backup:: mailmsg sMailbox1Backup -sMailbox2Backup:: mailmsg sMailbox2Backup -sMailbox3Backup:: mailmsg sMailbox3Backup -sMailbox4Backup:: mailmsg sMailbox4Backup -sMailbox5Backup:: mailmsg sMailbox5Backup -sMailbox6Backup:: mailmsg sMailbox6Backup -sMailbox7Backup:: mailmsg sMailbox7Backup -sMailbox8Backup:: mailmsg sMailbox8Backup -sMailbox9Backup:: mailmsg sMailbox9Backup -sMailbox10Backup:: mailmsg sMailbox10Backup +sMailbox1Backup:: mailmsg sMailbox1Backup +sMailbox2Backup:: mailmsg sMailbox2Backup +sMailbox3Backup:: mailmsg sMailbox3Backup +sMailbox4Backup:: mailmsg sMailbox4Backup +sMailbox5Backup:: mailmsg sMailbox5Backup +sMailbox6Backup:: mailmsg sMailbox6Backup +sMailbox7Backup:: mailmsg sMailbox7Backup +sMailbox8Backup:: mailmsg sMailbox8Backup +sMailbox9Backup:: mailmsg sMailbox9Backup +sMailbox10Backup:: mailmsg sMailbox10Backup ; abe2 -sMysteryGiftItem:: ds 1 -sMysteryGiftUnlocked:: ds 1 -sBackupMysteryGiftItem:: ds 1 -sNumDailyMysteryGiftPartnerIDs:: ds 1 +sMysteryGiftItem:: db +sMysteryGiftUnlocked:: db +sBackupMysteryGiftItem:: db +sNumDailyMysteryGiftPartnerIDs:: db sDailyMysteryGiftPartnerIDs:: ds 5 * 2 ; maximum 5 per day, 2 bytes per ID sMysteryGiftDecorationsReceived:: flag_array NUM_NON_TROPHY_DECOS ds 4 -sMysteryGiftTimer:: ds 1 -sMysteryGiftTimerStartDay:: ds 1 +sMysteryGiftTimer:: db +sMysteryGiftTimerStartDay:: db ds 1 -sMysteryGiftTrainerHouseFlag:: ds 1 +sMysteryGiftTrainerHouseFlag:: db sMysteryGiftPartnerName:: ds NAME_LENGTH s0_ac09:: ds 1 sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 ; ac0a @@ -75,13 +77,15 @@ sBackupMysteryGiftItemEnd:: ds $30 sRTCStatusFlags:: ds 8 -sLuckyNumberDay:: ds 1 -sLuckyIDNumber:: ds 2 +sLuckyNumberDay:: db +sLuckyIDNumber:: dw + SECTION "Backup Save", SRAM + sBackupOptions:: ds OptionsEnd - Options -s0_b208:: ds 1 ; loaded with 99, used to check save corruption +sBackupCheckValue1:: db ; loaded with SAVE_CHECK_VALUE_1, used to check save corruption sBackupGameData:: ; b209 sBackupPlayerData:: ds wPlayerDataEnd - wPlayerData @@ -93,16 +97,18 @@ sBackupGameDataEnd:: ds $18a ; bf0d -sBackupChecksum:: ds 2 -s0_bf0f:: ds 1 ; loaded with 0x7f, used to check save corruption -sStackTop:: ds 2 +sBackupChecksum:: dw + +sBackupCheckValue2:: db ; loaded with SAVE_CHECK_VALUE_2, used to check save corruption + +sStackTop:: dw SECTION "Save", SRAM sOptions:: ds OptionsEnd - Options -s1_a008:: ds 1 ; loaded with 99, used to check save corruption +sCheckValue1:: db ; loaded with SAVE_CHECK_VALUE_1, used to check save corruption sGameData:: ; a009 sPlayerData:: ds wPlayerDataEnd - wPlayerData @@ -114,22 +120,28 @@ sGameDataEnd:: ds $18a ; ad0d -sChecksum:: ds 2 -s1_ad0f:: ds 1 ; loaded with 0x7f, used to check save corruption +sChecksum:: dw + +sCheckValue2:: db ; loaded with SAVE_CHECK_VALUE_2, used to check save corruption + SECTION "Active Box", SRAM + ; ad10 box sBox ; b160 ds $f4 + + SECTION "Link Battle Data", SRAM + sLinkBattleResults:: ds $c -sLinkBattleStats:: ; b260 -sLinkBattleWins:: ds 2 -sLinkBattleLosses:: ds 2 ; b262 -sLinkBattleDraws:: ds 2 ; b264 +sLinkBattleStats:: +sLinkBattleWins:: dw ; b260 +sLinkBattleLosses:: dw ; b262 +sLinkBattleDraws:: dw ; b264 sLinkBattleRecord:: sLinkBattleRecord1:: link_battle_record sLinkBattleRecord1 @@ -139,88 +151,80 @@ sLinkBattleRecord4:: link_battle_record sLinkBattleRecord4 sLinkBattleRecord5:: link_battle_record sLinkBattleRecord5 sLinkBattleStatsEnd:: -SECTION "SRAM Hall of Fame", SRAM -sHallOfFame:: ; b2c0 -; temporary until I can find a way to macrofy it - hall_of_fame sHallOfFame01 - hall_of_fame sHallOfFame02 - hall_of_fame sHallOfFame03 - hall_of_fame sHallOfFame04 - hall_of_fame sHallOfFame05 - hall_of_fame sHallOfFame06 - hall_of_fame sHallOfFame07 - hall_of_fame sHallOfFame08 - hall_of_fame sHallOfFame09 - hall_of_fame sHallOfFame10 - hall_of_fame sHallOfFame11 - hall_of_fame sHallOfFame12 - hall_of_fame sHallOfFame13 - hall_of_fame sHallOfFame14 - hall_of_fame sHallOfFame15 - hall_of_fame sHallOfFame16 - hall_of_fame sHallOfFame17 - hall_of_fame sHallOfFame18 - hall_of_fame sHallOfFame19 - hall_of_fame sHallOfFame20 - hall_of_fame sHallOfFame21 - hall_of_fame sHallOfFame22 - hall_of_fame sHallOfFame23 - hall_of_fame sHallOfFame24 - hall_of_fame sHallOfFame25 - hall_of_fame sHallOfFame26 - hall_of_fame sHallOfFame27 - hall_of_fame sHallOfFame28 - hall_of_fame sHallOfFame29 - hall_of_fame sHallOfFame30 -; x = 1 -; rept NUM_HOF_TEAMS -; ; PRINTT("{x}\n") -; if STRLEN({x}) == 2 - ; PRINTT(STRSUB({x},2,1)) - ; hall_of_fame STRCAT("sHallOfFame0", STRSUB({x},2,1)) -; else - ; PRINTT(STRSUB({x},2,2)) - ; hall_of_fame STRCAT("sHallOfFame", STRSUB({x},2,2)) -; endc -; x = x + 1 -; endr +SECTION "SRAM Hall of Fame", SRAM + +sHallOfFame:: ; b2c0 +sHallOfFame01:: hall_of_fame sHallOfFame01 +sHallOfFame02:: hall_of_fame sHallOfFame02 +sHallOfFame03:: hall_of_fame sHallOfFame03 +sHallOfFame04:: hall_of_fame sHallOfFame04 +sHallOfFame05:: hall_of_fame sHallOfFame05 +sHallOfFame06:: hall_of_fame sHallOfFame06 +sHallOfFame07:: hall_of_fame sHallOfFame07 +sHallOfFame08:: hall_of_fame sHallOfFame08 +sHallOfFame09:: hall_of_fame sHallOfFame09 +sHallOfFame10:: hall_of_fame sHallOfFame10 +sHallOfFame11:: hall_of_fame sHallOfFame11 +sHallOfFame12:: hall_of_fame sHallOfFame12 +sHallOfFame13:: hall_of_fame sHallOfFame13 +sHallOfFame14:: hall_of_fame sHallOfFame14 +sHallOfFame15:: hall_of_fame sHallOfFame15 +sHallOfFame16:: hall_of_fame sHallOfFame16 +sHallOfFame17:: hall_of_fame sHallOfFame17 +sHallOfFame18:: hall_of_fame sHallOfFame18 +sHallOfFame19:: hall_of_fame sHallOfFame19 +sHallOfFame20:: hall_of_fame sHallOfFame20 +sHallOfFame21:: hall_of_fame sHallOfFame21 +sHallOfFame22:: hall_of_fame sHallOfFame22 +sHallOfFame23:: hall_of_fame sHallOfFame23 +sHallOfFame24:: hall_of_fame sHallOfFame24 +sHallOfFame25:: hall_of_fame sHallOfFame25 +sHallOfFame26:: hall_of_fame sHallOfFame26 +sHallOfFame27:: hall_of_fame sHallOfFame27 +sHallOfFame28:: hall_of_fame sHallOfFame28 +sHallOfFame29:: hall_of_fame sHallOfFame29 +sHallOfFame30:: hall_of_fame sHallOfFame30 sHallOfFameEnd:: -SECTION "SRAM Crystal Data", SRAM -sMobileEventIndex:: ds 1 ; be3c -sCrystalData:: - ds wCrystalDataEnd - wCrystalData -sMobileEventIndexBackup:: ds 1 +SECTION "SRAM Crystal Data", SRAM + +sMobileEventIndex:: db ; be3c + +sCrystalData:: ds wCrystalDataEnd - wCrystalData +sMobileEventIndexBackup:: db + SECTION "SRAM Battle Tower", SRAM -; data of the BattleTower must be in SRAM because you can save and leave between battles -sBattleTowerChallengeState:: ds 1 + +; Battle Tower data must be in SRAM because you can save and leave between battles +sBattleTowerChallengeState:: ; 0: normal ; 2: battle tower + db sBattleTower:: ; be46 -sNrOfBeatenBattleTowerTrainers:: ds 1 -sBTChoiceOfLevelGroup:: ds 1 -; The 7 trainers of the BattleTower are saved here, so nobody appears more than once -sBTTrainers:: ; sbe48 - ds 7 -s1_be4f:: ds 1 -sBattleTowerReward:: ds 1 -; Pkmn of previous trainer +sNrOfBeatenBattleTowerTrainers:: db +sBTChoiceOfLevelGroup:: db +; Battle Tower trainers are saved here, so nobody appears more than once +sBTTrainers:: ds BATTLETOWER_NROFTRAINERS ; sbe48 +sBattleTowerSaveFileFlags:: db +sBattleTowerReward:: db + +; team of previous trainer sBTPkmnOfTrainers:: ; 0xbe51 -sBTPkmnPrevTrainer1:: - ds 1 -sBTPkmnPrevTrainer2:: ds 1 -sBTPkmnPrevTrainer3:: ds 1 -; Pkmn of preprevious trainer -sBTPkmnPrevPrevTrainer1:: ds 1 -sBTPkmnPrevPrevTrainer2:: ds 1 -sBTPkmnPrevPrevTrainer3:: ds 1 +sBTPkmnPrevTrainer1:: db +sBTPkmnPrevTrainer2:: db +sBTPkmnPrevTrainer3:: db +; team of preprevious trainer +sBTPkmnPrevPrevTrainer1:: db +sBTPkmnPrevPrevTrainer2:: db +sBTPkmnPrevPrevTrainer3:: db SECTION "Boxes 1-7", SRAM, BANK [2] + box sBox1 box sBox2 box sBox3 @@ -229,7 +233,9 @@ SECTION "Boxes 1-7", SRAM, BANK [2] box sBox6 box sBox7 + SECTION "Boxes 8-14", SRAM + box sBox8 box sBox9 box sBox10 @@ -239,7 +245,8 @@ SECTION "Boxes 8-14", SRAM box sBox14 SECTION "SRAM Mobile", SRAM, BANK [5] -ds 1 ; Former location for sMobileEventIndex, moved to 1:BE3C in English + + ds 1 ; former location for sMobileEventIndex, moved to 1:BE3C in English sTrainerRankings:: ; a001 sTrainerRankingGameTimeHOF:: ds 4 sTrainerRankingStepCountHOF:: ds 4 @@ -285,9 +292,11 @@ sTrainerRankingShortestMagikarp:: ds 2 sTrainerRankingBugContestScore:: ds 2 sTrainerRankingsChecksum:: ds 2 sTrainerRankingsEnd:: ; a083 + ds 1 ; Former location for sMobileEventIndexBackup, moved to 1:BE44 in English sTrainerRankingsBackup:: ds sTrainerRankingsEnd - sTrainerRankings ds $945 ; aa4b + sMobileLoginPassword:: ds MOBILE_LOGIN_PASSWORD_LENGTH diff --git a/wram.asm b/wram.asm index df154266d..c26fde5a1 100644 --- a/wram.asm +++ b/wram.asm @@ -349,7 +349,7 @@ wBT_OTTemp:: battle_tower_struct wBT_OTTemp NEXTU ; c608 ; hall of fame temp struct - hall_of_fame wHallOfFameTemp +wHallOfFameTemp:: hall_of_fame wHallOfFameTemp NEXTU ; c608 ; timeset temp storage @@ -2838,14 +2838,13 @@ w3_d662:: battle_tower_struct w3_d662 UNION ; d742 w3_d742:: battle_tower_struct w3_d742 ; d822 - NEXTU ; d742 ds $be - wBTChoiceOfLvlGroup:: w3_d800:: ; ds BG_MAP_WIDTH * SCREEN_HEIGHT ($240) ds $69 ENDU ; d869 + w3_d869:: ds $17 w3_d880:: ds 1 w3_d881:: ds 1 @@ -2860,7 +2859,6 @@ w3_d8a1:: ds 1 w3_d8a2:: ds 1 w3_d8a3:: ds $19d w3_da40:: ds $1c0 - w3_dc00:: ds SCREEN_WIDTH * SCREEN_HEIGHT w3_dd68:: ds SCREEN_WIDTH * SCREEN_HEIGHT ds $11c