diff --git a/Makefile b/Makefile index cb2c366d0..14235ff3b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ data/maps/map_data.o \ data/pokemon/dex_entries.o \ data/pokemon/egg_moves.o \ data/pokemon/evos_attacks.o \ -engine/title/credits.o \ +engine/movie/credits.o \ engine/overworld/events.o \ gfx/pics.o \ gfx/sprites.o \ diff --git a/engine/routines/checksave.asm b/engine/events/checksave.asm similarity index 100% rename from engine/routines/checksave.asm rename to engine/events/checksave.asm diff --git a/engine/routines/checktime.asm b/engine/events/checktime.asm similarity index 100% rename from engine/routines/checktime.asm rename to engine/events/checktime.asm diff --git a/engine/engine_flags.asm b/engine/events/engine_flags.asm similarity index 100% rename from engine/engine_flags.asm rename to engine/events/engine_flags.asm diff --git a/engine/money.asm b/engine/events/money.asm similarity index 100% rename from engine/money.asm rename to engine/events/money.asm diff --git a/engine/routines/playslowcry.asm b/engine/events/playslowcry.asm similarity index 100% rename from engine/routines/playslowcry.asm rename to engine/events/playslowcry.asm diff --git a/engine/gfx/crystal_layouts.asm b/engine/gfx/crystal_layouts.asm index 0133916e5..71e2e4f56 100755 --- a/engine/gfx/crystal_layouts.asm +++ b/engine/gfx/crystal_layouts.asm @@ -203,7 +203,7 @@ Function49496: ; 49496 ret ; 494ac -INCLUDE "engine/gfx/tileset_palettes.asm" +INCLUDE "engine/tilesets/tileset_palettes.asm" MG_Mobile_Layout02: ; 49706 ld hl, .Palette_49732 diff --git a/engine/dma_transfer.asm b/engine/gfx/dma_transfer.asm similarity index 100% rename from engine/dma_transfer.asm rename to engine/gfx/dma_transfer.asm diff --git a/engine/routines/loadpushoam.asm b/engine/gfx/loadpushoam.asm similarity index 100% rename from engine/routines/loadpushoam.asm rename to engine/gfx/loadpushoam.asm diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index 9db3dc291..442f73cfa 100755 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -1,49 +1,589 @@ -CanLearnTMHMMove: ; 11639 - ld a, [wCurPartySpecies] - ld [wCurSpecies], a - call GetBaseData - ld hl, wBaseTMHM - push hl +TMHMPocket: ; 2c76f (b:476f) + ld a, $1 + ld [hInMenu], a + call TMHM_PocketLoop + ld a, $0 + ld [hInMenu], a + ret nc + call PlaceHollowCursor + call WaitBGMap + ld a, [wCurItem] + dec a + ld [wCurItemQuantity], a + ld hl, wTMsHMs + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + ld [wItemQuantityBuffer], a + call .ConvertItemToTMHMNumber + scf + ret - ld a, [wPutativeTMHMMove] +.ConvertItemToTMHMNumber: ; 2c798 (b:4798) + ld a, [wCurItem] + ld c, a + callfar GetNumberedTMHM + ld a, c + ld [wCurItem], a + ret + +ConvertCurItemIntoCurTMHM: ; 2c7a7 (b:47a7) + ld a, [wCurItem] + ld c, a + callfar GetTMHMNumber + ld a, c + ld [wCurTMHM], a + ret + +GetTMHMItemMove: ; 2c7b6 (b:47b6) + call ConvertCurItemIntoCurTMHM + predef GetTMHMMove + ret + +AskTeachTMHM: ; 2c7bf (b:47bf) + ld hl, wOptions + ld a, [hl] + push af + res NO_TEXT_SCROLL, [hl] + ld a, [wCurItem] + cp TM01 + jr c, .NotTMHM + call GetTMHMItemMove + ld a, [wCurTMHM] + ld [wPutativeTMHMMove], a + call GetMoveName + call CopyName1 + ld hl, Text_BootedTM ; Booted up a TM + ld a, [wCurItem] + cp HM01 + jr c, .TM + ld hl, Text_BootedHM ; Booted up an HM +.TM: + call PrintText + ld hl, Text_ItContained + call PrintText + call YesNoBox +.NotTMHM: + pop bc + ld a, b + ld [wOptions], a + ret + +ChooseMonToLearnTMHM: ; 2c7fb + ld hl, wStringBuffer2 + ld de, wTMHMMoveNameBackup + ld bc, 12 + call CopyBytes + call ClearBGPalettes +ChooseMonToLearnTMHM_NoRefresh: ; 2c80a + farcall LoadPartyMenuGFX + farcall InitPartyMenuWithCancel + farcall InitPartyMenuGFX + ld a, PARTYMENUACTION_TEACH_TMHM + ld [wPartyMenuActionText], a +.loopback + farcall WritePartyMenuTilemap + farcall PrintPartyMenuText + call WaitBGMap + call SetPalettes + call DelayFrame + farcall PartyMenuSelect + push af + ld a, [wCurPartySpecies] + cp EGG + pop bc ; now contains the former contents of af + jr z, .egg + push bc + ld hl, wTMHMMoveNameBackup + ld de, wStringBuffer2 + ld bc, 12 + call CopyBytes + pop af ; now contains the original contents of af + ret + +.egg + push hl + push de + push bc + push af + ld de, SFX_WRONG + call PlaySFX + call WaitSFX + pop af + pop bc + pop de + pop hl + jr .loopback +; 2c867 + +TeachTMHM: ; 2c867 + predef CanLearnTMHMMove + + push bc + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames + call GetNick + pop bc + + ld a, c + and a + jr nz, .compatible + push de + ld de, SFX_WRONG + call PlaySFX + pop de + ld hl, Text_TMHMNotCompatible + call PrintText + jr .nope + +.compatible + callfar KnowsMove + jr c, .nope + + predef LearnMove + ld a, b + and a + jr z, .nope + + farcall StubbedTrainerRankings_TMsHMsTaught + ld a, [wCurItem] + call IsHM + ret c + + ld c, HAPPINESS_LEARNMOVE + callfar ChangeHappiness + call ConsumeTM + jr .learned_move + +.nope + and a + ret + +.unused + ld a, 2 + ld [wItemEffectSucceeded], a +.learned_move + scf + ret +; 2c8bf (b:48bf) + +Text_BootedTM: ; 0x2c8bf + ; Booted up a TM. + text_jump UnknownText_0x1c0373 + db "@" +; 0x2c8c4 + +Text_BootedHM: ; 0x2c8c4 + ; Booted up an HM. + text_jump UnknownText_0x1c0384 + db "@" +; 0x2c8c9 + +Text_ItContained: ; 0x2c8c9 + ; It contained @ . Teach @ to a #MON? + text_jump UnknownText_0x1c0396 + db "@" +; 0x2c8ce + +Text_TMHMNotCompatible: ; 0x2c8ce + ; is not compatible with @ . It can't learn @ . + text_jump UnknownText_0x1c03c2 + db "@" +; 0x2c8d3 + +TMHM_PocketLoop: ; 2c8d3 (b:48d3) + xor a + ld [hBGMapMode], a + call TMHM_DisplayPocketItems + ld a, 2 + ld [w2DMenuCursorInitY], a + ld a, 7 + ld [w2DMenuCursorInitX], a + ld a, 1 + ld [w2DMenuNumCols], a + ld a, 5 + sub d + inc a + cp 6 + jr nz, .okay + dec a +.okay + ld [w2DMenuNumRows], a + ld a, $c + ld [w2DMenuFlags1], a + xor a + ld [w2DMenuFlags2], a + ld a, $20 + ld [w2DMenuCursorOffsets], a + ld a, A_BUTTON | B_BUTTON | D_UP | D_DOWN | D_LEFT | D_RIGHT + ld [wMenuJoypadFilter], a + ld a, [wTMHMPocketCursor] + inc a + ld [wMenuCursorY], a + ld a, $1 + ld [wMenuCursorX], a + jr TMHM_ShowTMMoveDescription + +TMHM_JoypadLoop: ; 2c915 (b:4915) + call TMHM_DisplayPocketItems + call StaticMenuJoypad + ld b, a + ld a, [wMenuCursorY] + dec a + ld [wTMHMPocketCursor], a + xor a + ld [hBGMapMode], a + ld a, [w2DMenuFlags2] + bit 7, a + jp nz, TMHM_ScrollPocket + ld a, b + ld [wMenuJoypad], a + bit A_BUTTON_F, a + jp nz, TMHM_ChooseTMorHM + bit B_BUTTON_F, a + jp nz, TMHM_ExitPack + bit D_RIGHT_F, a + jp nz, TMHM_ExitPocket + bit D_LEFT_F, a + jp nz, TMHM_ExitPocket +TMHM_ShowTMMoveDescription: ; 2c946 (b:4946) + call TMHM_CheckHoveringOverCancel + jp nc, TMHM_ExitPocket + hlcoord 0, 12 + ld b, 4 + ld c, SCREEN_WIDTH - 2 + call TextBox + ld a, [wCurItem] + cp NUM_TMS + NUM_HMS + 1 + jr nc, TMHM_JoypadLoop + ld [wd265], a + predef GetTMHMMove + ld a, [wd265] + ld [wCurSpecies], a + hlcoord 1, 14 + call PrintMoveDesc + jp TMHM_JoypadLoop + +TMHM_ChooseTMorHM: ; 2c974 (b:4974) + call TMHM_PlaySFX_ReadText2 + call CountTMsHMs ; This stores the count to wd265. + ld a, [wMenuCursorY] + dec a + ld b, a + ld a, [wTMHMPocketScrollPosition] + add b + ld b, a + ld a, [wd265] + cp b + jr z, _TMHM_ExitPack ; our cursor was hovering over CANCEL +TMHM_CheckHoveringOverCancel: ; 2c98a (b:498a) + call TMHM_GetCurrentPocketPosition + ld a, [wMenuCursorY] ld b, a - ld c, 0 - ld hl, TMHMMoves .loop + inc c + ld a, c + cp NUM_TMS + NUM_HMS + 1 + jr nc, .okay ld a, [hli] and a - jr z, .end - cp b - jr z, .asm_11659 - inc c - jr .loop + jr z, .loop + dec b + jr nz, .loop + ld a, c +.okay + ld [wCurItem], a + cp -1 + ret -.asm_11659 - pop hl - ld b, CHECK_FLAG +TMHM_ExitPack: ; 2c9a5 (b:49a5) + call TMHM_PlaySFX_ReadText2 +_TMHM_ExitPack: ; 2c9a8 (b:49a8) + ld a, $2 + ld [wMenuJoypad], a + and a + ret + +TMHM_ExitPocket: ; 2c9af (b:49af) + and a + ret + +TMHM_ScrollPocket: ; 2c9b1 (b:49b1) + ld a, b + bit 7, a + jr nz, .skip + ld hl, wTMHMPocketScrollPosition + ld a, [hl] + and a + jp z, TMHM_JoypadLoop + dec [hl] + call TMHM_DisplayPocketItems + jp TMHM_ShowTMMoveDescription + +.skip + call TMHM_GetCurrentPocketPosition + ld b, 5 +.loop + inc c + ld a, c + cp NUM_TMS + NUM_HMS + 1 + jp nc, TMHM_JoypadLoop + ld a, [hli] + and a + jr z, .loop + dec b + jr nz, .loop + ld hl, wTMHMPocketScrollPosition + inc [hl] + call TMHM_DisplayPocketItems + jp TMHM_ShowTMMoveDescription + +TMHM_DisplayPocketItems: ; 2c9e2 (b:49e2) + ld a, [wBattleType] + cp BATTLETYPE_TUTORIAL + jp z, Tutorial_TMHMPocket + + hlcoord 5, 2 + lb bc, 10, 15 + ld a, " " + call ClearBox + call TMHM_GetCurrentPocketPosition + ld d, $5 +.loop2 + inc c + ld a, c + cp NUM_TMS + NUM_HMS + 1 + jr nc, .NotTMHM + ld a, [hli] + and a + jr z, .loop2 + ld b, a + ld a, c + ld [wd265], a + push hl push de - ld d, 0 - predef SmallFarFlagAction + push bc + call TMHMPocket_GetCurrentLineCoord + push hl + ld a, [wd265] + cp NUM_TMS + 1 + jr nc, .HM + ld de, wd265 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + jr .okay + +.HM: + push af + sub NUM_TMS + ld [wd265], a + ld [hl], "H" + inc hl + ld de, wd265 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 + call PrintNum + pop af + ld [wd265], a +.okay + predef GetTMHMMove + ld a, [wd265] + ld [wPutativeTMHMMove], a + call GetMoveName + pop hl + ld bc, 3 + add hl, bc + push hl + call PlaceString + pop hl + pop bc + ld a, c + push bc + cp NUM_TMS + 1 + jr nc, .hm2 + ld bc, SCREEN_WIDTH + 9 + add hl, bc + ld [hl], "×" + inc hl + ld a, "0" ; why are we doing this? + pop bc + push bc + ld a, b + ld [wd265], a + ld de, wd265 + lb bc, 1, 2 + call PrintNum +.hm2 + pop bc + pop de + pop hl + dec d + jr nz, .loop2 + jr .done + +.NotTMHM: + call TMHMPocket_GetCurrentLineCoord + inc hl + inc hl + inc hl + push de + ld de, TMHM_String_Cancel + call PlaceString + pop de +.done + ret + +TMHMPocket_GetCurrentLineCoord: ; 2ca86 (b:4a86) + hlcoord 5, 0 + ld bc, 2 * SCREEN_WIDTH + ld a, 6 + sub d + ld e, a + ; AddNTimes +.loop + add hl, bc + dec e + jr nz, .loop + ret +; 2ca95 (b:4a95) + +Unreferenced_Function2ca95: ; 2ca95 + pop hl + ld bc, 3 + add hl, bc + predef GetTMHMMove + ld a, [wd265] + ld [wPutativeTMHMMove], a + call GetMoveName + push hl + call PlaceString + pop hl + ret +; 2caae + +TMHM_String_Cancel: ; 2caae + db "CANCEL@" +; 2cab5 + +TMHM_GetCurrentPocketPosition: ; 2cab5 (b:4ab5) + ld hl, wTMsHMs + ld a, [wTMHMPocketScrollPosition] + ld b, a + inc b + ld c, 0 +.loop + inc c + ld a, [hli] + and a + jr z, .loop + dec b + jr nz, .loop + dec hl + dec c + ret + +Tutorial_TMHMPocket: ; 2caca (b:4aca) + hlcoord 9, 3 + push de + ld de, TMHM_String_Cancel + call PlaceString pop de ret -.end - pop hl - ld c, 0 +TMHM_PlaySFX_ReadText2: ; 2cad6 (b:4ad6) + push de + ld de, SFX_READ_TEXT_2 + call PlaySFX + pop de ret -; 1166a +; 2cadf (b:4adf) -GetTMHMMove: ; 1166a +Unreferenced_Function2cadf: ; 2cadf + call ConvertCurItemIntoCurTMHM + call .CheckHaveRoomForTMHM + ld hl, .NoRoomText + jr nc, .print + ld hl, .ReceivedText +.print + jp PrintText +; 2caf0 + +.NoRoomText: ; 0x2caf0 + ; You have no room for any more @ S. + text_jump UnknownText_0x1c03fa + db "@" +; 0x2caf5 + +.ReceivedText: ; 0x2caf5 + ; You received @ ! + text_jump UnknownText_0x1c0421 + db "@" +; 0x2cafa + +.CheckHaveRoomForTMHM: ; 2cafa ld a, [wd265] dec a - ld hl, TMHMMoves + ld hl, wTMsHMs ld b, 0 ld c, a add hl, bc ld a, [hl] + inc a + cp NUM_TMS * 2 + ret nc + ld [hl], a + ret +; 2cb0c + +ConsumeTM: ; 2cb0c (b:4b0c) + call ConvertCurItemIntoCurTMHM + ld a, [wd265] + dec a + ld hl, wTMsHMs + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + and a + ret z + dec a + ld [hl], a + ret nz + ld a, [wTMHMPocketScrollPosition] + and a + ret z + dec a + ld [wTMHMPocketScrollPosition], a + ret + +CountTMsHMs: ; 2cb2a (b:4b2a) + ld b, 0 + ld c, NUM_TMS + NUM_HMS + ld hl, wTMsHMs +.loop + ld a, [hli] + and a + jr z, .skip + inc b +.skip + dec c + jr nz, .loop + ld a, b ld [wd265], a ret -; 1167a - -INCLUDE "data/moves/tmhm_moves.asm" +PrintMoveDesc: ; 2cb3e + push hl + ld hl, MoveDescriptions + ld a, [wCurSpecies] + dec a + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld a, [hli] + ld e, a + ld d, [hl] + pop hl + jp PlaceString +; 2cb52 diff --git a/engine/items/tmhm2.asm b/engine/items/tmhm2.asm new file mode 100755 index 000000000..9db3dc291 --- /dev/null +++ b/engine/items/tmhm2.asm @@ -0,0 +1,49 @@ +CanLearnTMHMMove: ; 11639 + ld a, [wCurPartySpecies] + ld [wCurSpecies], a + call GetBaseData + ld hl, wBaseTMHM + push hl + + ld a, [wPutativeTMHMMove] + ld b, a + ld c, 0 + ld hl, TMHMMoves +.loop + ld a, [hli] + and a + jr z, .end + cp b + jr z, .asm_11659 + inc c + jr .loop + +.asm_11659 + pop hl + ld b, CHECK_FLAG + push de + ld d, 0 + predef SmallFarFlagAction + pop de + ret + +.end + pop hl + ld c, 0 + ret +; 1166a + +GetTMHMMove: ; 1166a + ld a, [wd265] + dec a + ld hl, TMHMMoves + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [wd265], a + ret +; 1167a + + +INCLUDE "data/moves/tmhm_moves.asm" diff --git a/engine/link/link.asm b/engine/link/link.asm index 86af41c01..f6f37619f 100755 --- a/engine/link/link.asm +++ b/engine/link/link.asm @@ -2029,7 +2029,7 @@ Unreferenced_Function28f09: ; 28f09 ret ; 28f24 -INCLUDE "engine/gfx/trade_animation.asm" +INCLUDE "engine/movie/trade_animation.asm" CheckTimeCapsuleCompatibility: ; 29bfb ; Checks to see if your party is compatible with the Gen 1 games. diff --git a/engine/routines/placewaitingtext.asm b/engine/link/placewaitingtext.asm similarity index 100% rename from engine/routines/placewaitingtext.asm rename to engine/link/placewaitingtext.asm diff --git a/engine/debug.asm b/engine/menus/debug.asm similarity index 100% rename from engine/debug.asm rename to engine/menus/debug.asm diff --git a/engine/save.asm b/engine/menus/save.asm similarity index 100% rename from engine/save.asm rename to engine/menus/save.asm diff --git a/engine/routines/savemenu_copytilemapatonce.asm b/engine/menus/savemenu_copytilemapatonce.asm similarity index 100% rename from engine/routines/savemenu_copytilemapatonce.asm rename to engine/menus/savemenu_copytilemapatonce.asm diff --git a/engine/title/credits.asm b/engine/movie/credits.asm similarity index 100% rename from engine/title/credits.asm rename to engine/movie/credits.asm diff --git a/engine/title/crystal_intro.asm b/engine/movie/crystal_intro.asm similarity index 100% rename from engine/title/crystal_intro.asm rename to engine/movie/crystal_intro.asm diff --git a/engine/gfx/evolution_animation.asm b/engine/movie/evolution_animation.asm similarity index 100% rename from engine/gfx/evolution_animation.asm rename to engine/movie/evolution_animation.asm diff --git a/engine/gfx/gbc_only.asm b/engine/movie/gbc_only.asm similarity index 100% rename from engine/gfx/gbc_only.asm rename to engine/movie/gbc_only.asm diff --git a/engine/title/init_hof_credits.asm b/engine/movie/init_hof_credits.asm similarity index 100% rename from engine/title/init_hof_credits.asm rename to engine/movie/init_hof_credits.asm diff --git a/engine/title/title.asm b/engine/movie/title.asm similarity index 100% rename from engine/title/title.asm rename to engine/movie/title.asm diff --git a/engine/gfx/trade_animation.asm b/engine/movie/trade_animation.asm similarity index 100% rename from engine/gfx/trade_animation.asm rename to engine/movie/trade_animation.asm diff --git a/engine/title/unused_title.asm b/engine/movie/unused_title.asm similarity index 100% rename from engine/title/unused_title.asm rename to engine/movie/unused_title.asm diff --git a/engine/routines/phonering_copytilemapatonce.asm b/engine/phone/phonering_copytilemapatonce.asm similarity index 100% rename from engine/routines/phonering_copytilemapatonce.asm rename to engine/phone/phonering_copytilemapatonce.asm diff --git a/engine/routines/townmap_convertlinebreakcharacters.asm b/engine/pokegear/townmap_convertlinebreakcharacters.asm similarity index 100% rename from engine/routines/townmap_convertlinebreakcharacters.asm rename to engine/pokegear/townmap_convertlinebreakcharacters.asm diff --git a/engine/routines/checknickerrors.asm b/engine/pokemon/checknickerrors.asm similarity index 100% rename from engine/routines/checknickerrors.asm rename to engine/pokemon/checknickerrors.asm diff --git a/engine/routines/correcterrorsinplayerparty.asm b/engine/pokemon/correcterrorsinplayerparty.asm similarity index 100% rename from engine/routines/correcterrorsinplayerparty.asm rename to engine/pokemon/correcterrorsinplayerparty.asm diff --git a/engine/pokemon/tmhm.asm b/engine/pokemon/tmhm.asm deleted file mode 100755 index 442f73cfa..000000000 --- a/engine/pokemon/tmhm.asm +++ /dev/null @@ -1,589 +0,0 @@ -TMHMPocket: ; 2c76f (b:476f) - ld a, $1 - ld [hInMenu], a - call TMHM_PocketLoop - ld a, $0 - ld [hInMenu], a - ret nc - call PlaceHollowCursor - call WaitBGMap - ld a, [wCurItem] - dec a - ld [wCurItemQuantity], a - ld hl, wTMsHMs - ld c, a - ld b, 0 - add hl, bc - ld a, [hl] - ld [wItemQuantityBuffer], a - call .ConvertItemToTMHMNumber - scf - ret - -.ConvertItemToTMHMNumber: ; 2c798 (b:4798) - ld a, [wCurItem] - ld c, a - callfar GetNumberedTMHM - ld a, c - ld [wCurItem], a - ret - -ConvertCurItemIntoCurTMHM: ; 2c7a7 (b:47a7) - ld a, [wCurItem] - ld c, a - callfar GetTMHMNumber - ld a, c - ld [wCurTMHM], a - ret - -GetTMHMItemMove: ; 2c7b6 (b:47b6) - call ConvertCurItemIntoCurTMHM - predef GetTMHMMove - ret - -AskTeachTMHM: ; 2c7bf (b:47bf) - ld hl, wOptions - ld a, [hl] - push af - res NO_TEXT_SCROLL, [hl] - ld a, [wCurItem] - cp TM01 - jr c, .NotTMHM - call GetTMHMItemMove - ld a, [wCurTMHM] - ld [wPutativeTMHMMove], a - call GetMoveName - call CopyName1 - ld hl, Text_BootedTM ; Booted up a TM - ld a, [wCurItem] - cp HM01 - jr c, .TM - ld hl, Text_BootedHM ; Booted up an HM -.TM: - call PrintText - ld hl, Text_ItContained - call PrintText - call YesNoBox -.NotTMHM: - pop bc - ld a, b - ld [wOptions], a - ret - -ChooseMonToLearnTMHM: ; 2c7fb - ld hl, wStringBuffer2 - ld de, wTMHMMoveNameBackup - ld bc, 12 - call CopyBytes - call ClearBGPalettes -ChooseMonToLearnTMHM_NoRefresh: ; 2c80a - farcall LoadPartyMenuGFX - farcall InitPartyMenuWithCancel - farcall InitPartyMenuGFX - ld a, PARTYMENUACTION_TEACH_TMHM - ld [wPartyMenuActionText], a -.loopback - farcall WritePartyMenuTilemap - farcall PrintPartyMenuText - call WaitBGMap - call SetPalettes - call DelayFrame - farcall PartyMenuSelect - push af - ld a, [wCurPartySpecies] - cp EGG - pop bc ; now contains the former contents of af - jr z, .egg - push bc - ld hl, wTMHMMoveNameBackup - ld de, wStringBuffer2 - ld bc, 12 - call CopyBytes - pop af ; now contains the original contents of af - ret - -.egg - push hl - push de - push bc - push af - ld de, SFX_WRONG - call PlaySFX - call WaitSFX - pop af - pop bc - pop de - pop hl - jr .loopback -; 2c867 - -TeachTMHM: ; 2c867 - predef CanLearnTMHMMove - - push bc - ld a, [wCurPartyMon] - ld hl, wPartyMonNicknames - call GetNick - pop bc - - ld a, c - and a - jr nz, .compatible - push de - ld de, SFX_WRONG - call PlaySFX - pop de - ld hl, Text_TMHMNotCompatible - call PrintText - jr .nope - -.compatible - callfar KnowsMove - jr c, .nope - - predef LearnMove - ld a, b - and a - jr z, .nope - - farcall StubbedTrainerRankings_TMsHMsTaught - ld a, [wCurItem] - call IsHM - ret c - - ld c, HAPPINESS_LEARNMOVE - callfar ChangeHappiness - call ConsumeTM - jr .learned_move - -.nope - and a - ret - -.unused - ld a, 2 - ld [wItemEffectSucceeded], a -.learned_move - scf - ret -; 2c8bf (b:48bf) - -Text_BootedTM: ; 0x2c8bf - ; Booted up a TM. - text_jump UnknownText_0x1c0373 - db "@" -; 0x2c8c4 - -Text_BootedHM: ; 0x2c8c4 - ; Booted up an HM. - text_jump UnknownText_0x1c0384 - db "@" -; 0x2c8c9 - -Text_ItContained: ; 0x2c8c9 - ; It contained @ . Teach @ to a #MON? - text_jump UnknownText_0x1c0396 - db "@" -; 0x2c8ce - -Text_TMHMNotCompatible: ; 0x2c8ce - ; is not compatible with @ . It can't learn @ . - text_jump UnknownText_0x1c03c2 - db "@" -; 0x2c8d3 - -TMHM_PocketLoop: ; 2c8d3 (b:48d3) - xor a - ld [hBGMapMode], a - call TMHM_DisplayPocketItems - ld a, 2 - ld [w2DMenuCursorInitY], a - ld a, 7 - ld [w2DMenuCursorInitX], a - ld a, 1 - ld [w2DMenuNumCols], a - ld a, 5 - sub d - inc a - cp 6 - jr nz, .okay - dec a -.okay - ld [w2DMenuNumRows], a - ld a, $c - ld [w2DMenuFlags1], a - xor a - ld [w2DMenuFlags2], a - ld a, $20 - ld [w2DMenuCursorOffsets], a - ld a, A_BUTTON | B_BUTTON | D_UP | D_DOWN | D_LEFT | D_RIGHT - ld [wMenuJoypadFilter], a - ld a, [wTMHMPocketCursor] - inc a - ld [wMenuCursorY], a - ld a, $1 - ld [wMenuCursorX], a - jr TMHM_ShowTMMoveDescription - -TMHM_JoypadLoop: ; 2c915 (b:4915) - call TMHM_DisplayPocketItems - call StaticMenuJoypad - ld b, a - ld a, [wMenuCursorY] - dec a - ld [wTMHMPocketCursor], a - xor a - ld [hBGMapMode], a - ld a, [w2DMenuFlags2] - bit 7, a - jp nz, TMHM_ScrollPocket - ld a, b - ld [wMenuJoypad], a - bit A_BUTTON_F, a - jp nz, TMHM_ChooseTMorHM - bit B_BUTTON_F, a - jp nz, TMHM_ExitPack - bit D_RIGHT_F, a - jp nz, TMHM_ExitPocket - bit D_LEFT_F, a - jp nz, TMHM_ExitPocket -TMHM_ShowTMMoveDescription: ; 2c946 (b:4946) - call TMHM_CheckHoveringOverCancel - jp nc, TMHM_ExitPocket - hlcoord 0, 12 - ld b, 4 - ld c, SCREEN_WIDTH - 2 - call TextBox - ld a, [wCurItem] - cp NUM_TMS + NUM_HMS + 1 - jr nc, TMHM_JoypadLoop - ld [wd265], a - predef GetTMHMMove - ld a, [wd265] - ld [wCurSpecies], a - hlcoord 1, 14 - call PrintMoveDesc - jp TMHM_JoypadLoop - -TMHM_ChooseTMorHM: ; 2c974 (b:4974) - call TMHM_PlaySFX_ReadText2 - call CountTMsHMs ; This stores the count to wd265. - ld a, [wMenuCursorY] - dec a - ld b, a - ld a, [wTMHMPocketScrollPosition] - add b - ld b, a - ld a, [wd265] - cp b - jr z, _TMHM_ExitPack ; our cursor was hovering over CANCEL -TMHM_CheckHoveringOverCancel: ; 2c98a (b:498a) - call TMHM_GetCurrentPocketPosition - ld a, [wMenuCursorY] - ld b, a -.loop - inc c - ld a, c - cp NUM_TMS + NUM_HMS + 1 - jr nc, .okay - ld a, [hli] - and a - jr z, .loop - dec b - jr nz, .loop - ld a, c -.okay - ld [wCurItem], a - cp -1 - ret - -TMHM_ExitPack: ; 2c9a5 (b:49a5) - call TMHM_PlaySFX_ReadText2 -_TMHM_ExitPack: ; 2c9a8 (b:49a8) - ld a, $2 - ld [wMenuJoypad], a - and a - ret - -TMHM_ExitPocket: ; 2c9af (b:49af) - and a - ret - -TMHM_ScrollPocket: ; 2c9b1 (b:49b1) - ld a, b - bit 7, a - jr nz, .skip - ld hl, wTMHMPocketScrollPosition - ld a, [hl] - and a - jp z, TMHM_JoypadLoop - dec [hl] - call TMHM_DisplayPocketItems - jp TMHM_ShowTMMoveDescription - -.skip - call TMHM_GetCurrentPocketPosition - ld b, 5 -.loop - inc c - ld a, c - cp NUM_TMS + NUM_HMS + 1 - jp nc, TMHM_JoypadLoop - ld a, [hli] - and a - jr z, .loop - dec b - jr nz, .loop - ld hl, wTMHMPocketScrollPosition - inc [hl] - call TMHM_DisplayPocketItems - jp TMHM_ShowTMMoveDescription - -TMHM_DisplayPocketItems: ; 2c9e2 (b:49e2) - ld a, [wBattleType] - cp BATTLETYPE_TUTORIAL - jp z, Tutorial_TMHMPocket - - hlcoord 5, 2 - lb bc, 10, 15 - ld a, " " - call ClearBox - call TMHM_GetCurrentPocketPosition - ld d, $5 -.loop2 - inc c - ld a, c - cp NUM_TMS + NUM_HMS + 1 - jr nc, .NotTMHM - ld a, [hli] - and a - jr z, .loop2 - ld b, a - ld a, c - ld [wd265], a - push hl - push de - push bc - call TMHMPocket_GetCurrentLineCoord - push hl - ld a, [wd265] - cp NUM_TMS + 1 - jr nc, .HM - ld de, wd265 - lb bc, PRINTNUM_LEADINGZEROS | 1, 2 - call PrintNum - jr .okay - -.HM: - push af - sub NUM_TMS - ld [wd265], a - ld [hl], "H" - inc hl - ld de, wd265 - lb bc, PRINTNUM_RIGHTALIGN | 1, 2 - call PrintNum - pop af - ld [wd265], a -.okay - predef GetTMHMMove - ld a, [wd265] - ld [wPutativeTMHMMove], a - call GetMoveName - pop hl - ld bc, 3 - add hl, bc - push hl - call PlaceString - pop hl - pop bc - ld a, c - push bc - cp NUM_TMS + 1 - jr nc, .hm2 - ld bc, SCREEN_WIDTH + 9 - add hl, bc - ld [hl], "×" - inc hl - ld a, "0" ; why are we doing this? - pop bc - push bc - ld a, b - ld [wd265], a - ld de, wd265 - lb bc, 1, 2 - call PrintNum -.hm2 - pop bc - pop de - pop hl - dec d - jr nz, .loop2 - jr .done - -.NotTMHM: - call TMHMPocket_GetCurrentLineCoord - inc hl - inc hl - inc hl - push de - ld de, TMHM_String_Cancel - call PlaceString - pop de -.done - ret - -TMHMPocket_GetCurrentLineCoord: ; 2ca86 (b:4a86) - hlcoord 5, 0 - ld bc, 2 * SCREEN_WIDTH - ld a, 6 - sub d - ld e, a - ; AddNTimes -.loop - add hl, bc - dec e - jr nz, .loop - ret -; 2ca95 (b:4a95) - -Unreferenced_Function2ca95: ; 2ca95 - pop hl - ld bc, 3 - add hl, bc - predef GetTMHMMove - ld a, [wd265] - ld [wPutativeTMHMMove], a - call GetMoveName - push hl - call PlaceString - pop hl - ret -; 2caae - -TMHM_String_Cancel: ; 2caae - db "CANCEL@" -; 2cab5 - -TMHM_GetCurrentPocketPosition: ; 2cab5 (b:4ab5) - ld hl, wTMsHMs - ld a, [wTMHMPocketScrollPosition] - ld b, a - inc b - ld c, 0 -.loop - inc c - ld a, [hli] - and a - jr z, .loop - dec b - jr nz, .loop - dec hl - dec c - ret - -Tutorial_TMHMPocket: ; 2caca (b:4aca) - hlcoord 9, 3 - push de - ld de, TMHM_String_Cancel - call PlaceString - pop de - ret - -TMHM_PlaySFX_ReadText2: ; 2cad6 (b:4ad6) - push de - ld de, SFX_READ_TEXT_2 - call PlaySFX - pop de - ret -; 2cadf (b:4adf) - -Unreferenced_Function2cadf: ; 2cadf - call ConvertCurItemIntoCurTMHM - call .CheckHaveRoomForTMHM - ld hl, .NoRoomText - jr nc, .print - ld hl, .ReceivedText -.print - jp PrintText -; 2caf0 - -.NoRoomText: ; 0x2caf0 - ; You have no room for any more @ S. - text_jump UnknownText_0x1c03fa - db "@" -; 0x2caf5 - -.ReceivedText: ; 0x2caf5 - ; You received @ ! - text_jump UnknownText_0x1c0421 - db "@" -; 0x2cafa - -.CheckHaveRoomForTMHM: ; 2cafa - ld a, [wd265] - dec a - ld hl, wTMsHMs - ld b, 0 - ld c, a - add hl, bc - ld a, [hl] - inc a - cp NUM_TMS * 2 - ret nc - ld [hl], a - ret -; 2cb0c - -ConsumeTM: ; 2cb0c (b:4b0c) - call ConvertCurItemIntoCurTMHM - ld a, [wd265] - dec a - ld hl, wTMsHMs - ld b, 0 - ld c, a - add hl, bc - ld a, [hl] - and a - ret z - dec a - ld [hl], a - ret nz - ld a, [wTMHMPocketScrollPosition] - and a - ret z - dec a - ld [wTMHMPocketScrollPosition], a - ret - -CountTMsHMs: ; 2cb2a (b:4b2a) - ld b, 0 - ld c, NUM_TMS + NUM_HMS - ld hl, wTMsHMs -.loop - ld a, [hli] - and a - jr z, .skip - inc b -.skip - dec c - jr nz, .loop - ld a, b - ld [wd265], a - ret - -PrintMoveDesc: ; 2cb3e - push hl - ld hl, MoveDescriptions - ld a, [wCurSpecies] - dec a - ld c, a - ld b, 0 - add hl, bc - add hl, bc - ld a, [hli] - ld e, a - ld d, [hl] - pop hl - jp PlaceString -; 2cb52 diff --git a/engine/predef.asm b/engine/routines/predef.asm similarity index 100% rename from engine/predef.asm rename to engine/routines/predef.asm diff --git a/engine/gfx/map_palettes.asm b/engine/tilesets/map_palettes.asm similarity index 100% rename from engine/gfx/map_palettes.asm rename to engine/tilesets/map_palettes.asm diff --git a/engine/gfx/mapgroup_roofs.asm b/engine/tilesets/mapgroup_roofs.asm similarity index 100% rename from engine/gfx/mapgroup_roofs.asm rename to engine/tilesets/mapgroup_roofs.asm diff --git a/engine/gfx/tileset_anims.asm b/engine/tilesets/tileset_anims.asm similarity index 100% rename from engine/gfx/tileset_anims.asm rename to engine/tilesets/tileset_anims.asm diff --git a/engine/gfx/tileset_palettes.asm b/engine/tilesets/tileset_palettes.asm similarity index 100% rename from engine/gfx/tileset_palettes.asm rename to engine/tilesets/tileset_palettes.asm diff --git a/engine/gfx/timeofdaypals.asm b/engine/tilesets/timeofdaypals.asm similarity index 100% rename from engine/gfx/timeofdaypals.asm rename to engine/tilesets/timeofdaypals.asm diff --git a/main.asm b/main.asm index 7c5610e5f..4980beee4 100644 --- a/main.asm +++ b/main.asm @@ -3,13 +3,13 @@ INCLUDE "constants.asm" SECTION "bank1", ROMX -INCLUDE "engine/routines/placewaitingtext.asm" -INCLUDE "engine/routines/loadpushoam.asm" +INCLUDE "engine/link/placewaitingtext.asm" +INCLUDE "engine/gfx/loadpushoam.asm" INCLUDE "engine/overworld/map_objects.asm" INCLUDE "engine/menus/intro_menu.asm" INCLUDE "engine/overworld/init_map.asm" INCLUDE "engine/pokemon/learn.asm" -INCLUDE "engine/routines/checknickerrors.asm" +INCLUDE "engine/pokemon/checknickerrors.asm" INCLUDE "engine/routines/math.asm" INCLUDE "data/items/attributes.asm" INCLUDE "engine/overworld/npc_movement.asm" @@ -21,13 +21,13 @@ SECTION "bank2", ROMX INCLUDE "engine/overworld/player_object.asm" INCLUDE "engine/routines/sine.asm" -INCLUDE "engine/predef.asm" +INCLUDE "engine/routines/predef.asm" INCLUDE "engine/gfx/color.asm" SECTION "bank3", ROMX -INCLUDE "engine/routines/checktime.asm" +INCLUDE "engine/events/checktime.asm" INCLUDE "engine/events/specials.asm" INCLUDE "engine/routines/printnum.asm" INCLUDE "engine/pokemon/health.asm" @@ -48,7 +48,7 @@ SECTION "bank4", ROMX INCLUDE "engine/items/pack.asm" INCLUDE "engine/overworld/time.asm" -INCLUDE "engine/items/tmhm.asm" +INCLUDE "engine/items/tmhm2.asm" INCLUDE "engine/menus/naming_screen.asm" INCLUDE "engine/events/misc_scripts.asm" INCLUDE "engine/events/heal_machine_anim.asm" @@ -64,7 +64,7 @@ INCLUDE "engine/events/std_collision.asm" INCLUDE "engine/events/bug_contest/judging.asm" INCLUDE "engine/events/pokerus/apply_pokerus_tick.asm" INCLUDE "engine/events/bug_contest/contest_2.asm" -INCLUDE "engine/routines/correcterrorsinplayerparty.asm" +INCLUDE "engine/pokemon/correcterrorsinplayerparty.asm" INCLUDE "engine/routines/getsquareroot.asm" @@ -73,12 +73,12 @@ SECTION "bank5", ROMX INCLUDE "engine/rtc/rtc.asm" INCLUDE "engine/overworld/overworld.asm" INCLUDE "engine/overworld/tile_events.asm" -INCLUDE "engine/save.asm" +INCLUDE "engine/menus/save.asm" INCLUDE "engine/overworld/spawn_points.asm" INCLUDE "engine/overworld/map_setup.asm" INCLUDE "engine/events/pokecenter_pc.asm" INCLUDE "engine/items/mart.asm" -INCLUDE "engine/money.asm" +INCLUDE "engine/events/money.asm" INCLUDE "data/items/marts.asm" INCLUDE "engine/events/mom.asm" INCLUDE "engine/events/daycare.asm" @@ -90,7 +90,7 @@ INCLUDE "gfx/tilesets.asm" SECTION "Roofs", ROMX -INCLUDE "engine/gfx/mapgroup_roofs.asm" +INCLUDE "engine/tilesets/mapgroup_roofs.asm" SECTION "Clock Reset", ROMX @@ -144,7 +144,7 @@ INCLUDE "data/trainers/class_names.asm" INCLUDE "engine/battle/ai/redundant.asm" INCLUDE "engine/events/move_deleter.asm" INCLUDE "engine/link/mystery_gift_2.asm" -INCLUDE "engine/pokemon/tmhm.asm" +INCLUDE "engine/items/tmhm.asm" INCLUDE "data/moves/descriptions.asm" INCLUDE "engine/events/pokerus/pokerus.asm" INCLUDE "engine/battle/start_battle.asm" @@ -205,15 +205,15 @@ INCLUDE "engine/events/buena_menu.asm" SECTION "bank13", ROMX -INCLUDE "engine/gfx/map_palettes.asm" +INCLUDE "engine/tilesets/map_palettes.asm" INCLUDE "gfx/tileset_palette_maps.asm" INCLUDE "data/collision_permissions.asm" INCLUDE "engine/routines/emptyallsrambanks.asm" -INCLUDE "engine/routines/savemenu_copytilemapatonce.asm" -INCLUDE "engine/routines/checksave.asm" +INCLUDE "engine/menus/savemenu_copytilemapatonce.asm" +INCLUDE "engine/events/checksave.asm" INCLUDE "data/maps/scenes.asm" INCLUDE "engine/overworld/loadmappart.asm" -INCLUDE "engine/routines/phonering_copytilemapatonce.asm" +INCLUDE "engine/phone/phonering_copytilemapatonce.asm" Shrink1Pic: ; 4d249 INCBIN "gfx/new_game/shrink1.2bpp.lz" @@ -232,13 +232,13 @@ INCLUDE "engine/pokemon/caught_data.asm" INCLUDE "engine/pokemon/search2.asm" INCLUDE "engine/pokemon/stats_screen.asm" INCLUDE "engine/events/catch_tutorial.asm" -INCLUDE "engine/gfx/evolution_animation.asm" -INCLUDE "engine/title/init_hof_credits.asm" +INCLUDE "engine/movie/evolution_animation.asm" +INCLUDE "engine/movie/init_hof_credits.asm" INCLUDE "engine/events/battle_tower/get_trainer_class.asm" INCLUDE "engine/battle/sliding_intro.asm" INCLUDE "mobile/print_opp_message.asm" INCLUDE "engine/battle/checkbattlescene.asm" -INCLUDE "engine/gfx/gbc_only.asm" +INCLUDE "engine/movie/gbc_only.asm" INCLUDE "engine/events/poke_seer.asm" @@ -277,10 +277,10 @@ INCLUDE "data/phone/text/extra.asm" SECTION "bank20", ROMX INCLUDE "engine/overworld/player_movement.asm" -INCLUDE "engine/engine_flags.asm" +INCLUDE "engine/events/engine_flags.asm" INCLUDE "engine/overworld/variables.asm" INCLUDE "data/text/battle.asm" -INCLUDE "engine/debug.asm" +INCLUDE "engine/menus/debug.asm" SECTION "bank21", ROMX @@ -304,7 +304,7 @@ INCLUDE "mobile/mobile_22_2.asm" SECTION "bank23", ROMX -INCLUDE "engine/gfx/timeofdaypals.asm" +INCLUDE "engine/tilesets/timeofdaypals.asm" INCLUDE "engine/battle/battle_transition.asm" INCLUDE "engine/events/field_moves.asm" INCLUDE "engine/events/magnet_train.asm" @@ -442,7 +442,7 @@ CopyrightGFX:: ; e4000 INCBIN "gfx/splash/copyright.2bpp" INCLUDE "engine/menus/options_menu.asm" -INCLUDE "engine/title/crystal_intro.asm" +INCLUDE "engine/movie/crystal_intro.asm" SECTION "bank3E", ROMX @@ -450,7 +450,7 @@ SECTION "bank3E", ROMX INCLUDE "engine/gfx/load_font.asm" INCLUDE "engine/link/time_capsule.asm" INCLUDE "engine/events/name_rater.asm" -INCLUDE "engine/routines/playslowcry.asm" +INCLUDE "engine/events/playslowcry.asm" INCLUDE "engine/pokedex/newpokedexentry.asm" INCLUDE "engine/link/time_capsule_2.asm" INCLUDE "engine/pokedex/unown_dex.asm" @@ -461,7 +461,7 @@ INCLUDE "engine/battle/misc.asm" SECTION "bank3F", ROMX -INCLUDE "engine/gfx/tileset_anims.asm" +INCLUDE "engine/tilesets/tileset_anims.asm" INCLUDE "engine/events/npc_trade.asm" INCLUDE "engine/events/mom_phone.asm" @@ -471,7 +471,7 @@ INCLUDE "mobile/mobile_40.asm" SECTION "bank41", ROMX -INCLUDE "engine/dma_transfer.asm" +INCLUDE "engine/gfx/dma_transfer.asm" INCLUDE "gfx/emotes.asm" INCLUDE "engine/overworld/warp_connection.asm" INCLUDE "engine/link/mystery_gift.asm" @@ -493,8 +493,8 @@ INCBIN "gfx/intro/logo.2bpp.lz" SECTION "Title", ROMX -INCLUDE "engine/title/unused_title.asm" -INCLUDE "engine/title/title.asm" +INCLUDE "engine/movie/unused_title.asm" +INCLUDE "engine/movie/title.asm" INCLUDE "mobile/mobile_45.asm" @@ -586,7 +586,7 @@ INCLUDE "engine/rtc/printhoursmins.asm" INCLUDE "engine/events/diploma.asm" INCLUDE "engine/pokedex/pokedex_3.asm" INCLUDE "engine/events/catch_tutorial_input.asm" -INCLUDE "engine/routines/townmap_convertlinebreakcharacters.asm" +INCLUDE "engine/pokegear/townmap_convertlinebreakcharacters.asm" PokegearGFX: ; 1de2e4 INCBIN "gfx/pokegear/pokegear.2bpp.lz"