Skip to content

Commit

Permalink
Added all commands up to 70
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltContainer committed Oct 22, 2023
1 parent f614429 commit 5be3802
Show file tree
Hide file tree
Showing 36 changed files with 1,100 additions and 5 deletions.
4 changes: 4 additions & 0 deletions rom-hacking/intro.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
slug: /
---

# ROM Hacking

Learn how to make your own modifications to the Pokemon BDSP ROM.
27 changes: 27 additions & 0 deletions rom-hacking/scripting/commands/add-wk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# (58) _ADD_WK

## Effect

Increments a work by a given value.

## Syntax

```c
_ADD_WK(work, value)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **work** | The work that gets incremented | Work | Required |
| **value** | The value to add | Work, Float | Required |
## Example
```c
_LDVAL(@LOCALWORK1, 3)
_ADD_WK(@LOCALWORK1, 4)
```

The above script will set the work variable @LOCALWORK1 to 3.

Then, @LOCALWORK1's value is incremented by 4, making it 7.
25 changes: 25 additions & 0 deletions rom-hacking/scripting/commands/arrive-flag-set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# (42) _ARRIVE_FLAG_SET

## Effect

Sets the given system flag to true.

Also updates the player's badge count.

## Syntax

```c
_FLAG_SET(sysflag)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **sysflag** | The system flag to set | SysFlag | Required |
## Example
```c
_ARRIVE_FLAG_SET($SYS_FLAG_PAIR)
```

The above script will set the $SYS_FLAG_PAIR system flag.
38 changes: 38 additions & 0 deletions rom-hacking/scripting/commands/call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# (28) _CALL

## Synonyms

- _CHG_COMMON_SCR

## Effect

Calls a script.

The position of the call is saved. Execution returns to this command once a _RET is executed.

## Syntax

```c
_CALL(label)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **label** | The label to call | String | Required |
## Example
```c
_CALL('ev_dummy')
_SE_PLAY('S_BOO')
ev_dummy:
_SE_PLAY('S_PINPON')
_RET()
```

The above script will jump to the ev_dummy script.

Once there, the sound effect 'S_PINPON' plays. Then, execution returns to where the last call happened.

After returning, the sound effect 'S_BOO' plays.
44 changes: 44 additions & 0 deletions rom-hacking/scripting/commands/case-cancel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# (38) _CASE_CANCEL

## Effect

Compares the values of @SCWK_REG0 and @EV_WIN_B_CANCEL. Jumps to a script if they are equal.

The position of the jump is not saved. Execution does not return to this command once a _RET is executed.

:::caution

Broken and always considers @SCWK_REG0 as greater and therefore does nothing.

:::

## Syntax

```c
_CASE_JUMP(val, label)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **label** | The label to jump to | String | Required |
## Example
```c
_LDVAL(@LOCALWORK1, 4)
_SWITCH(@LOCALWORK1)
_CASE_JUMP(1, 'ev_dummy_1')
_CASE_JUMP(2, 'ev_dummy_2')
_CASE_JUMP(3, 'ev_dummy_3')
_CASE_CANCEL('ev_dummy_cancel')
```

The above script will set the work variable @LOCALWORK1 to 4.

Then, a switch statement using @LOCALWORK1 is prepared.

First, the value of @LOCALWORK1 is compared to 1. Since they're not equal, execution continues.

The same happens for values 2 and 3.

Finally, _CASE_CANCEL executes and, due to a bug, does nothing.
36 changes: 36 additions & 0 deletions rom-hacking/scripting/commands/case-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# (37) _CASE_JUMP

## Effect

Compares the value of the work of the last prepared "switch" statement to the given value. Jumps to a script if they are equal.

The position of the jump is not saved. Execution does not return to this command once a _RET is executed.

## Syntax

```c
_CASE_JUMP(val, label)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **val** | The value to compare to | Work, Float | Required |
| **label** | The label to jump to | String | Required |
## Example
```c
_LDVAL(@LOCALWORK1, 2)
_SWITCH(@LOCALWORK1)
_CASE_JUMP(1, 'ev_dummy_1')
_CASE_JUMP(2, 'ev_dummy_2')
_CASE_JUMP(3, 'ev_dummy_3')
```

The above script will set the work variable @LOCALWORK1 to 2.

Then, a switch statement using @LOCALWORK1 is prepared.

First, the value of @LOCALWORK1 is compared to 1. Since they're not equal, execution continues.

Then, the value of @LOCALWORK1 is compared to 2. Since they're equal, ev_dummy_2 is jumped to.
43 changes: 43 additions & 0 deletions rom-hacking/scripting/commands/cmpwk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# (19) _CMPWK

## Effect

Compares the value of a work to the value of another work.

When passing a work, it will check its value and use that as the work to use. When passing a float, it will use that value as the work to use.

:::caution

Broken and always considers **work1** as greater.

:::

## Syntax

```c
_CMPWK(work1, work2)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **work1** | The work to compare | Work, Float | Required |
| **work2** | The work to compare to | Work, Float | Required |
## Example
```c
_LDVAL(@LOCALWORK4, 9)
_LDVAL(@LOCALWORK8, 13)
_LDVAL(@LOCALWORK1, 4)
_CMPWK(@LOCALWORK1, 8)
_IF_JUMP('EQ', 'ev_dummy')
```

