Merge branch 'RHH/upcoming' into RHH/pr/upcoming/cleanup/customTrainer

# Conflicts:
#	src/battle_main.c
#	src/battle_tower.c
#	src/match_call.c
This commit is contained in:
Eduardo Quezada 2023-08-11 11:41:44 -04:00
commit f026b51b48
288 changed files with 8197 additions and 4294 deletions

View File

@ -23,8 +23,9 @@ body:
label: Version label: Version
description: What version of pokeemerald-expansion are you using as a base? description: What version of pokeemerald-expansion are you using as a base?
options: options:
- 1.5.0 (Default) - 1.5.1 (Default)
- upcoming (Edge) - upcoming (Edge)
- 1.5.0
- 1.4.3 - 1.4.3
- 1.4.2 - 1.4.2
- 1.4.1 - 1.4.1

View File

@ -23,8 +23,9 @@ body:
label: Version label: Version
description: What version of pokeemerald-expansion are you using as a base? description: What version of pokeemerald-expansion are you using as a base?
options: options:
- 1.5.0 (Default) - 1.5.1 (Default)
- upcoming (Edge) - upcoming (Edge)
- 1.5.0
- 1.4.3 - 1.4.3
- 1.4.2 - 1.4.2
- 1.4.1 - 1.4.1

View File

@ -23,8 +23,9 @@ body:
label: Version label: Version
description: What version of pokeemerald-expansion are you using as a base? description: What version of pokeemerald-expansion are you using as a base?
options: options:
- 1.5.0 (Default) - 1.5.1 (Default)
- upcoming (Edge) - upcoming (Edge)
- 1.5.0
- 1.4.3 - 1.4.3
- 1.4.2 - 1.4.2
- 1.4.1 - 1.4.1

View File

@ -4,9 +4,7 @@ on:
push: push:
branches: branches:
- master - master
- battle_engine - upcoming
- pokemon_expansion
- item_expansion
pull_request: pull_request:
jobs: jobs:

View File

@ -1,16 +0,0 @@
name: Close issues related to a merged pull request based on master branch.
on:
pull_request:
types: [closed]
branches:
- upcoming
jobs:
closeIssueOnPrMergeTrigger:
runs-on: ubuntu-latest
steps:
- name: Closes issues related to a merged pull request.
uses: ldez/gha-mjolnir@v1.0.3

View File

