summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/bugs_and_glitches.md66
-rw-r--r--docs/event_commands.md26
-rw-r--r--docs/map_event_scripts.md (renamed from docs/map_scripts.md)83
-rw-r--r--docs/menu.md40
4 files changed, 123 insertions, 92 deletions
diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md
index 5abf9d08a..d79f386a8 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
@@ -1075,7 +1081,7 @@ In [home/map.asm](/home/map.asm):
## `Function6ec1` does not correctly limit object movement
-This bug is why the Lapras in Union Cave, which uses `SPRITEMOVEDATA_LAPRAS`, is not restricted by its `1, 1` movement radius.
+This bug is why the Lapras in Union Cave, which uses `SPRITEMOVEDATA_SWIM_WANDER`, is not restricted by its `1, 1` movement radius.
In [engine/npc_movement.asm](/engine/npc_movement.asm):
@@ -1104,7 +1110,7 @@ In [engine/search.asm](/engine/search.asm):
ld hl, PlayerName
-rept NAME_LENGTH_JAPANESE +- 2 ; should be PLAYER_NAME_LENGTH +- 2
+rept NAME_LENGTH_JAPANESE + -2 ; should be PLAYER_NAME_LENGTH + -2
ld a, [de]
cp [hl]
jr nz, .notfound
@@ -1126,7 +1132,7 @@ endr
ret
```
-**Fix:** Change `rept NAME_LENGTH_JAPANESE +- 2` to `rept PLAYER_NAME_LENGTH +- 2`.
+**Fix:** Change `rept NAME_LENGTH_JAPANESE + -2` to `rept PLAYER_NAME_LENGTH + -2`.
## Catching a Transformed Pokémon always catches a Ditto
@@ -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..fdf611cbf 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>
@@ -15,17 +17,17 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/s
## `$05`: <code>ptjump <i>script</i></code>
-## `$06`: <code>if_equal <i>byte</i>, <i>script</i></code>
+## `$06`: <code>ifequal <i>byte</i>, <i>script</i></code>
-## `$07`: <code>if_not_equal <i>byte</i>, <i>script</i></code>
+## `$07`: <code>ifnotequal <i>byte</i>, <i>script</i></code>
## `$08`: <code>iffalse <i>script</i></code>
## `$09`: <code>iftrue <i>script</i></code>
-## `$0A`: <code>if_greater_than <i>byte</i>, <i>script</i></code>
+## `$0A`: <code>ifgreater <i>byte</i>, <i>script</i></code>
-## `$0B`: <code>if_less_than <i>byte</i>, <i>script</i></code>
+## `$0B`: <code>ifless <i>byte</i>, <i>script</i></code>
## `$0C`: <code>jumpstd <i>std_script</i></code>
@@ -91,10 +93,6 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/s
## `$2B`: <code>checktime <i>time</i></code>
-- **`checkmorn`:** `checktime MORN`
-- **`checkday`:** `checktime DAY`
-- **`checknite`:** `checktime NITE`
-
## `$2C`: <code>checkpoke <i>mon_id</i></code>
## `$2D`: <code>givepoke <i>mon_id</i>, <i>level</i>[, <i>item</i>=0[, <i>trainer</i>=0, <i>ot_name</i>, <i>nickname</i>]]</code>
@@ -165,7 +163,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`
@@ -211,9 +209,9 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/s
## `$65`: `scripttalkafter`
-## `$66`: `end_if_just_battled`
+## `$66`: `endifjustbattled`
-## `$67`: `check_just_battled`
+## `$67`: `checkjustbattled`
## `$68`: <code>setlasttalked <i>object_id</i></code>
@@ -243,7 +241,7 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/s
## `$75`: <code>showemote <i>emote_id</i>, <i>object_id</i>, <i>length</i></code>
-## `$76`: <code>spriteface <i>object_id</i>, <i>facing</i></code>
+## `$76`: <code>objectface <i>object_id</i>, <i>facing</i></code>
## `$77`: <code>follownotexact <i>object2</i>, <i>object1</i></code>
@@ -301,7 +299,7 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/s
## `$92`: <code>reloadandreturn <i>which_method</i></code>
-## `$93`: `end_all`
+## `$93`: `endall`
## `$94`: <code>pokemart <i>dialog_id</i>, <i>mart_id</i></code>
@@ -345,4 +343,4 @@ Defined in [macros/scripts/events.asm](/macros/scripts/events.asm) and [engine/s
## `$A8`: <code>wait <i>duration</i></code>
-## `$A9`: `check_save`
+## `$A9`: `checksave`
diff --git a/docs/map_scripts.md b/docs/map_event_scripts.md
index 2302257e7..a77f74503 100644
--- a/docs/map_scripts.md
+++ b/docs/map_event_scripts.md
@@ -1,30 +1,57 @@
-# Map Scripts
+# Map Event Scripts
-## <code>const_value set 2</code>
+## Contents
+
+- [Object constants](#object-constants)
+- [Map scripts](#map-scripts)
+ - [Scene scripts](#scene-scripts)
+ - [Callbacks](#callbacks)
+ - [Callback types](#callback-types)
+- [Event scripts](#event-scripts)
+- [Text](#text)
+- [Movement data](#movement-data)
+- [Map events](#map-events)
+ - [Warp events](#warp-events)
+ - [Coord events](#coord-events)
+ - [BG events](#bg-events)
+ - [BG event types](#bg-event-types)
+ - [Object events](#object-events)
+ - [Movement types](#movement-types)
+ - [Object types](#object-types)
+
+
+## Object constants
<pre>
+ const_def 2 ; object constants
const <i>MAPNAME</i>_<i>OBJECTNAME</i>
</pre>
-## <code>MapName_MapScripts:</code>
+## Map scripts
+<pre>
+<i>MapName</i>_MapScripts:
+</pre>
-### <code>.SceneScripts: db <i>N</i></code>
+
+### Scene scripts
<pre>
+ db <i>N</i> ; scene scripts
scene_script <i>script</i>
</pre>
-### <code>.MapCallbacks: db <i>N</i></code>
+### Callbacks
<pre>
+ db <i>N</i> ; callbacks
callback <i>type</i>, <i>script</i>
</pre>
-Callback types:
+#### Callback types
- `MAPCALLBACK_NEWMAP`
@@ -67,35 +94,38 @@ Callback types:
[Movement commands](movement_commands.md)
-## <code>MapName_MapEvents:</code>
+## Map events
-```asm
- ; filler
- db 0, 0
-```
+<pre>
+<i>MapName</i>_MapEvents:
+ db 0, 0 ; filler
+</pre>
-### <code>.Warps: db <i>N</i></code>
+### Warp events
<pre>
- warp_def <i>x</i>, <i>y</i>, <i>warp_id</i>, <i>map</i>
+ db <i>N</i> ; warp events
+ warp_event <i>x</i>, <i>y</i>, <i>map</i>, <i>warp_id</i>
</pre>
-### <code>.CoordEvents: db <i>N</i></code>
+### Coord events
<pre>
+ db <i>N</i> ; coord events
coord_event <i>x</i>, <i>y</i>, <i>scene_id</i>, <i>script</i>
</pre>
-### <code>.BGEvents: db <i>N</i></code>
+### BG events
<pre>
+ db <i>N</i> ; bg events
bg_event <i>x</i>, <i>y</i>, <i>type</i>, <i>script</i>
</pre>
-BG event types:
+#### BG event types
- `BGEVENT_READ`
@@ -110,20 +140,21 @@ 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>
+### Object events
<pre>
+ db <i>N</i> ; object events
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>
</pre>
-Movement types:
+#### Movement types
-- `SPRITEMOVEDATA_ITEM_TREE`
+- `SPRITEMOVEDATA_STILL`
- `SPRITEMOVEDATA_WANDER`
@@ -137,7 +168,7 @@ Movement types:
- `SPRITEMOVEDATA_SPINRANDOM_FAST`
-- `SPRITEMOVEDATA_SNORLAX`
+- `SPRITEMOVEDATA_BIGDOLLSYM`
- `SPRITEMOVEDATA_POKEMON`
@@ -151,22 +182,24 @@ Movement types:
- `SPRITEMOVEDATA_SPINCLOCKWISE`
+- `SPRITEMOVEDATA_BIGDOLLASYM`
+
- `SPRITEMOVEDATA_BIGDOLL`
-- `SPRITEMOVEDATA_LAPRAS`
+- `SPRITEMOVEDATA_SWIM_WANDER`
-Object types:
+#### Object types
- `OBJECTTYPE_SCRIPT`
- `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