The above script will set:
- Work variable @LOCALWORK4 to 9;
- Work variable @LOCALWORK8 to 13;
- Work variable @LOCALWORK1 to 4.

Then, the values of work 4 (@LOCALWORK4) and work 8 (@LOCALWORK8) are compared. Due to a bug, no matter their values, @LOCALWORK4 is determined to be greater.

Next, the result of the comparison is checked. Since the result is "greater" and not "equal", ev_dummy is not jumped to and script execution continues on the next line.
2 changes: 1 addition & 1 deletion rom-hacking/scripting/commands/end.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ _END()
_SE_PLAY('S_PINPON')
```
The above script will set the work variable @LOCALWORK1 to 1, then end script execution. The command on line 3 will not be executed.
The above script will set the work variable @LOCALWORK1 to 1, then end script execution. The 'S_PINPON' sound effect will not play.
38 changes: 38 additions & 0 deletions rom-hacking/scripting/commands/flag-check-wk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# (49) _FLAG_CHECK_WK

## Effect

Checks the flag corresponding to the value of a work.

Sets a work with the result.

:::caution

Contrary to what might be expected, a result of 0 is true and 1 is false.

:::

## Syntax

```c
_FLAG_CHECK_WK(flag, result)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **flag** | The work containing the flag to check or the direct flag number | Work, Float | Required |
| **result** | The work to put the result in | Work | Required |
## Example
```c
_FLAG_SET(#FH_03)
_FLAG_CHECK_WK(#FH_03, @LOCALWORK1)
_IFVAL_JUMP(@LOCALWORK1, 'EQ', 0, 'ev_dummy')
```

The above script will set the #FH_03 flag.

Next, it checks the same flag. Since it is true, 0 is put into @LOCALWORK1.

Finally, @LOCALWORK1 is compared to 0. Since it is equal to it, the script jumps to ev_dummy.
35 changes: 35 additions & 0 deletions rom-hacking/scripting/commands/flag-check.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# (44) _FLAG_CHECK

## Effect

Checks the value of a flag and sets the comparison result.

:::caution

The comparison result is "less" if the flag is true, and "equal" if the flag is false. Keep this in mind if using "FLGON" and "FLGOFF" as the comparison operator since they correspond to "equal" and "less" respectively (so the opposite of what you would expect here).

:::

## Syntax

```c
_FLAG_CHECK(flag)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **flag** | The flag to check | Flag | Required |
## Example
```c
_FLAG_SET(#FH_03)
_FLAG_CHECK(#FH_03)
_IF_JUMP('FLGON', 'ev_dummy')
```

The above script will set the #FH_03 flag.

Then, the #FH_03 flag is checked and the comprison result is set.

Next, the result of the comparison is checked. Since the condition is "FLGON" which corresponds to "equal", ev_dummy will not be jumped to.
23 changes: 23 additions & 0 deletions rom-hacking/scripting/commands/flag-reset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# (43) _FLAG_RESET

## Effect

Resets the given flag to false.

## Syntax

```c
_FLAG_RESET(flag)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **flag** | The flag to reset | Flag | Required |
## Example
```c
_FLAG_RESET(#FH_03)
```

The above script will reset the #FH_03 flag.
26 changes: 26 additions & 0 deletions rom-hacking/scripting/commands/flag-set-wk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# (50) _FLAG_SET_WK

## Effect

Sets the flag corresponding to the given value to true.

## Syntax

```c
_FLAG_SET_WK(flag)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **flag** | The work containing the flag to set or the direct flag number | Work, Float | Required |
## Example
```c
_LDVAL(@LOCALWORK1, 3)
_FLAG_SET_WK(@LOCALWORK1)
```

The above script will set the work variable @LOCALWORK1 to 3.

Then, the flag number contained in @LOCALWORK1 (in this case 3) is the flag that gets set to true. This corresponds to flag #FH_04.
25 changes: 25 additions & 0 deletions rom-hacking/scripting/commands/flag-set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# (41) _FLAG_SET

## Effect

Sets the given flag to true.

If the flag is #FLAG_STOP_ZONE_PROGRAM, also updates FieldManager's eventTownMapPos to the player's world position.

## Syntax

```c
_FLAG_SET(flag)
```
| Argument | Description | Types | Required |
| - | - | - | - |
| **flag** | The flag to set | Flag | Required |
## Example
```c
_FLAG_SET(#FH_03)
```

The above script will set the #FH_03 flag.
Loading

0 comments on commit 5be3802

Please sign in to comment.