@ -125,19 +125,53 @@ Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or conti
Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert.
1. Open msys2 at C:\devkitPro\msys2\mingw64.exe or run `C:\devkitPro\msys2\msys2_shell.bat -mingw64`. 1. Open msys2 at C:\devkitPro\msys2\msys2_shell.bat.
2. Certain packages are required to build pokeemerald. Install these by running the following command: 2. Certain packages are required to build pokeemerald. Install these by running the following two commands:
```bash ```bash
pacman -S make zlib-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-libpng pacman -Sy msys2-keyring
pacman -S make gcc zlib-devel git
``` ```
<details> <details>
<summary><i>Note...</i></summary> <summary><i>Note...</i></summary>
> This command will ask for confirmation, just enter the yes action when prompted. > The commands will ask for confirmation, just enter the yes action when prompted.
</details> </details>
3. Download [libpng](https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.xz/download).
4. Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\&#8288;_\<user>_**, where *\<user>* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\<user>_\Downloads** (the Downloads location for most users), enter this command:
```bash
cd Downloads
```
<details>
<summary><i>Notes...</i></summary>
> Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator.
> Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`.
> Note 3: Windows path names are case-insensitive so adhering to capitalization isnt needed.
> Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there.
</details>
5. Run the following commands to uncompress and install libpng.
```bash
tar xf libpng-1.6.37.tar.xz
cd libpng-1.6.37
./configure --prefix=/usr
make check
make install
```
6. Then finally, run the following command to change back to the user profile folder.
```bash
cd
```
### Choosing where to store pokeemerald (msys2) ### Choosing where to store pokeemerald (msys2)
At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder. At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder.

View File

@ -28,7 +28,7 @@ LD := $(PREFIX)ld
# note: the makefile must be set up so MODERNCC is never called # note: the makefile must be set up so MODERNCC is never called
# if MODERN=0 # if MODERN=0
MODERNCC := $(PREFIX)gcc MODERNCC := $(PREFIX)gcc
PATH_MODERNCC := PATH=$(TOOLCHAIN)/bin:PATH $(MODERNCC) PATH_MODERNCC := PATH="$(PATH)" $(MODERNCC)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
EXE := .exe EXE := .exe
@ -118,7 +118,7 @@ LIBPATH := -L ../../tools/agbcc/lib
LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall
else else
CC1 = $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet CC1 = $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -std=gnu17 -fanalyzer
ROM := $(MODERN_ROM_NAME) ROM := $(MODERN_ROM_NAME)
OBJ_DIR := $(MODERN_OBJ_DIR_NAME) OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))" LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))"

View File

@ -1053,8 +1053,9 @@
.byte 0xca .byte 0xca
.endm .endm
.macro setcharge .macro setcharge battler:req
.byte 0xcb .byte 0xcb
.byte \battler
.endm .endm
.macro callterrainattack .macro callterrainattack
@ -1381,6 +1382,12 @@
.4byte \ptr .4byte \ptr
.endm .endm
.macro jumpifcantloseitem battler:req, ptr:req
callnative BS_JumpIfCantLoseItem
.byte \battler
.4byte \ptr
.endm
@ various command changed to more readable macros @ various command changed to more readable macros
.macro cancelmultiturnmoves battler:req .macro cancelmultiturnmoves battler:req
various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES

File diff suppressed because it is too large Load Diff

View File

@ -432,6 +432,57 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE .4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE
.4byte BattleScript_EffectTakeHeart @ EFFECT_TAKE_HEART .4byte BattleScript_EffectTakeHeart @ EFFECT_TAKE_HEART
.4byte BattleScript_EffectAxeKick @ EFFECT_AXE_KICK .4byte BattleScript_EffectAxeKick @ EFFECT_AXE_KICK
.4byte BattleScript_EffectHit @ EFFECT_COLLISION_COURSE
.4byte BattleScript_EffectSpinOut @ EFFECT_SPIN_OUT
.4byte BattleScript_EffectMakeItRain @ EFFECT_MAKE_IT_RAIN
.4byte BattleScript_EffectCorrosiveGas @ EFFECT_CORROSIVE_GAS
.4byte BattleScript_EffectHit @ EFFECT_POPULATION_BOMB
.4byte BattleScript_EffectMortalSpin @ EFFECT_MORTAL_SPIN
BattleScript_EffectMortalSpin:
call BattleScript_EffectHit_Ret
rapidspinfree
setmoveeffect MOVE_EFFECT_POISON
seteffectwithchance
tryfaintmon BS_TARGET
moveendall
end
BattleScript_EffectCorrosiveGas:
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
jumpifsubstituteblocks BattleScript_CorrosiveGasFail
jumpifcantloseitem BS_TARGET, BattleScript_CorrosiveGasFail
attackanimation
waitanimation
jumpifability BS_TARGET, ABILITY_STICKY_HOLD, BattleScript_StickyHoldActivates
setlastuseditem BS_TARGET
removeitem BS_TARGET
printstring STRINGID_PKMNITEMMELTED
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_CorrosiveGasFail:
pause B_WAIT_TIME_SHORT
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
printstring STRINGID_NOEFFECTONTARGET
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_EffectMakeItRain:
setmoveeffect MOVE_EFFECT_PAYDAY
call BattleScript_EffectHit_Ret
seteffectwithchance
tryfaintmon BS_TARGET
setmoveeffect MOVE_EFFECT_SP_ATK_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
seteffectprimary
goto BattleScript_MoveEnd
BattleScript_EffectSpinOut::
setmoveeffect MOVE_EFFECT_SPD_MINUS_2 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
goto BattleScript_EffectHit
BattleScript_EffectAxeKick:: BattleScript_EffectAxeKick::
setmoveeffect MOVE_EFFECT_CONFUSION setmoveeffect MOVE_EFFECT_CONFUSION
@ -1121,24 +1172,7 @@ BattleScript_HyperspaceFuryRemoveProtect::
return return
BattleScript_EffectPlasmaFists: BattleScript_EffectPlasmaFists:
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance seteffectwithchance
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
applyplasmafists applyplasmafists
@ -1147,24 +1181,7 @@ BattleScript_EffectPlasmaFists:
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectSparklySwirl: BattleScript_EffectSparklySwirl:
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
healpartystatus healpartystatus
waitstate waitstate
@ -1173,24 +1190,7 @@ BattleScript_EffectSparklySwirl:
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectFreezyFrost: BattleScript_EffectFreezyFrost:
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
normalisebuffs normalisebuffs
printstring STRINGID_STATCHANGESGONE printstring STRINGID_STATCHANGESGONE
@ -1199,24 +1199,7 @@ BattleScript_EffectFreezyFrost:
BattleScript_EffectSappySeed: BattleScript_EffectSappySeed:
jumpifstatus3 BS_TARGET, STATUS3_LEECHSEED, BattleScript_EffectHit jumpifstatus3 BS_TARGET, STATUS3_LEECHSEED, BattleScript_EffectHit
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
jumpifhasnohp BS_TARGET, BattleScript_MoveEnd jumpifhasnohp BS_TARGET, BattleScript_MoveEnd
setseeded setseeded
@ -1226,24 +1209,7 @@ BattleScript_EffectSappySeed:
BattleScript_EffectBaddyBad: BattleScript_EffectBaddyBad:
jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_REFLECT, BattleScript_EffectHit jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_REFLECT, BattleScript_EffectHit
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
setreflect setreflect
printfromtable gReflectLightScreenSafeguardStringIds printfromtable gReflectLightScreenSafeguardStringIds
@ -1252,24 +1218,7 @@ BattleScript_EffectBaddyBad:
BattleScript_EffectGlitzyGlow: BattleScript_EffectGlitzyGlow:
jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_LIGHTSCREEN, BattleScript_EffectHit jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_LIGHTSCREEN, BattleScript_EffectHit
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
setlightscreen setlightscreen
printfromtable gReflectLightScreenSafeguardStringIds printfromtable gReflectLightScreenSafeguardStringIds
@ -1430,24 +1379,7 @@ BattleScript_NoMoveEffect:
BattleScript_EffectRelicSong: BattleScript_EffectRelicSong:
setmoveeffect MOVE_EFFECT_RELIC_SONG | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN setmoveeffect MOVE_EFFECT_RELIC_SONG | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance seteffectwithchance
argumentstatuseffect argumentstatuseffect
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
@ -2214,24 +2146,7 @@ BattleScript_EffectFinalGambit:
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectHitSwitchTarget: BattleScript_EffectHitSwitchTarget:
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
moveendall moveendall
jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut
@ -3115,12 +3030,9 @@ BattleScript_TryTailwindAbilitiesLoop_WindRider:
BattleScript_TryTailwindAbilitiesLoop_WindPower: BattleScript_TryTailwindAbilitiesLoop_WindPower:
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
copybyte sSAVED_BATTLER, gBattlerAttacker setcharge BS_TARGET
copybyte gBattlerAttacker, gBattlerTarget
setcharge
printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
copybyte gBattlerAttacker, sSAVED_BATTLER
goto BattleScript_TryTailwindAbilitiesLoop_Increment goto BattleScript_TryTailwindAbilitiesLoop_Increment
BattleScript_EffectMircleEye: BattleScript_EffectMircleEye:
@ -3191,24 +3103,7 @@ BattleScript_EffectThroatChop:
goto BattleScript_EffectHit goto BattleScript_EffectHit
BattleScript_EffectHitEscape: BattleScript_EffectHitEscape:
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
jumpifmovehadnoeffect BattleScript_MoveEnd jumpifmovehadnoeffect BattleScript_MoveEnd
jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd
seteffectwithchance seteffectwithchance
@ -3280,6 +3175,27 @@ BattleScript_MoveEnd::
moveendall moveendall
end end
BattleScript_EffectHit_Ret::
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
return
BattleScript_EffectNaturalGift: BattleScript_EffectNaturalGift:
attackcanceler attackcanceler
attackstring attackstring
@ -3471,24 +3387,7 @@ BattleScript_EffectPoisonHit:
goto BattleScript_EffectHit goto BattleScript_EffectHit
BattleScript_EffectAbsorb:: BattleScript_EffectAbsorb::
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_AbsorbHealBlock jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_AbsorbHealBlock
setdrainedhp setdrainedhp
manipulatedamage DMG_BIG_ROOT manipulatedamage DMG_BIG_ROOT
@ -3917,24 +3816,7 @@ BattleScript_EffectFlinchHit::
BattleScript_EffectFlinchStatus: BattleScript_EffectFlinchStatus:
setmoveeffect MOVE_EFFECT_FLINCH setmoveeffect MOVE_EFFECT_FLINCH
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance seteffectwithchance
argumentstatuseffect argumentstatuseffect
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
@ -5167,24 +5049,7 @@ BattleScript_EffectBatonPass::
BattleScript_EffectRapidSpin:: BattleScript_EffectRapidSpin::
.if B_SPEED_BUFFING_RAPID_SPIN == GEN_8 .if B_SPEED_BUFFING_RAPID_SPIN == GEN_8
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd
setmoveeffect MOVE_EFFECT_RAPIDSPIN | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN setmoveeffect MOVE_EFFECT_RAPIDSPIN | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
seteffectwithchance seteffectwithchance
@ -5903,7 +5768,7 @@ BattleScript_EffectCharge::
attackcanceler attackcanceler
attackstring attackstring
ppreduce ppreduce
setcharge setcharge BS_ATTACKER
attackanimation attackanimation
waitanimation waitanimation
.if B_CHARGE_SPDEF_RAISE >= GEN_5 .if B_CHARGE_SPDEF_RAISE >= GEN_5
@ -6801,9 +6666,6 @@ BattleScript_DoSwitchOut::
hidepartystatussummary BS_ATTACKER hidepartystatussummary BS_ATTACKER
switchinanim BS_ATTACKER, FALSE switchinanim BS_ATTACKER, FALSE
waitstate waitstate
jumpifcantreverttoprimal BattleScript_DoSwitchOut2
call BattleScript_PrimalReversionRet
BattleScript_DoSwitchOut2:
switchineffects BS_ATTACKER switchineffects BS_ATTACKER
moveendcase MOVEEND_STATUS_IMMUNITY_ABILITIES moveendcase MOVEEND_STATUS_IMMUNITY_ABILITIES
moveendcase MOVEEND_MIRROR_MOVE moveendcase MOVEEND_MIRROR_MOVE
@ -6942,14 +6804,14 @@ BattleScript_SunlightFaded::
BattleScript_OverworldWeatherStarts:: BattleScript_OverworldWeatherStarts::
printfromtable gWeatherStartsStringIds printfromtable gWeatherStartsStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
playanimation_var BS_ATTACKER, sB_ANIM_ARG1 playanimation_var BS_BATTLER_0, sB_ANIM_ARG1
call BattleScript_ActivateWeatherAbilities call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_OverworldTerrain:: BattleScript_OverworldTerrain::
printfromtable gTerrainStringIds printfromtable gTerrainStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG playanimation BS_BATTLER_0, B_ANIM_RESTORE_BG
call BattleScript_ActivateTerrainEffects call BattleScript_ActivateTerrainEffects
end3 end3
@ -6973,27 +6835,6 @@ BattleScript_TailwindEnds::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
end2 end2
BattleScript_WindPowerActivatesEnd2::
setbyte gBattlerAttacker, 0
BattleScript_WindPowerLoop:
printstring STRINGID_EMPTYSTRING3
jumpifability BS_ATTACKER, ABILITY_WIND_POWER, BattleScript_WindPowerLoop_Cont
goto BattleScript_WindPowerIncrement
BattleScript_WindPowerLoop_Cont:
jumpifstatus3 BS_ATTACKER, STATUS3_CHARGED_UP, BattleScript_WindPowerIncrement
goto BattleScript_WindPower_Activate
BattleScript_WindPower_Activate:
call BattleScript_AbilityPopUp
setcharge
printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER
waitmessage B_WAIT_TIME_LONG
BattleScript_WindPowerIncrement:
addbyte gBattlerAttacker, 1
jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_WindPowerLoop
BattleScript_WindPowerEnd:
destroyabilitypopup
end2
BattleScript_TrickRoomEnds:: BattleScript_TrickRoomEnds::
printstring STRINGID_TRICKROOMENDS printstring STRINGID_TRICKROOMENDS
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
@ -7455,11 +7296,8 @@ BattleScript_AngerShellRet:
return return
BattleScript_WindPowerActivates:: BattleScript_WindPowerActivates::
.if B_CHECK_IF_CHARGED_UP == TRUE
jumpifstatus3 BS_ATTACKER, STATUS3_CHARGED_UP, BattleScript_WindPowerActivates_Ret
.endif
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
setcharge setcharge BS_TARGET
printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER printstring STRINGID_BEINGHITCHARGEDPKMNWITHPOWER
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
BattleScript_WindPowerActivates_Ret: BattleScript_WindPowerActivates_Ret:
@ -7958,17 +7796,12 @@ BattleScript_WishMegaEvolution::
goto BattleScript_MegaEvolutionAfterString goto BattleScript_MegaEvolutionAfterString
BattleScript_PrimalReversion:: BattleScript_PrimalReversion::
printstring STRINGID_EMPTYSTRING3 call BattleScript_PrimalReversionRet
waitmessage 1 end2
setbyte gIsCriticalHit, 0
handleprimalreversion BS_ATTACKER, 0 BattleScript_PrimalReversionRestoreAttacker::
handleprimalreversion BS_ATTACKER, 1 call BattleScript_PrimalReversionRet
playanimation BS_ATTACKER, B_ANIM_PRIMAL_REVERSION copybyte gBattlerAttacker, sSAVED_BATTLER
waitanimation
handleprimalreversion BS_ATTACKER, 2
printstring STRINGID_PKMNREVERTEDTOPRIMAL
waitmessage B_WAIT_TIME_LONG
switchinabilities BS_ATTACKER
end2 end2
BattleScript_PrimalReversionRet:: BattleScript_PrimalReversionRet::
@ -7982,6 +7815,7 @@ BattleScript_PrimalReversionRet::
handleprimalreversion BS_ATTACKER, 2 handleprimalreversion BS_ATTACKER, 2
printstring STRINGID_PKMNREVERTEDTOPRIMAL printstring STRINGID_PKMNREVERTEDTOPRIMAL
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
switchinabilities BS_ATTACKER
return return
BattleScript_AttackerFormChange:: BattleScript_AttackerFormChange::
@ -8822,15 +8656,14 @@ BattleScript_DesolateLandActivates::
call BattleScript_ActivateWeatherAbilities call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_DesolateLandEvaporatesWaterTypeMoves:: BattleScript_PrimalWeatherBlocksMove::
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_ATTACKSTRING_PRINTED, BattleScript_MoveEnd @in case of multi-target moves, if move fails once, no point in printing the message twice
accuracycheck BattleScript_PrintMoveMissed, NO_ACC_CALC_CHECK_LOCK_ON
attackstring attackstring
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
ppreduce ppreduce
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_STRING_PRINTED, BattleScript_MoveEnd printfromtable gPrimalWeatherBlocksStringIds
printstring STRINGID_MOVEEVAPORATEDINTHEHARSHSUNLIGHT
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orword gHitMarker, HITMARKER_STRING_PRINTED
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_PrimordialSeaActivates:: BattleScript_PrimordialSeaActivates::
@ -8842,17 +8675,6 @@ BattleScript_PrimordialSeaActivates::
call BattleScript_ActivateWeatherAbilities call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_PrimordialSeaFizzlesOutFireTypeMoves::
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
pause B_WAIT_TIME_SHORT
ppreduce
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_STRING_PRINTED, BattleScript_MoveEnd
printstring STRINGID_MOVEFIZZLEDOUTINTHEHEAVYRAIN
waitmessage B_WAIT_TIME_LONG
orword gHitMarker, HITMARKER_STRING_PRINTED
goto BattleScript_MoveEnd
BattleScript_DeltaStreamActivates:: BattleScript_DeltaStreamActivates::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
@ -8990,16 +8812,7 @@ BattleScript_PsychicSurgeActivates::
call BattleScript_ActivateTerrainEffects call BattleScript_ActivateTerrainEffects
end3 end3
BattleScript_HurtTarget_NoString:
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
tryfaintmon BS_TARGET
return
BattleScript_BadDreamsActivates:: BattleScript_BadDreamsActivates::
call BattleScript_AbilityPopUp
setbyte sFIXED_ABILITY_POPUP, TRUE
setbyte gBattlerTarget, 0 setbyte gBattlerTarget, 0
BattleScript_BadDreamsLoop: BattleScript_BadDreamsLoop:
jumpiftargetally BattleScript_BadDreamsIncrement jumpiftargetally BattleScript_BadDreamsIncrement
@ -9008,16 +8821,32 @@ BattleScript_BadDreamsLoop:
jumpifstatus BS_TARGET, STATUS1_SLEEP, BattleScript_BadDreams_Dmg jumpifstatus BS_TARGET, STATUS1_SLEEP, BattleScript_BadDreams_Dmg
goto BattleScript_BadDreamsIncrement goto BattleScript_BadDreamsIncrement
BattleScript_BadDreams_Dmg: BattleScript_BadDreams_Dmg:
jumpifbyteequal sFIXED_ABILITY_POPUP, sZero, BattleScript_BadDreams_ShowPopUp
BattleScript_BadDreams_DmgAfterPopUp:
printstring STRINGID_BADDREAMSDMG printstring STRINGID_BADDREAMSDMG
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
dmg_1_8_targethp dmg_1_8_targethp
call BattleScript_HurtTarget_NoString orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
jumpifhasnohp BS_TARGET, BattleScript_BadDreams_HidePopUp
BattleScript_BadDreamsIncrement: BattleScript_BadDreamsIncrement:
addbyte gBattlerTarget, 1 addbyte gBattlerTarget, 1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_BadDreamsLoop jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_BadDreamsLoop
BattleScript_BadDreamsEnd: jumpifbyteequal sFIXED_ABILITY_POPUP, sZero, BattleScript_BadDreamsEnd
destroyabilitypopup destroyabilitypopup
pause 15
BattleScript_BadDreamsEnd:
end3 end3
BattleScript_BadDreams_ShowPopUp:
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
setbyte sFIXED_ABILITY_POPUP, TRUE
goto BattleScript_BadDreams_DmgAfterPopUp
BattleScript_BadDreams_HidePopUp:
destroyabilitypopup
tryfaintmon BS_TARGET
goto BattleScript_BadDreamsIncrement
BattleScript_TookAttack:: BattleScript_TookAttack::
attackstring attackstring
@ -10294,24 +10123,7 @@ BattleScript_ExtremeEvoboostEnd::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectHitSetRemoveTerrain: BattleScript_EffectHitSetRemoveTerrain:
attackcanceler call BattleScript_EffectHit_Ret
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
setterrain BattleScript_TryFaint setterrain BattleScript_TryFaint
playanimation BS_ATTACKER, B_ANIM_RESTORE_BG playanimation BS_ATTACKER, B_ANIM_RESTORE_BG
printfromtable gTerrainStringIds printfromtable gTerrainStringIds
@ -10494,6 +10306,7 @@ BattleScript_SymbiosisActivates::
return return
BattleScript_TargetAbilityStatRaiseRet:: BattleScript_TargetAbilityStatRaiseRet::
copybyte sSAVED_BATTLER, gBattlerAttacker
copybyte gBattlerAbility, gEffectBattler copybyte gBattlerAbility, gEffectBattler
copybyte gBattlerAttacker, gBattlerTarget copybyte gBattlerAttacker, gBattlerTarget
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
@ -10501,6 +10314,7 @@ BattleScript_TargetAbilityStatRaiseRet::
setgraphicalstatchangevalues setgraphicalstatchangevalues
call BattleScript_StatUp call BattleScript_StatUp
BattleScript_TargetAbilityStatRaiseRet_End: BattleScript_TargetAbilityStatRaiseRet_End:
copybyte gBattlerAttacker, sSAVED_BATTLER
return return
BattleScript_PokemonCantUseTheMove:: BattleScript_PokemonCantUseTheMove::

View File

@ -421,7 +421,12 @@ BattleFrontier_BattleTowerLobby_EventScript_SaveBeforeLinkMultisChallenge::
call Common_EventScript_SaveGame call Common_EventScript_SaveGame
setvar VAR_TEMP_0, 255 setvar VAR_TEMP_0, 255
goto_if_eq VAR_RESULT, 0, BattleFrontier_BattleTowerLobby_EventScript_CancelChallengeSaveFailed goto_if_eq VAR_RESULT, 0, BattleFrontier_BattleTowerLobby_EventScript_CancelChallengeSaveFailed
@ GAME_STAT_ENTERED_BATTLE_TOWER should not be incremented here, for two reasons:
@ 1. It is incremented again in BattleFrontier_BattleTowerLobby_EventScript_CableLinkSuccessful or BattleFrontier_BattleTowerLobby_EventScript_WirelessLinkSuccessful
@ 2. If the player tries to save, but fails, the counter will still be incremented even if the player never enters the tower.
.ifndef BUGFIX
incrementgamestat GAME_STAT_ENTERED_BATTLE_TOWER incrementgamestat GAME_STAT_ENTERED_BATTLE_TOWER
.endif
specialvar VAR_RESULT, IsWirelessAdapterConnected specialvar VAR_RESULT, IsWirelessAdapterConnected
goto_if_eq VAR_RESULT, TRUE, BattleFrontier_BattleTowerLobby_EventScript_TryWirelessLink goto_if_eq VAR_RESULT, TRUE, BattleFrontier_BattleTowerLobby_EventScript_TryWirelessLink
goto BattleFrontier_BattleTowerLobby_EventScript_TryCableLink goto BattleFrontier_BattleTowerLobby_EventScript_TryCableLink

View File

@ -1,14 +1,15 @@
.if DEBUG_OVERWORLD_MENU == TRUE .if DEBUG_OVERWORLD_MENU == TRUE
Debug_MessageEnd:
Debug_ShowFieldMessageStringVar4::
special ShowFieldMessageStringVar4
waitmessage waitmessage
waitbuttonpress waitbuttonpress
releaseall releaseall
end end
Debug_ShowFieldMessageStringVar4::
special ShowFieldMessageStringVar4
goto Debug_MessageEnd
Debug_CheatStart:: Debug_CheatStart::
lockall
setflag FLAG_SYS_POKEMON_GET setflag FLAG_SYS_POKEMON_GET
setflag FLAG_RESCUED_BIRCH setflag FLAG_RESCUED_BIRCH
setflag FLAG_HIDE_ROUTE_101_BIRCH_ZIGZAGOON_BATTLE setflag FLAG_HIDE_ROUTE_101_BIRCH_ZIGZAGOON_BATTLE
@ -44,12 +45,8 @@ Debug_CheatStart::
end end
Debug_FlagsNotSetOverworldConfigMessage:: Debug_FlagsNotSetOverworldConfigMessage::
lockall
message Debug_FlagsNotSetOverworldConfigMessage_Text message Debug_FlagsNotSetOverworldConfigMessage_Text
waitmessage goto Debug_MessageEnd
waitbuttonpress
releaseall
end
Debug_FlagsNotSetOverworldConfigMessage_Text: Debug_FlagsNotSetOverworldConfigMessage_Text:
.string "Feature unavailable!\n" .string "Feature unavailable!\n"
@ -57,18 +54,21 @@ Debug_FlagsNotSetOverworldConfigMessage_Text:
.string "'include/config/overworld.h'!$" .string "'include/config/overworld.h'!$"
Debug_FlagsNotSetBattleConfigMessage:: Debug_FlagsNotSetBattleConfigMessage::
lockall
message Debug_FlagsNotSetBattleConfigMessage_Text message Debug_FlagsNotSetBattleConfigMessage_Text
waitmessage goto Debug_MessageEnd
waitbuttonpress
releaseall
end
Debug_FlagsNotSetBattleConfigMessage_Text: Debug_FlagsNotSetBattleConfigMessage_Text:
.string "Feature unavailable!\n" .string "Feature unavailable!\n"
.string "Please define a usable flag in:\l" .string "Please define a usable flag in:\l"
.string "'include/config/battle.h'!$" .string "'include/config/battle.h'!$"
Debug_BoxFilledMessage::
message Debug_BoxFilledMessage_Text
goto Debug_MessageEnd
Debug_BoxFilledMessage_Text:
.string "Storage boxes filled!$"
Debug_Script_1:: Debug_Script_1::
end end
@ -112,4 +112,35 @@ Debug_SaveBlock2Size::
Debug_PokemonStorageSize:: Debug_PokemonStorageSize::
.string "{PKMN}Storage size: {STR_VAR_1}/{STR_VAR_2}.$" .string "{PKMN}Storage size: {STR_VAR_1}/{STR_VAR_2}.$"
Debug_HatchAnEgg::
lockall
getpartysize
goto_if_eq VAR_RESULT, 0, Debug_HatchAnEgg_NoPokemon
special ChoosePartyMon
waitstate
goto_if_ge VAR_0x8004, PARTY_SIZE, Debug_HatchAnEgg_End
specialvar VAR_RESULT, ScriptGetPartyMonSpecies
goto_if_ne VAR_RESULT, SPECIES_EGG, DebugScript_HatchAnEgg_CantForceHatch
special EggHatch
waitstate
Debug_HatchAnEgg_End::
releaseall
end
Debug_HatchAnEgg_NoPokemon::
msgbox DebugScript_HatchAnEgg_Text_EmptyParty, MSGBOX_DEFAULT
releaseall
end
DebugScript_HatchAnEgg_CantForceHatch::
msgbox DebugScript_HatchAnEgg_Text_NotAnEgg, MSGBOX_DEFAULT
releaseall
end
DebugScript_HatchAnEgg_Text_EmptyParty::
.string "You have no Pokémon nor Eggs.$"
DebugScript_HatchAnEgg_Text_NotAnEgg::
.string "That's not a Pokémon Egg.$"
.endif .endif

View File

@ -48,11 +48,7 @@ struct OamDimensions
s8 height; s8 height;
}; };
static void UpdateOamCoords(void); static void SortSprites(u32 *spritePriorities, s32 n);
static void BuildSpritePriorities(void);
static void SortSprites(void);
static void CopyMatricesToOamBuffer(void);
static void AddSpritesToOamBuffer(void);
static u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); static u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority);
static void ResetOamMatrices(void); static void ResetOamMatrices(void);
static void ResetSprite(struct Sprite *sprite); static void ResetSprite(struct Sprite *sprite);
@ -280,12 +276,12 @@ u32 gOamMatrixAllocBitmap;
u8 gReservedSpritePaletteCount; u8 gReservedSpritePaletteCount;
EWRAM_DATA struct Sprite gSprites[MAX_SPRITES + 1] = {0}; EWRAM_DATA struct Sprite gSprites[MAX_SPRITES + 1] = {0};
EWRAM_DATA static u16 sSpritePriorities[MAX_SPRITES] = {0};
EWRAM_DATA static u8 sSpriteOrder[MAX_SPRITES] = {0}; EWRAM_DATA static u8 sSpriteOrder[MAX_SPRITES] = {0};
EWRAM_DATA static bool8 sShouldProcessSpriteCopyRequests = 0; EWRAM_DATA static bool8 sShouldProcessSpriteCopyRequests = 0;
EWRAM_DATA static u8 sSpriteCopyRequestCount = 0; EWRAM_DATA static u8 sSpriteCopyRequestCount = 0;
EWRAM_DATA static struct SpriteCopyRequest sSpriteCopyRequests[MAX_SPRITES] = {0}; EWRAM_DATA static struct SpriteCopyRequest sSpriteCopyRequests[MAX_SPRITES] = {0};
EWRAM_DATA u8 gOamLimit = 0; EWRAM_DATA u8 gOamLimit = 0;
static EWRAM_DATA u8 gOamDummyIndex = 0;
EWRAM_DATA u16 gReservedSpriteTileCount = 0; EWRAM_DATA u16 gReservedSpriteTileCount = 0;
EWRAM_DATA static u8 sSpriteTileAllocBitmap[128] = {0}; EWRAM_DATA static u8 sSpriteTileAllocBitmap[128] = {0};
EWRAM_DATA s16 gSpriteCoordOffsetX = 0; EWRAM_DATA s16 gSpriteCoordOffsetX = 0;
@ -296,6 +292,7 @@ EWRAM_DATA bool8 gAffineAnimsDisabled = FALSE;
void ResetSpriteData(void) void ResetSpriteData(void)
{ {
ResetOamRange(0, 128); ResetOamRange(0, 128);
gOamDummyIndex = 0;
ResetAllSprites(); ResetAllSprites();
ClearSpriteCopyRequests(); ClearSpriteCopyRequests();
ResetAffineAnimData(); ResetAffineAnimData();
@ -326,26 +323,37 @@ void AnimateSprites(void)
void BuildOamBuffer(void) void BuildOamBuffer(void)
{ {
u8 temp; bool32 oamLoadDisabled;
UpdateOamCoords(); u32 i, stride;
BuildSpritePriorities(); u8 oamIndex;
SortSprites();
temp = gMain.oamLoadDisabled; // All attributes which affect sorting packed into a single u32:
gMain.oamLoadDisabled = TRUE; // { priority:2, subpriority:8, y:9, :5, index:8 }.
AddSpritesToOamBuffer(); // Index has its own byte even though it only needs 6 bits so that
CopyMatricesToOamBuffer(); // we can load it with a ldrb instead of having to mask out the
gMain.oamLoadDisabled = temp; // bottom 6 bits.
sShouldProcessSpriteCopyRequests = TRUE; u32 spritePriorities[MAX_SPRITES];
} s32 toSort = 0;
u8 skippedSprites[MAX_SPRITES];
u32 skippedSpritesN = 0;
u32 matrices = 0;
void UpdateOamCoords(void)
{
u8 i;
for (i = 0; i < MAX_SPRITES; i++) for (i = 0; i < MAX_SPRITES; i++)
{ {
struct Sprite *sprite = &gSprites[i]; // Reuse existing sSpriteOrder because we expect the order to be
if (sprite->inUse && !sprite->invisible) // relatively stable between frames.
u32 index = sSpriteOrder[i];
struct Sprite *sprite = &gSprites[index];
s32 y;
if (!sprite->inUse || sprite->invisible)
{ {
skippedSprites[skippedSpritesN++] = index;
continue;
}
if (sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK)
matrices |= 1 << sprite->oam.matrixNum;
if (sprite->coordOffsetEnabled) if (sprite->coordOffsetEnabled)
{ {
sprite->oam.x = sprite->x + sprite->x2 + sprite->centerToCornerVecX + gSpriteCoordOffsetX; sprite->oam.x = sprite->x + sprite->x2 + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
@ -356,122 +364,54 @@ void UpdateOamCoords(void)
sprite->oam.x = sprite->x + sprite->x2 + sprite->centerToCornerVecX; sprite->oam.x = sprite->x + sprite->x2 + sprite->centerToCornerVecX;
sprite->oam.y = sprite->y + sprite->y2 + sprite->centerToCornerVecY; sprite->oam.y = sprite->y + sprite->y2 + sprite->centerToCornerVecY;
} }
}
}
}
void BuildSpritePriorities(void) y = sprite->oam.y;
{ if (y >= DISPLAY_HEIGHT)
u16 i;
for (i = 0; i < MAX_SPRITES; i++)
{ {
struct Sprite *sprite = &gSprites[i]; y -= 256;
u16 priority = sprite->subpriority | (sprite->oam.priority << 8);
sSpritePriorities[i] = priority;
} }
} else if (sprite->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite->oam.size == ST_OAM_SIZE_3)
void SortSprites(void)
{
u8 i;
for (i = 1; i < MAX_SPRITES; i++)
{ {
u8 j = i; u32 shape = sprite->oam.shape;
struct Sprite *sprite1 = &gSprites[sSpriteOrder[i - 1]];
struct Sprite *sprite2 = &gSprites[sSpriteOrder[i]];
u16 sprite1Priority = sSpritePriorities[sSpriteOrder[i - 1]];
u16 sprite2Priority = sSpritePriorities[sSpriteOrder[i]];
s16 sprite1Y = sprite1->oam.y;
s16 sprite2Y = sprite2->oam.y;
if (sprite1Y >= DISPLAY_HEIGHT)
sprite1Y = sprite1Y - 256;
if (sprite2Y >= DISPLAY_HEIGHT)
sprite2Y = sprite2Y - 256;
if (sprite1->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite1->oam.size == ST_OAM_SIZE_3)
{
u32 shape = sprite1->oam.shape;
if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE) if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE)
{ {
if (sprite1Y > 128) if (y > 128)
sprite1Y = sprite1Y - 256; y -= 256;
} }
} }
if (sprite2->oam.affineMode == ST_OAM_AFFINE_DOUBLE // y in [-128...159], so (159 - y) in [0..287].
&& sprite2->oam.size == ST_OAM_SIZE_3) spritePriorities[toSort++]
{ = (sprite->oam.priority << 30)
u32 shape = sprite2->oam.shape; | (sprite->subpriority << 22)
if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE) | (((159 - y) & 0x1FF) << 13)
{ | (index << 0);
if (sprite2Y > 128)
sprite2Y = sprite2Y - 256;
}
} }
while (j > 0 SortSprites(spritePriorities, toSort);
&& ((sprite1Priority > sprite2Priority)
|| (sprite1Priority == sprite2Priority && sprite1Y < sprite2Y)))
{
u8 temp = sSpriteOrder[j];
sSpriteOrder[j] = sSpriteOrder[j - 1];
sSpriteOrder[j - 1] = temp;
// UB: If j equals 1, then j-- makes j equal 0. for (i = 0; i < toSort; i++)
// Then, sSpriteOrder[-1] gets accessed below. sSpriteOrder[i] = spritePriorities[i] & 0xFF;
// Although this doesn't result in a bug in the ROM, for (i = 0; i < skippedSpritesN; i++)
// the behavior is undefined. sSpriteOrder[toSort + i] = skippedSprites[i];
j--;
#ifdef UBFIX oamLoadDisabled = gMain.oamLoadDisabled;
if (j == 0) gMain.oamLoadDisabled = TRUE;
for (i = 0, oamIndex = 0; i < toSort; i++)
{
if (AddSpriteToOamBuffer(&gSprites[spritePriorities[i] & 0xFF], &oamIndex))
break; break;
#endif }
sprite1 = &gSprites[sSpriteOrder[j - 1]]; for (i = oamIndex; i < gOamDummyIndex; i++)
sprite2 = &gSprites[sSpriteOrder[j]]; gMain.oamBuffer[i] = gDummyOamData;
sprite1Priority = sSpritePriorities[sSpriteOrder[j - 1]]; gOamDummyIndex = oamIndex;
sprite2Priority = sSpritePriorities[sSpriteOrder[j]];
sprite1Y = sprite1->oam.y;
sprite2Y = sprite2->oam.y;
if (sprite1Y >= DISPLAY_HEIGHT) for (i = 0; matrices != 0; i++, matrices >>= 1)
sprite1Y = sprite1Y - 256;
if (sprite2Y >= DISPLAY_HEIGHT)
sprite2Y = sprite2Y - 256;
if (sprite1->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite1->oam.size == ST_OAM_SIZE_3)
{ {
u32 shape = sprite1->oam.shape; if (matrices & 1)
if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE)
{
if (sprite1Y > 128)
sprite1Y = sprite1Y - 256;
}
}
if (sprite2->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite2->oam.size == ST_OAM_SIZE_3)
{
u32 shape = sprite2->oam.shape;
if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE)
{
if (sprite2Y > 128)
sprite2Y = sprite2Y - 256;
}
}
}
}
}
void CopyMatricesToOamBuffer(void)
{
u8 i;
for (i = 0; i < OAM_MATRIX_COUNT; i++)
{ {
u32 base = 4 * i; u32 base = 4 * i;
gMain.oamBuffer[base + 0].affineParam = gOamMatrices[i].a; gMain.oamBuffer[base + 0].affineParam = gOamMatrices[i].a;
@ -479,26 +419,32 @@ void CopyMatricesToOamBuffer(void)
gMain.oamBuffer[base + 2].affineParam = gOamMatrices[i].c; gMain.oamBuffer[base + 2].affineParam = gOamMatrices[i].c;
gMain.oamBuffer[base + 3].affineParam = gOamMatrices[i].d; gMain.oamBuffer[base + 3].affineParam = gOamMatrices[i].d;
} }
}
gMain.oamLoadDisabled = oamLoadDisabled;
sShouldProcessSpriteCopyRequests = TRUE;
} }
void AddSpritesToOamBuffer(void) static inline void InsertionSort(u32 *spritePriorities, s32 n)
{ {
u8 i = 0; s32 i = 1;
u8 oamIndex = 0; while (i < n)
while (i < MAX_SPRITES)
{ {
struct Sprite *sprite = &gSprites[sSpriteOrder[i]]; u32 x = spritePriorities[i];
if (sprite->inUse && !sprite->invisible && AddSpriteToOamBuffer(sprite, &oamIndex)) s32 j = i - 1;
return; while (j >= 0 && spritePriorities[j] > x)
{
spritePriorities[j + 1] = spritePriorities[j];
j--;
}
spritePriorities[j + 1] = x;
i++; i++;
} }
}
while (oamIndex < gOamLimit) static void SortSprites(u32 *spritePriorities, s32 n)
{ {
gMain.oamBuffer[oamIndex] = gDummyOamData; InsertionSort(spritePriorities, n);
oamIndex++;
}
} }
u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority) u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority)
@ -849,7 +795,7 @@ void CopyToSprites(u8 *src)
void ResetAllSprites(void) void ResetAllSprites(void)
{ {
u8 i; u32 i;
for (i = 0; i < MAX_SPRITES; i++) for (i = 0; i < MAX_SPRITES; i++)
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

View File

@ -1,19 +0,0 @@
JASC-PAL
0100
16
230 246 255
82 180 172
82 205 189
156 156 131
106 156 148
123 123 98
189 172 98
189 189 139
74 172 156
172 172 131
74 156 123
115 115 82
139 139 106
164 164 115
197 197 148
230 246 255

View File

@ -1,19 +0,0 @@
JASC-PAL
0100
16
230 246 255
246 246 222
230 230 180
139 238 139
246 246 189
197 246 164
246 230 197
230 246 255
230 213 180
205 197 164
148 222 148
222 238 255
139 205 139
213 238 246
222 246 255
213 205 164

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -10,7 +10,7 @@ JASC-PAL
168 144 120 168 144 120
192 192 176 192 192 176
248 248 248 248 248 248
56 48 40 98 82 57
232 64 32 232 64 32
176 24 16 176 24 16
64 56 48 64 56 48

Binary file not shown.

Before

Width:  |  Height:  |  Size: 781 B

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
90 82 82 81 81 93
205 189 189 176 183 186
230 222 222 210 217 219
246 246 238 221 232 233
0 0 0 0 0 0
255 255 255 255 255 255
222 222 246 222 222 246
0 0 0 245 153 185
200 65 142
0 0 0 0 0 0
0 0 0 0 0 0
148 148 148 148 148 148
74 82 74 75 76 83
255 255 255 255 255 255
24 24 24 24 24 24

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
57 65 90 57 65 90
98 115 189 82 101 183
115 139 213 98 146 208
148 180 205 120 182 232
205 238 246 238 160 209
180 197 222 203 238 246
139 205 222 173 196 230
131 180 197 167 217 230
82 98 131 130 167 196
197 197 197 82 90 132
148 139 148 191 200 202
90 90 82 138 138 147
82 83 91
255 255 255 255 255 255
24 24 24 24 24 24

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
57 65 90 58 77 90
98 115 189 66 133 158
115 139 213 59 186 164
148 180 205 170 228 208
205 238 246 238 160 209
180 197 222 148 251 101
139 205 222 67 203 125
131 180 197 123 220 239
82 98 131 112 158 194
197 197 197 72 88 142
148 139 148 175 213 218
90 90 82 110 136 175
77 79 96
255 255 255 255 255 255
24 24 24 24 24 24

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
98 90 90 88 74 115
205 164 189 192 163 204
230 197 222 226 198 231
255 222 255 255 222 255
0 0 0 0 0 0
255 246 65 242 236 110
230 180 32 235 196 76
245 153 185
200 65 151
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 161 116 180
148 148 148 75 66 92
74 82 74
255 255 255 255 255 255
24 24 24 24 24 24

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 B

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
41 82 57 41 82 57
123 82 189 123 82 189
139 115 213 139 115 213
148 180 205 222 84 195
242 156 214
197 180 255 197 180 255
156 156 197 156 156 197
139 205 172 172 221 198
115 164 139 124 182 168
98 74 115 98 74 115
189 230 230 214 245 229
82 115 106 83 113 116
74 82 74 75 83 81
255 255 255 255 255 255
24 24 24 24 24 24

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
41 82 57 41 41 81
123 82 189 88 81 189
139 115 213 103 164 224
148 180 205 222 84 195
197 180 255 242 156 214
156 156 197 246 255 178
139 205 172 211 198 141
115 164 139 170 201 212
98 74 115 153 160 168
189 230 230 74 74 115
82 115 106 200 234 234
110 120 135
74 82 74 74 82 74
255 255 255 255 255 255
24 24 24 24 24 24

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 553 B

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 607 B

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
98 49 41 98 49 41
205 90 74 206 75 75
238 123 74 238 101 73
255 156 65 255 163 77
0 0 0 245 151 182
255 246 106 255 246 106
230 213 106 234 196 83
255 156 98 255 192 66
213 131 74 222 128 33
148 90 65 135 76 59
213 205 230 206 210 222
90 90 82 228 238 242
87 82 91
255 255 255 255 255 255
24 24 24 24 24 24

View File

@ -1,19 +1,19 @@
JASC-PAL JASC-PAL
0100 0100
16 16
248 160 176
197 197 148 197 197 148
98 49 41 98 49 41
205 90 74 191 64 100
238 123 74 238 73 103
255 156 65 255 122 122
0 0 0 245 151 182
255 246 106 255 165 133
230 213 106 230 107 107
255 156 98 255 206 107
213 131 74 222 138 63
148 90 65 148 90 65
213 205 230 213 174 214
238 211 231
90 90 82 90 90 82
255 255 255 255 255 255
24 24 24 24 24 24

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 759 B

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

View File

@ -15,5 +15,5 @@ JASC-PAL
144 56 80 144 56 80
72 72 112 72 72 112
168 56 80 168 56 80
0 0 0 255 255 255
0 0 0 0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 712 B

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 794 B

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 906 B

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 B

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Some files were not shown because too many files have changed in this diff Show More