diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/bugs_and_glitches.md | 60 | ||||
-rw-r--r-- | docs/event_commands.md | 4 | ||||
-rw-r--r-- | docs/map_scripts.md | 23 | ||||
-rw-r--r-- | docs/menu.md | 40 |
4 files changed, 64 insertions, 63 deletions
diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 5abf9d08a..3c5728b78 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -51,7 +51,7 @@ These are known bugs and glitches in the original Pokémon Crystal game: code th - [`LoadSpriteGFX` does not limit the capacity of `UsedSprites`](#loadspritegfx-does-not-limit-the-capacity-of-usedsprites) - [`ChooseWildEncounter` doesn't really validate the wild Pokémon species](#choosewildencounter-doesnt-really-validate-the-wild-pokémon-species) - [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution) -- [`Special_CheckBugContestContestantFlag` can read beyond its data table](#special_checkbugcontestcontestantflag-can-read-beyond-its-data-table) +- [`CheckBugContestContestantFlag` can read beyond its data table](#checkbugcontestcontestantflag-can-read-beyond-its-data-table) - [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1) @@ -155,7 +155,7 @@ This is a bug with `DittoMetalPowder` in [engine/battle/effect_commands.asm](/en ([Video](https://www.youtube.com/watch?v=zuCLMikWo4Y)) -This is a bug with `BattleCommand_BellyDrum` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm): +This is a bug with `BattleCommand_BellyDrum` in [engine/battle/move_effects/belly_drum.asm](/engine/battle/move_effects/belly_drum.asm): ```asm BattleCommand_BellyDrum: ; 37c1a @@ -307,7 +307,7 @@ CheckHiddenOpponent: ; 37daa ([Video](https://www.youtube.com/watch?v=202-iAsrIa8)) -This is a bug with `BattleCommand_BeatUp` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm): +This is a bug with `BattleCommand_BeatUp` in [engine/battle/move_effects/beat_up.asm](/engine/battle/move_effects/beat_up.asm): ```asm .got_mon @@ -346,7 +346,7 @@ This is a bug with `BattleCommand_BeatUp` in [engine/battle/effect_commands.asm] This bug existed for all battles in Gold and Silver, and was only fixed for single-player battles in Crystal to preserve link compatibility. -This is a bug with `BattleCommand_Present` in [engine/battle/effect_commands/present.asm](/engine/battle/effect_commands/present.asm): +This is a bug with `BattleCommand_Present` in [engine/battle/move_effects/present.asm](/engine/battle/move_effects/present.asm): ```asm BattleCommand_Present: ; 37874 @@ -712,12 +712,12 @@ This is a bug with `ItemAttributes` in [items/attributes.asm](/items/attributes. ## Daisy's grooming doesn't always increase happiness -This is a bug with `MassageOrHaircut` in [engine/events/special.asm](/engine/events/special.asm): +This is a bug with `HaircutOrGrooming` in [engine/events/special.asm](/engine/events/special.asm): ```asm ; Bug: Subtracting $ff from $ff fails to set c. ; This can result in overflow into the next data array. -; In the case of getting a massage from Daisy, we bleed +; In the case of getting a grooming from Daisy, we bleed ; into CopyPokemonName_Buffer1_Buffer3, which passes ; $d0 to ChangeHappiness and returns $73 to the script. ; The end result is that there is a 0.4% chance your @@ -740,8 +740,7 @@ This is a bug with `MassageOrHaircut` in [engine/events/special.asm](/engine/eve ... -Data_DaisyMassage: ; 746b - db $ff, 2, HAPPINESS_MASSAGE ; 99.6% chance +INCLUDE "data/events/happiness_chances.asm" CopyPokemonName_Buffer1_Buffer3: ; 746e ld hl, StringBuffer1 @@ -750,12 +749,19 @@ CopyPokemonName_Buffer1_Buffer3: ; 746e jp CopyBytes ``` +In [data/events/happiness_chances.asm](/data/events/happiness_chances.asm): + +```asm +HappinessData_DaisysGrooming: ; 746b + db $ff, 2, HAPPINESS_GROOMING ; 99.6% chance +``` + **Fix:** ```asm -Data_DaisyMassage: ; 746b - db $80, 2, HAPPINESS_MASSAGE ; 50% chance - db $ff, 2, HAPPINESS_MASSAGE ; 50% chance +HappinessData_DaisysGrooming: ; 746b + db $80, 2, HAPPINESS_GROOMING ; 50% chance + db $ff, 2, HAPPINESS_GROOMING ; 50% chance ``` @@ -863,10 +869,10 @@ StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365) jr nc, .okay set 0, e .okay - ld a, [wPermission] + ld a, [wEnvironment] cp CAVE jr z, .okay2 - cp PERM_5 + cp ENVIRONMENT_5 jr z, .okay2 cp DUNGEON jr z, .okay2 @@ -1268,11 +1274,11 @@ This is a bug with `PlacePartyMonEvoStoneCompatibility.DetermineCompatibility` i ld l, a ld de, StringBuffer1 ld a, BANK(EvosAttacks) - ld bc, $a + ld bc, 10 call FarCopyBytes ``` -**Fix:** Change `ld bc, $a` to `ld bc, $10` to support up to five Stone entries. +**Fix:** Change `ld bc, 10` to `ld bc, StringBuffer2 - StringBuffer1` to support up to six Stone entries. ## `ScriptCall` can overflow `wScriptStack` and crash @@ -1312,6 +1318,8 @@ ScriptCall: ret ``` +*To do:* Fix this bug. + ## `LoadSpriteGFX` does not limit the capacity of `UsedSprites` @@ -1417,15 +1425,16 @@ In [engine/events.asm](/engine/events.asm): **Fix:** Uncomment `pop bc`. -## `Special_CheckBugContestContestantFlag` can read beyond its data table +## `CheckBugContestContestantFlag` can read beyond its data table In [engine/events/bug_contest/contest_2.asm](/engine/events/bug_contest/contest_2.asm): ```asm -Special_CheckBugContestContestantFlag: ; 139ed +CheckBugContestContestantFlag: ; 139ed ; Checks the flag of the Bug Catching Contestant whose index is loaded in a. -; Bug: If a >= 10 when this is called, it will read beyond the table. +; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, +; it will read beyond the table. ld hl, BugCatchingContestantEventFlagTable ld e, a @@ -1440,20 +1449,11 @@ Special_CheckBugContestContestantFlag: ; 139ed ret ; 139fe -BugCatchingContestantEventFlagTable: ; 139fe - dw EVENT_BUG_CATCHING_CONTESTANT_1A - dw EVENT_BUG_CATCHING_CONTESTANT_2A - dw EVENT_BUG_CATCHING_CONTESTANT_3A - dw EVENT_BUG_CATCHING_CONTESTANT_4A - dw EVENT_BUG_CATCHING_CONTESTANT_5A - dw EVENT_BUG_CATCHING_CONTESTANT_6A - dw EVENT_BUG_CATCHING_CONTESTANT_7A - dw EVENT_BUG_CATCHING_CONTESTANT_8A - dw EVENT_BUG_CATCHING_CONTESTANT_9A - dw EVENT_BUG_CATCHING_CONTESTANT_10A -; 13a12 +INCLUDE "data/events/bug_contest_flags.asm" ``` +However, `a < NUM_BUG_CONTESTANTS` should always be true, so in practice this is not a problem. + ## `ClearWRAM` only clears WRAM bank 1 diff --git a/docs/event_commands.md b/docs/event_commands.md index 91486ad06..8c6d96481 100644 --- a/docs/event_commands.md +++ b/docs/event_commands.md @@ -2,6 +2,8 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/scripting.asm:ScriptCommandTable](/engine/scripting.asm). +Until this document is filled out, the [G/S Scripting Compendium](https://hax.iimarckus.org/files/scriptingcodes_eng.htm) has descriptions for most of these commands. It was written for G/S binary hacking and not Crystal assembly hacking, so it's not 100% accurate for pokecrystal. + ## `$00`: <code>scall <i>script</i></code> @@ -165,7 +167,7 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/s ## `$4E`: `yesorno` -## `$4F`: <code>loadmenudata <i>data_pointer</i></code> +## `$4F`: <code>loadmenuheader <i>menu_header</i></code> ## `$50`: `closewindow` diff --git a/docs/map_scripts.md b/docs/map_scripts.md index 2302257e7..fa864ac37 100644 --- a/docs/map_scripts.md +++ b/docs/map_scripts.md @@ -11,14 +11,14 @@ ## <code>MapName_MapScripts:</code> -### <code>.SceneScripts: db <i>N</i></code> +### <code>db <i>N</i> ; scene scripts</code> <pre> scene_script <i>script</i> </pre> -### <code>.MapCallbacks: db <i>N</i></code> +### <code>db <i>N</i> ; callbacks</code> <pre> callback <i>type</i>, <i>script</i> @@ -70,26 +70,25 @@ Callback types: ## <code>MapName_MapEvents:</code> ```asm - ; filler - db 0, 0 + db 0, 0 ; filler ``` -### <code>.Warps: db <i>N</i></code> +### <code>db <i>N</i> ; warp events</code> <pre> - warp_def <i>x</i>, <i>y</i>, <i>warp_id</i>, <i>map</i> + warp_event <i>x</i>, <i>y</i>, <i>warp_id</i>, <i>map</i> </pre> -### <code>.CoordEvents: db <i>N</i></code> +### <code>db <i>N</i> ; coord events</code> <pre> coord_event <i>x</i>, <i>y</i>, <i>scene_id</i>, <i>script</i> </pre> -### <code>.BGEvents: db <i>N</i></code> +### <code>db <i>N</i> ; bg events</code> <pre> bg_event <i>x</i>, <i>y</i>, <i>type</i>, <i>script</i> @@ -110,12 +109,12 @@ BG event types: - `BGEVENT_ITEM` <pre> - hiddenitem <i>event_flag</i>, <i>item_id</i> + hiddenitem <i>item_id</i>, <i>event_flag</i> </pre> - `BGEVENT_COPY` -### <code>.ObjectEvents: db <i>N</i></code> +### <code>db <i>N</i> ; object events</code> <pre> object_event <i>x</i>, <i>y</i>, <i>sprite</i>, <i>movement</i>, <i>rx</i>, <i>ry</i>, <i>h1</i>, <i>h2</i>, <i>palette</i>, <i>type</i>, <i>range</i>, <i>script</i>, <i>event_flag</i> @@ -162,11 +161,11 @@ Object types: - `OBJECTTYPE_ITEMBALL` <pre> - itemball <i>item_id</i> + itemball <i>item_id</i>[, <i>quantity</i>=1] </pre> - `OBJECTTYPE_TRAINER` <pre> - trainer <i>event_flag</i>, <i>group_id</i>, <i>trainer_id</i>, <i>seen_text</i>, <i>beaten_text</i>, <i>loss_text</i>, <i>script</i> + trainer <i>group_id</i>, <i>trainer_id</i>, <i>event_flag</i>, <i>seen_text</i>, <i>beaten_text</i>, <i>loss_text</i>, <i>script</i> </pre> diff --git a/docs/menu.md b/docs/menu.md index 71186a905..80d64ada1 100644 --- a/docs/menu.md +++ b/docs/menu.md @@ -19,13 +19,13 @@ This is the only menu that does scrolling. It doesn't draw any `TextBox` around Structure: ```asm -.MenuDataHeader: +.MenuHeader: db MENU_BACKUP_TILES ; flags menu_coords 2, 4, SCREEN_WIDTH - 1, 13 - dw .MenuData2 + dw .MenuData db 1 ; default option -.MenuData2: +.MenuData: db 0 ; flags db 5, 0 ; rows, columns db 1 ; horizontal spacing @@ -35,7 +35,7 @@ Structure: dba Function3 ``` -`wMenuData2Flags`: +`wMenuDataFlags`: ``` 7: Select is functional @@ -48,9 +48,9 @@ Structure: 0: Call Function1 to display the cancel entry ``` -If the columns entry in `MenuDataHeader2` of a scrolling menu is 0, `Function2` isn't called either. It doesn't affect the position of the arrows. +If the columns entry in `MenuData` of a scrolling menu is 0, `Function2` isn't called either. It doesn't affect the position of the arrows. -Call state for functions in `MenuDataHeader2` of `ScrollingMenu`: +Call state for functions in `MenuData` of `ScrollingMenu`: ``` All of them: @@ -68,7 +68,7 @@ Function3: Called to display anything else, whenever the cursor is moved. There is no register of importance that should be preserved in any of these functions. -The `; horizontal spacing` item in each `MenuData2` is a misnomer. It changes how the `Items` struct looks. +The `; horizontal spacing` item in each `MenuData` is a misnomer. It changes how the `Items` struct looks. If it's 1: @@ -99,14 +99,14 @@ This, like is implied by the name, is a 2-dimensional menu, where you can move y Structure: ```asm -.MenuDataHeader: +.MenuHeader: db MENU_BACKUP_TILES ; flags db 12, 08 ; start coords db 17, 19 ; end coords - dw .MenuData2 + dw .MenuData db 1 ; default option -.MenuData2: +.MenuData: db STATICMENU_CURSOR ; flags dn 2, 2 ; rows, columns db 6 ; spacing @@ -114,7 +114,7 @@ Structure: dba Function ``` -`wMenuData2Flags`: +`wMenuDataFlags`: ``` 7: Leave one tile of spacing between the left textbox border and the text, enabling the cursor. @@ -141,13 +141,13 @@ These are like the regular `VerticalMenu`, except they allow for creating slight Structure: ``` -.MenuDataHeader: +.MenuHeader: db MENU_BACKUP_TILES ; flags menu_coords 0, 0, 10, 7 - dw .MenuData2 + dw .MenuData db 1 ; default option -.MenuData2: +.MenuData: db STATICMENU_CURSOR | STATICMENU_DISABLE_B ; flags db 0 ; items dw Items @@ -155,7 +155,7 @@ Structure: dw StringPointers ``` -`wMenuData2Flags`: +`wMenuDataFlags`: ``` 7: Unused @@ -219,20 +219,20 @@ This is the simplest menu. Like, the most boring. Nothing special. Just normal. Structure: ```asm -.MenuDataHeader: +.MenuHeader: db MENU_SPRITE_ANIMS | MENU_BACKUP_TILES ; flags menu_coords 12, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw .MenuData2 + dw .MenuData db 1 ; default option -.MenuData2: +.MenuData: db STATICMENU_CURSOR ; flags db 2 ; # items db "GIVE@" db "TAKE@" ``` -`wMenuData2Flags`: +`wMenuDataFlags`: ``` 7: Leave one tile of spacing between the left textbox border and the text @@ -259,7 +259,7 @@ This is used in the menu for selecting the character's name. ## Misc/Generic -`MenuDataHeader` flags (`wMenuFlags`): +`MenuHeader` flags (`wMenuFlags`): ``` 7: Save a backup of the tiles |