Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-expansion into gen_9_move_effects_batch2

This commit is contained in:
LOuroboros 2023-06-13 05:44:37 -03:00
commit 313f522622
1169 changed files with 16530 additions and 7951 deletions

View File

@ -50,6 +50,8 @@ jobs:
run: make -j${nproc} -O all run: make -j${nproc} -O all
- name: Test - name: Test
env:
TEST: 1
run: | run: |
make -j${nproc} -O pokeemerald-test.elf make -j${nproc} -O pokeemerald-test.elf
make -j${nproc} check make -j${nproc} check

16
.github/workflows/manual.yml vendored Normal file
View File

@ -0,0 +1,16 @@
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

@ -41,11 +41,16 @@ GAME_CODE := BPEE
MAKER_CODE := 01 MAKER_CODE := 01
REVISION := 0 REVISION := 0
MODERN ?= 0 MODERN ?= 0
TEST ?= 0
ifeq (modern,$(MAKECMDGOALS)) ifeq (modern,$(MAKECMDGOALS))
MODERN := 1 MODERN := 1
endif endif
ifeq (check,$(MAKECMDGOALS))
TEST := 1
endif
# use arm-none-eabi-cpp for macOS # use arm-none-eabi-cpp for macOS
# as macOS's default compiler is clang # as macOS's default compiler is clang
# and clang's preprocessor will warn on \u # and clang's preprocessor will warn on \u
@ -79,6 +84,7 @@ ELF = $(ROM:.gba=.elf)
MAP = $(ROM:.gba=.map) MAP = $(ROM:.gba=.map)
SYM = $(ROM:.gba=.sym) SYM = $(ROM:.gba=.sym)
TEST_OBJ_DIR_NAME := build/test
TESTELF = $(ROM:.gba=-test.elf) TESTELF = $(ROM:.gba=-test.elf)
HEADLESSELF = $(ROM:.gba=-test-headless.elf) HEADLESSELF = $(ROM:.gba=-test-headless.elf)
@ -119,7 +125,15 @@ LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a)
LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall
endif endif
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) ifeq ($(TESTELF),$(MAKECMDGOALS))
TEST := 1
endif
ifeq ($(TEST),1)
OBJ_DIR := $(TEST_OBJ_DIR_NAME)
endif
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -DTESTING=$(TEST)
ifneq ($(MODERN),1) ifneq ($(MODERN),1)
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef
endif endif
@ -168,7 +182,7 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst
# Disable dependency scanning for clean/tidy/tools # Disable dependency scanning for clean/tidy/tools
# Use a separate minimal makefile for speed # Use a separate minimal makefile for speed
# Since we don't need to reload most of this makefile # Since we don't need to reload most of this makefile
ifeq (,$(filter-out all rom compare modern check libagbsyscall syms,$(MAKECMDGOALS))) ifeq (,$(filter-out all rom compare modern check libagbsyscall syms $(TESTELF),$(MAKECMDGOALS)))
$(call infoshell, $(MAKE) -f make_tools.mk) $(call infoshell, $(MAKE) -f make_tools.mk)
else else
NODEP ?= 1 NODEP ?= 1
@ -178,9 +192,9 @@ endif
ifeq (,$(MAKECMDGOALS)) ifeq (,$(MAKECMDGOALS))
SCAN_DEPS ?= 1 SCAN_DEPS ?= 1
else else
# clean, tidy, tools, check-tools, mostlyclean, clean-tools, clean-check-tools, $(TOOLDIRS), $(CHECKTOOLDIRS), tidymodern, tidynonmodern don't even build the ROM # clean, tidy, tools, check-tools, mostlyclean, clean-tools, clean-check-tools, $(TOOLDIRS), $(CHECKTOOLDIRS), tidymodern, tidynonmodern, tidycheck don't even build the ROM
# libagbsyscall does its own thing # libagbsyscall does its own thing
ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) clean-check-tools $(CHECKTOOLDIRS) tidymodern tidynonmodern libagbsyscall,$(MAKECMDGOALS))) ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) clean-check-tools $(CHECKTOOLDIRS) tidymodern tidynonmodern tidycheck libagbsyscall,$(MAKECMDGOALS)))
SCAN_DEPS ?= 0 SCAN_DEPS ?= 0
else else
SCAN_DEPS ?= 1 SCAN_DEPS ?= 1
@ -257,7 +271,7 @@ clean-tools:
clean-check-tools: clean-check-tools:
@$(foreach tooldir,$(CHECKTOOLDIRS),$(MAKE) clean -C $(tooldir);) @$(foreach tooldir,$(CHECKTOOLDIRS),$(MAKE) clean -C $(tooldir);)
mostlyclean: tidynonmodern tidymodern mostlyclean: tidynonmodern tidymodern tidycheck
rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(SAMPLE_SUBDIR)/*.bin
rm -f $(CRY_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin
rm -f $(MID_SUBDIR)/*.s rm -f $(MID_SUBDIR)/*.s
@ -268,7 +282,7 @@ mostlyclean: tidynonmodern tidymodern
rm -f $(AUTO_GEN_TARGETS) rm -f $(AUTO_GEN_TARGETS)
@$(MAKE) clean -C libagbsyscall @$(MAKE) clean -C libagbsyscall
tidy: tidynonmodern tidymodern tidy: tidynonmodern tidymodern tidycheck
tidynonmodern: tidynonmodern:
rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME) rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
@ -278,6 +292,10 @@ tidymodern:
rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME) rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME)
rm -rf $(MODERN_OBJ_DIR_NAME) rm -rf $(MODERN_OBJ_DIR_NAME)
tidycheck:
rm -f $(TESTELF) $(HEADLESSELF)
rm -rf $(TEST_OBJ_DIR_NAME)
ifneq ($(MODERN),0) ifneq ($(MODERN),0)
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
endif endif
@ -480,7 +498,7 @@ endif
check: $(TESTELF) check: $(TESTELF)
@cp $< $(HEADLESSELF) @cp $< $(HEADLESSELF)
$(PATCHELF) $(HEADLESSELF) gTestRunnerHeadless '\x01' gTestRunnerSkipIsFail "$(TEST_SKIP_IS_FAIL)" $(PATCHELF) $(HEADLESSELF) gTestRunnerHeadless '\x01' gTestRunnerSkipIsFail "$(TEST_SKIP_IS_FAIL)"
$(ROMTESTHYDRA) $(ROMTEST) $(HEADLESSELF) $(ROMTESTHYDRA) $(ROMTEST) $(OBJCOPY) $(HEADLESSELF)
libagbsyscall: libagbsyscall:
@$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN) @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)

View File

@ -332,57 +332,3 @@
createvisualtask AnimTask_IsDoubleBattle, 0 createvisualtask AnimTask_IsDoubleBattle, 0
jumprettrue \ptr jumprettrue \ptr
.endm .endm
@ keep CFRU macros cause I'm lazy. todo: update to createsprite and createvisualtask, respectively
.macro launchtemplate launchtemplatePtr launchtemplatePriority launchtemplateArgsNo launchtemplatearg0 launchtemplatearg1 launchtemplatearg2 launchtemplatearg3 launchtemplatearg4 launchtemplatearg5 launchtemplatearg6 launchtemplatearg7 launchtemplatearg8
.byte 0x2
.word \launchtemplatePtr
.byte \launchtemplatePriority
.byte \launchtemplateArgsNo
.hword \launchtemplatearg0
.hword \launchtemplatearg1
.hword \launchtemplatearg2
.hword \launchtemplatearg3
.hword \launchtemplatearg4
.hword \launchtemplatearg5
.hword \launchtemplatearg6
.hword \launchtemplatearg7
.hword \launchtemplatearg8
.endm
.macro launchtask launchtaskPtr launchtaskPriority launchtaskArgsNo launchtaskarg0 launchtaskarg1 launchtaskarg2 launchtaskarg3 launchtaskarg4 launchtaskarg5 launchtaskarg6 launchtaskarg7 launchtaskarg8
.byte 0x3
.word \launchtaskPtr
.byte \launchtaskPriority
.byte \launchtaskArgsNo
.hword \launchtaskarg0
.hword \launchtaskarg1
.hword \launchtaskarg2
.hword \launchtaskarg3
.hword \launchtaskarg4
.hword \launchtaskarg5
.hword \launchtaskarg6
.hword \launchtaskarg7
.hword \launchtaskarg8
.endm
.macro setblends setblends_value
.byte 0xC
.hword \setblends_value
.endm
.macro launchsoundtask launchsoundtaskPtr launchsoundtaskArgsNo launchsoundtaskarg0 launchsoundtaskarg1 launchsoundtaskarg2 launchsoundtaskarg3 launchsoundtaskarg4 launchsoundtaskarg5 launchsoundtaskarg6 launchsoundtaskarg7 launchsoundtaskarg8
.byte 0x1F
.word \launchsoundtaskPtr
.byte \launchsoundtaskArgsNo
.hword \launchsoundtaskarg0
.hword \launchsoundtaskarg1
.hword \launchsoundtaskarg2
.hword \launchsoundtaskarg3
.hword \launchsoundtaskarg4
.hword \launchsoundtaskarg5
.hword \launchsoundtaskarg6
.hword \launchsoundtaskarg7
.hword \launchsoundtaskarg8
.endm

View File

@ -1346,6 +1346,41 @@
callnative BS_ItemRestorePP callnative BS_ItemRestorePP
.endm .endm
.macro tryrevertweatherform
callnative BS_TryRevertWeatherForm
.endm
.macro setsnow
callnative BS_SetSnow
.endm
.macro setzeffect
callnative BS_SetZEffect
.endm
@ Used by effects that may proc Symbiosis but do not call removeitem.
.macro trysymbiosis
callnative BS_TrySymbiosis
.endm
@ returns TRUE or FALSE to gBattleCommunication[0]
.macro canteleport battler:req
callnative BS_CanTeleport
.byte \battler
.endm
@ returns B_SIDE_x to gBattleCommunication[0]
.macro getbattlerside battler:req
callnative BS_GetBattlerSide
.byte \battler
.endm
.macro checkparentalbondcounter counter:req, ptr:req
callnative BS_CheckParentalBondCounter
.byte \counter
.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
@ -1831,10 +1866,6 @@
various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH
.endm .endm
.macro setzeffect
various BS_ATTACKER, VARIOUS_SET_Z_EFFECT
.endm
.macro consumeberry battler:req, fromBattler:req .macro consumeberry battler:req, fromBattler:req
various \battler, VARIOUS_CONSUME_BERRY various \battler, VARIOUS_CONSUME_BERRY
.byte \fromBattler .byte \fromBattler
@ -2045,20 +2076,7 @@
.macro swapsidestatuses .macro swapsidestatuses
various BS_ATTACKER, VARIOUS_SWAP_SIDE_STATUSES various BS_ATTACKER, VARIOUS_SWAP_SIDE_STATUSES
.endm .endm
.macro canteleport battler:req
various \battler, VARIOUS_CAN_TELEPORT
.endm
.macro getbattlerside battler:req
various \battler, VARIOUS_GET_BATTLER_SIDE
.endm
.macro checkparentalbondcounter counter:req, jumpInstr:req
various BS_ATTACKER, VARIOUS_CHECK_PARENTAL_BOND_COUNTER
.byte \counter
.4byte \jumpInstr
.endm
.macro swapstats stat:req .macro swapstats stat:req
various BS_ATTACKER, VARIOUS_SWAP_STATS various BS_ATTACKER, VARIOUS_SWAP_STATS
.byte \stat .byte \stat
@ -2077,6 +2095,14 @@
various \battler, VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES various \battler, VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES
.endm .endm
.macro trytrainerslidezmovemsg battler:req
various \battler, VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE
.endm
.macro trytrainerslidemegaevolutionmsg battler:req
various \battler, VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION
.endm
@ helpful macros @ helpful macros
.macro setstatchanger stat:req, stages:req, down:req .macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7 setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7
@ -2230,11 +2256,6 @@
various 0, VARIOUS_SKY_DROP_YAWN various 0, VARIOUS_SKY_DROP_YAWN
.endm .endm
@ Used by effects that may proc Symbiosis but do not call removeitem.
.macro trysymbiosis
various BS_ATTACKER, VARIOUS_TRY_SYMBIOSIS
.endm
@ Tries to increase or decrease a battler's stat's stat stage by a specified amount. If impossible, jumps to \script. @ Tries to increase or decrease a battler's stat's stat stage by a specified amount. If impossible, jumps to \script.
.macro modifybattlerstatstage battler:req, stat:req, mode:req, amount:req, script:req, animation:req, customString .macro modifybattlerstatstage battler:req, stat:req, mode:req, amount:req, script:req, animation:req, customString

File diff suppressed because it is too large Load Diff

View File

@ -286,7 +286,11 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectHealPulse @ EFFECT_HEAL_PULSE .4byte BattleScript_EffectHealPulse @ EFFECT_HEAL_PULSE
.4byte BattleScript_EffectQuash @ EFFECT_QUASH .4byte BattleScript_EffectQuash @ EFFECT_QUASH
.4byte BattleScript_EffectIonDeluge @ EFFECT_ION_DELUGE .4byte BattleScript_EffectIonDeluge @ EFFECT_ION_DELUGE
#if B_USE_FROSTBITE == TRUE
.4byte BattleScript_EffectFrostbiteHit @ EFFECT_FREEZE_DRY
#else
.4byte BattleScript_EffectFreezeHit @ EFFECT_FREEZE_DRY .4byte BattleScript_EffectFreezeHit @ EFFECT_FREEZE_DRY
#endif
.4byte BattleScript_EffectTopsyTurvy @ EFFECT_TOPSY_TURVY .4byte BattleScript_EffectTopsyTurvy @ EFFECT_TOPSY_TURVY
.4byte BattleScript_EffectMistyTerrain @ EFFECT_MISTY_TERRAIN .4byte BattleScript_EffectMistyTerrain @ EFFECT_MISTY_TERRAIN
.4byte BattleScript_EffectGrassyTerrain @ EFFECT_GRASSY_TERRAIN .4byte BattleScript_EffectGrassyTerrain @ EFFECT_GRASSY_TERRAIN
@ -424,6 +428,8 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectDireClaw @ EFFECT_DIRE_CLAW .4byte BattleScript_EffectDireClaw @ EFFECT_DIRE_CLAW
.4byte BattleScript_EffectBarbBarrage @ EFFECT_BARB_BARRAGE .4byte BattleScript_EffectBarbBarrage @ EFFECT_BARB_BARRAGE
.4byte BattleScript_EffectRevivalBlessing @ EFFECT_REVIVAL_BLESSING .4byte BattleScript_EffectRevivalBlessing @ EFFECT_REVIVAL_BLESSING
.4byte BattleScript_EffectFrostbiteHit @ EFFECT_FROSTBITE_HIT
.4byte BattleScript_EffectSnow @ EFFECT_SNOWSCAPE
.4byte BattleScript_EffectTripleArrows @ EFFECT_TRIPLE_ARROWS .4byte BattleScript_EffectTripleArrows @ EFFECT_TRIPLE_ARROWS
.4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE .4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE
.4byte BattleScript_EffectTakeHeart @ EFFECT_TAKE_HEART .4byte BattleScript_EffectTakeHeart @ EFFECT_TAKE_HEART
@ -506,9 +512,9 @@ BattleScript_EffectRevivalBlessing::
attackcanceler attackcanceler
attackstring attackstring
ppreduce ppreduce
tryrevivalblessing BattleScript_ButItFailed
attackanimation attackanimation
waitanimation waitanimation
tryrevivalblessing BattleScript_ButItFailed
printstring STRINGID_PKMNREVIVEDREADYTOFIGHT printstring STRINGID_PKMNREVIVEDREADYTOFIGHT
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_EffectRevivalBlessingSendOut jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_EffectRevivalBlessingSendOut
@ -524,7 +530,7 @@ BattleScript_StealthRockActivates::
setstealthrock BattleScript_MoveEnd setstealthrock BattleScript_MoveEnd
printfromtable gDmgHazardsStringIds printfromtable gDmgHazardsStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd return
BattleScript_EffectDireClaw:: BattleScript_EffectDireClaw::
setmoveeffect MOVE_EFFECT_DIRE_CLAW setmoveeffect MOVE_EFFECT_DIRE_CLAW
@ -538,7 +544,7 @@ BattleScript_SpikesActivates::
trysetspikes BattleScript_MoveEnd trysetspikes BattleScript_MoveEnd
printfromtable gDmgHazardsStringIds printfromtable gDmgHazardsStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd return
BattleScript_EffectAttackUpUserAlly: BattleScript_EffectAttackUpUserAlly:
jumpifnoally BS_ATTACKER, BattleScript_EffectAttackUp jumpifnoally BS_ATTACKER, BattleScript_EffectAttackUp
@ -653,6 +659,7 @@ BattleScript_AffectionBasedStatusHeal::
jumpifstatus BS_ATTACKER, STATUS1_PARALYSIS, BattleScript_AffectionBasedStatus_HealParalysisString jumpifstatus BS_ATTACKER, STATUS1_PARALYSIS, BattleScript_AffectionBasedStatus_HealParalysisString
jumpifstatus BS_ATTACKER, STATUS1_BURN, BattleScript_AffectionBasedStatus_HealBurnString jumpifstatus BS_ATTACKER, STATUS1_BURN, BattleScript_AffectionBasedStatus_HealBurnString
jumpifstatus BS_ATTACKER, STATUS1_FREEZE, BattleScript_AffectionBasedStatus_HealFreezeString jumpifstatus BS_ATTACKER, STATUS1_FREEZE, BattleScript_AffectionBasedStatus_HealFreezeString
jumpifstatus BS_ATTACKER, STATUS1_FROSTBITE, BattleScript_AffectionBasedStatus_HealFrostbiteString
end2 end2
BattleScript_AffectionBasedStatus_HealPoisonString: BattleScript_AffectionBasedStatus_HealPoisonString:
printstring STRINGID_ATTACKEREXPELLEDTHEPOISON printstring STRINGID_ATTACKEREXPELLEDTHEPOISON
@ -668,6 +675,9 @@ BattleScript_AffectionBasedStatus_HealBurnString:
goto BattleScript_AffectionBasedStatusHeal_Continue goto BattleScript_AffectionBasedStatusHeal_Continue
BattleScript_AffectionBasedStatus_HealFreezeString: BattleScript_AffectionBasedStatus_HealFreezeString:
printstring STRINGID_ATTACKERMELTEDTHEICE printstring STRINGID_ATTACKERMELTEDTHEICE
goto BattleScript_AffectionBasedStatusHeal_Continue
BattleScript_AffectionBasedStatus_HealFrostbiteString:
printstring STRINGID_ATTACKERHEALEDITSFROSTBITE
BattleScript_AffectionBasedStatusHeal_Continue: BattleScript_AffectionBasedStatusHeal_Continue:
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
clearstatus BS_ATTACKER clearstatus BS_ATTACKER
@ -682,7 +692,7 @@ BattleScript_ShellTrapSetUp::
playanimation BS_ATTACKER, B_ANIM_SHELL_TRAP_SETUP, NULL playanimation BS_ATTACKER, B_ANIM_SHELL_TRAP_SETUP, NULL
printstring STRINGID_PREPARESHELLTRAP printstring STRINGID_PREPARESHELLTRAP
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
end2 end3
BattleScript_EffectShellTrap:: BattleScript_EffectShellTrap::
attackcanceler attackcanceler
@ -756,7 +766,7 @@ BattleScript_BeakBlastSetUp::
playanimation BS_ATTACKER, B_ANIM_BEAK_BLAST_SETUP, NULL playanimation BS_ATTACKER, B_ANIM_BEAK_BLAST_SETUP, NULL
printstring STRINGID_HEATUPBEAK printstring STRINGID_HEATUPBEAK
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
end2 end3
BattleScript_BeakBlastBurn:: BattleScript_BeakBlastBurn::
setbyte cMULTISTRING_CHOOSER, 0 setbyte cMULTISTRING_CHOOSER, 0
@ -1521,8 +1531,9 @@ BattleScript_EffectBurnUp:
goto BattleScript_ButItFailed goto BattleScript_ButItFailed
BattleScript_BurnUpWorks: BattleScript_BurnUpWorks:
setmoveeffect MOVE_EFFECT_BURN_UP | MOVE_EFFECT_CERTAIN setmoveeffect MOVE_EFFECT_BURN_UP | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
goto BattleScript_EffectHit accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
goto BattleScript_HitFromCritCalc
BattleScript_BurnUpRemoveType:: BattleScript_BurnUpRemoveType::
losetype BS_ATTACKER, TYPE_FIRE losetype BS_ATTACKER, TYPE_FIRE
@ -1538,8 +1549,9 @@ BattleScript_EffectDoubleShock:
goto BattleScript_ButItFailed goto BattleScript_ButItFailed
BattleScript_DoubleShockWorks: BattleScript_DoubleShockWorks:
setmoveeffect MOVE_EFFECT_DOUBLE_SHOCK | MOVE_EFFECT_CERTAIN setmoveeffect MOVE_EFFECT_DOUBLE_SHOCK | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
goto BattleScript_EffectHit accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
goto BattleScript_HitFromCritCalc
BattleScript_DoubleShockRemoveType:: BattleScript_DoubleShockRemoveType::
losetype BS_ATTACKER, TYPE_ELECTRIC losetype BS_ATTACKER, TYPE_ELECTRIC
@ -1659,6 +1671,7 @@ BattleScript_MoveEffectCoreEnforcer::
printstring STRINGID_PKMNSABILITYSUPPRESSED printstring STRINGID_PKMNSABILITYSUPPRESSED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
trytoclearprimalweather trytoclearprimalweather
tryrevertweatherform
printstring STRINGID_EMPTYSTRING3 printstring STRINGID_EMPTYSTRING3
waitmessage 1 waitmessage 1
BattleScript_CoreEnforcerRet: BattleScript_CoreEnforcerRet:
@ -2807,6 +2820,7 @@ BattleScript_EffectSimpleBeam:
printstring STRINGID_PKMNACQUIREDSIMPLE printstring STRINGID_PKMNACQUIREDSIMPLE
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
trytoclearprimalweather trytoclearprimalweather
tryrevertweatherform
printstring STRINGID_EMPTYSTRING3 printstring STRINGID_EMPTYSTRING3
waitmessage 1 waitmessage 1
tryendneutralizinggas BS_TARGET tryendneutralizinggas BS_TARGET
@ -2906,6 +2920,7 @@ BattleScript_EffectWorrySeed:
printstring STRINGID_PKMNACQUIREDABILITY printstring STRINGID_PKMNACQUIREDABILITY
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
trytoclearprimalweather trytoclearprimalweather
tryrevertweatherform
printstring STRINGID_EMPTYSTRING3 printstring STRINGID_EMPTYSTRING3
waitmessage 1 waitmessage 1
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -3037,6 +3052,7 @@ BattleScript_EffectGastroAcid:
printstring STRINGID_PKMNSABILITYSUPPRESSED printstring STRINGID_PKMNSABILITYSUPPRESSED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
trytoclearprimalweather trytoclearprimalweather
tryrevertweatherform
printstring STRINGID_EMPTYSTRING3 printstring STRINGID_EMPTYSTRING3
waitmessage 1 waitmessage 1
tryendneutralizinggas BS_TARGET tryendneutralizinggas BS_TARGET
@ -3555,6 +3571,10 @@ BattleScript_EffectBurnHit::
setmoveeffect MOVE_EFFECT_BURN setmoveeffect MOVE_EFFECT_BURN
goto BattleScript_EffectHit goto BattleScript_EffectHit
BattleScript_EffectFrostbiteHit::
setmoveeffect MOVE_EFFECT_FROSTBITE
goto BattleScript_EffectHit
BattleScript_EffectSleepHit:: BattleScript_EffectSleepHit::
setmoveeffect MOVE_EFFECT_SLEEP setmoveeffect MOVE_EFFECT_SLEEP
goto BattleScript_EffectHit goto BattleScript_EffectHit
@ -4060,6 +4080,9 @@ BattleScript_EffectRest::
jumpifuproarwakes BattleScript_RestCantSleep jumpifuproarwakes BattleScript_RestCantSleep
jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_InsomniaProtects jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_InsomniaProtects
jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_InsomniaProtects jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_InsomniaProtects
.if B_LEAF_GUARD_PREVENTS_REST >= GEN_5
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardPreventsRest
.endif
trysetrest BattleScript_AlreadyAtFullHp trysetrest BattleScript_AlreadyAtFullHp
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
printfromtable gRestUsedStringIds printfromtable gRestUsedStringIds
@ -4081,6 +4104,12 @@ BattleScript_RestIsAlreadyAsleep::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_LeafGuardPreventsRest::
pause B_WAIT_TIME_SHORT
printstring STRINGID_BUTITFAILED
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_EffectOHKO:: BattleScript_EffectOHKO::
attackcanceler attackcanceler
attackstring attackstring
@ -5265,7 +5294,7 @@ BattleScript_MoveWeatherChange::
waitanimation waitanimation
printfromtable gMoveWeatherChangeStringIds printfromtable gMoveWeatherChangeStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectSunnyDay:: BattleScript_EffectSunnyDay::
@ -6915,10 +6944,11 @@ BattleScript_RainContinuesOrEnds::
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainContinuesOrEndsEnd jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainContinuesOrEndsEnd
playanimation BS_ATTACKER, B_ANIM_RAIN_CONTINUES playanimation BS_ATTACKER, B_ANIM_RAIN_CONTINUES
BattleScript_RainContinuesOrEndsEnd:: BattleScript_RainContinuesOrEndsEnd::
call BattleScript_ActivateWeatherAbilities
end2 end2
BattleScript_DamagingWeatherContinues:: BattleScript_DamagingWeatherContinues::
printfromtable gSandStormHailContinuesStringIds printfromtable gSandStormHailSnowContinuesStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
playanimation_var BS_ATTACKER, sB_ANIM_ARG1 playanimation_var BS_ATTACKER, sB_ANIM_ARG1
setbyte gBattleCommunication, 0 setbyte gBattleCommunication, 0
@ -6948,29 +6978,33 @@ BattleScript_DamagingWeatherLoopIncrement::
jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop
BattleScript_DamagingWeatherContinuesEnd:: BattleScript_DamagingWeatherContinuesEnd::
bicword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE bicword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE
call BattleScript_ActivateWeatherAbilities
end2 end2
BattleScript_SandStormHailEnds:: BattleScript_SandStormHailSnowEnds::
printfromtable gSandStormHailEndStringIds printfromtable gSandStormHailSnowEndStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
end2 end2
BattleScript_SunlightContinues:: BattleScript_SunlightContinues::
printstring STRINGID_SUNLIGHTSTRONG printstring STRINGID_SUNLIGHTSTRONG
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
playanimation BS_ATTACKER, B_ANIM_SUN_CONTINUES playanimation BS_ATTACKER, B_ANIM_SUN_CONTINUES
call BattleScript_ActivateWeatherAbilities
end2 end2
BattleScript_SunlightFaded:: BattleScript_SunlightFaded::
printstring STRINGID_SUNLIGHTFADED printstring STRINGID_SUNLIGHTFADED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
call BattleScript_ActivateWeatherAbilities
end2 end2
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_ATTACKER, sB_ANIM_ARG1
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_OverworldTerrain:: BattleScript_OverworldTerrain::
@ -7036,8 +7070,6 @@ BattleScript_MagicRoomEnds::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
end2 end2
BattleScript_GrassyTerrainEnds:
setbyte cMULTISTRING_CHOOSER, B_MSG_TERRAINENDS_GRASS
BattleScript_TerrainEnds_Ret:: BattleScript_TerrainEnds_Ret::
printfromtable gTerrainEndingStringIds printfromtable gTerrainEndingStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
@ -7240,8 +7272,10 @@ BattleScript_MistProtected::
return return
BattleScript_RageIsBuilding:: BattleScript_RageIsBuilding::
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_RageIsBuildingEnd
printstring STRINGID_PKMNRAGEBUILDING printstring STRINGID_PKMNRAGEBUILDING
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
BattleScript_RageIsBuildingEnd:
return return
BattleScript_MoveUsedIsDisabled:: BattleScript_MoveUsedIsDisabled::
@ -7960,26 +7994,29 @@ BattleScript_FocusPunchSetUp::
playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP
printstring STRINGID_PKMNTIGHTENINGFOCUS printstring STRINGID_PKMNTIGHTENINGFOCUS
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
end2 end3
BattleScript_MegaEvolution:: BattleScript_MegaEvolution::
printstring STRINGID_EMPTYSTRING3
trytrainerslidemegaevolutionmsg BS_ATTACKER
printstring STRINGID_MEGAEVOREACTING printstring STRINGID_MEGAEVOREACTING
BattleScript_MegaEvolutionAfeterString: BattleScript_MegaEvolutionAfterString:
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
setbyte gIsCriticalHit, 0 setbyte gIsCriticalHit, 0
handlemegaevo BS_ATTACKER, 0 handlemegaevo BS_ATTACKER, 0
handlemegaevo BS_ATTACKER, 1
playanimation BS_ATTACKER, B_ANIM_MEGA_EVOLUTION playanimation BS_ATTACKER, B_ANIM_MEGA_EVOLUTION
waitanimation waitanimation
handlemegaevo BS_ATTACKER, 2 handlemegaevo BS_ATTACKER, 1
printstring STRINGID_MEGAEVOEVOLVED printstring STRINGID_MEGAEVOEVOLVED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
switchinabilities BS_ATTACKER switchinabilities BS_ATTACKER
end2 end3
BattleScript_WishMegaEvolution:: BattleScript_WishMegaEvolution::
printstring STRINGID_EMPTYSTRING3
trytrainerslidemegaevolutionmsg BS_ATTACKER
printstring STRINGID_FERVENTWISHREACHED printstring STRINGID_FERVENTWISHREACHED
goto BattleScript_MegaEvolutionAfeterString goto BattleScript_MegaEvolutionAfterString
BattleScript_PrimalReversion:: BattleScript_PrimalReversion::
printstring STRINGID_EMPTYSTRING3 printstring STRINGID_EMPTYSTRING3
@ -8028,6 +8065,7 @@ BattleScript_AttackerFormChangeEnd3::
BattleScript_AttackerFormChangeEnd3NoPopup:: BattleScript_AttackerFormChangeEnd3NoPopup::
call BattleScript_AttackerFormChangeNoPopup call BattleScript_AttackerFormChangeNoPopup
end3
BattleScript_AttackerFormChangeMoveEffect:: BattleScript_AttackerFormChangeMoveEffect::
waitmessage 1 waitmessage 1
@ -8058,9 +8096,7 @@ BattleScript_CudChewActivates::
setbyte sBERRY_OVERRIDE, 0 setbyte sBERRY_OVERRIDE, 0
end3 end3
BattleScript_TargetFormChange:: BattleScript_TargetFormChangeNoPopup:
pause 5
call BattleScript_AbilityPopUpTarget
printstring STRINGID_EMPTYSTRING3 printstring STRINGID_EMPTYSTRING3
waitmessage 1 waitmessage 1
handleformchange BS_TARGET, 0 handleformchange BS_TARGET, 0
@ -8070,16 +8106,22 @@ BattleScript_TargetFormChange::
handleformchange BS_TARGET, 2 handleformchange BS_TARGET, 2
return return
BattleScript_TargetFormChange::
pause 5
call BattleScript_AbilityPopUpTarget
call BattleScript_TargetFormChangeNoPopup
return
BattleScript_TargetFormChangeWithString:: BattleScript_TargetFormChangeWithString::
pause 5 pause 5
call BattleScript_AbilityPopUpTarget call BattleScript_AbilityPopUpTarget
printstring STRINGID_EMPTYSTRING3 call BattleScript_TargetFormChangeNoPopup
waitmessage 1 printstring STRINGID_PKMNTRANSFORMED
handleformchange BS_TARGET, 0 waitmessage B_WAIT_TIME_LONG
handleformchange BS_TARGET, 1 return
playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL
waitanimation BattleScript_TargetFormChangeWithStringNoPopup::
handleformchange BS_TARGET, 2 call BattleScript_TargetFormChangeNoPopup
printstring STRINGID_PKMNTRANSFORMED printstring STRINGID_PKMNTRANSFORMED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
return return
@ -8213,6 +8255,11 @@ BattleScript_BurnTurnDmg::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_DoStatusTurnDmg goto BattleScript_DoStatusTurnDmg
BattleScript_FrostbiteTurnDmg::
printstring STRINGID_PKMNHURTBYFROSTBITE
waitmessage B_WAIT_TIME_LONG
goto BattleScript_DoStatusTurnDmg
BattleScript_MoveUsedIsFrozen:: BattleScript_MoveUsedIsFrozen::
printstring STRINGID_PKMNISFROZEN printstring STRINGID_PKMNISFROZEN
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
@ -8225,12 +8272,24 @@ BattleScript_MoveUsedUnfroze::
updatestatusicon BS_ATTACKER updatestatusicon BS_ATTACKER
return return
BattleScript_MoveUsedUnfrostbite::
printfromtable gFrostbiteHealedStringIds
waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_ATTACKER
return
BattleScript_DefrostedViaFireMove:: BattleScript_DefrostedViaFireMove::
printstring STRINGID_PKMNWASDEFROSTED printstring STRINGID_PKMNWASDEFROSTED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_TARGET updatestatusicon BS_TARGET
return return
BattleScript_FrostbiteHealedViaFireMove::
printstring STRINGID_PKMNFROSTBITEHEALED
waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_TARGET
return
BattleScript_MoveUsedIsParalyzed:: BattleScript_MoveUsedIsParalyzed::
printstring STRINGID_PKMNISPARALYZED printstring STRINGID_PKMNISPARALYZED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
@ -8452,6 +8511,12 @@ BattleScript_MoveEffectBurn::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_UpdateEffectStatusIconRet goto BattleScript_UpdateEffectStatusIconRet
BattleScript_MoveEffectFrostbite::
statusanimation BS_EFFECT_BATTLER
printfromtable gGotFrostbiteStringIds
waitmessage B_WAIT_TIME_LONG
goto BattleScript_UpdateEffectStatusIconRet
BattleScript_MoveEffectFreeze:: BattleScript_MoveEffectFreeze::
statusanimation BS_EFFECT_BATTLER statusanimation BS_EFFECT_BATTLER
printfromtable gGotFrozenStringIds printfromtable gGotFrozenStringIds
@ -8522,7 +8587,7 @@ BattleScript_DrizzleActivates::
printstring STRINGID_PKMNMADEITRAIN printstring STRINGID_PKMNMADEITRAIN
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_AbilityRaisesDefenderStat:: BattleScript_AbilityRaisesDefenderStat::
@ -8547,10 +8612,13 @@ BattleScript_AbilityPopUp:
return return
BattleScript_SpeedBoostActivates:: BattleScript_SpeedBoostActivates::
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_SpeedBoostActivatesEnd
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
printstring STRINGID_PKMNRAISEDSPEED printstring STRINGID_PKMNRAISEDSPEED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
BattleScript_SpeedBoostActivatesEnd:
end3 end3
@ Can't compare directly to a value, have to compare to value at pointer @ Can't compare directly to a value, have to compare to value at pointer
@ -8684,7 +8752,7 @@ BattleScript_SandstreamActivates::
printstring STRINGID_PKMNSXWHIPPEDUPSANDSTORM printstring STRINGID_PKMNSXWHIPPEDUPSANDSTORM
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_SandSpitActivates:: BattleScript_SandSpitActivates::
@ -8693,7 +8761,7 @@ BattleScript_SandSpitActivates::
printstring STRINGID_ASANDSTORMKICKEDUP printstring STRINGID_ASANDSTORMKICKEDUP
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
return return
BattleScript_ShedSkinActivates:: BattleScript_ShedSkinActivates::
@ -8703,37 +8771,16 @@ BattleScript_ShedSkinActivates::
updatestatusicon BS_ATTACKER updatestatusicon BS_ATTACKER
end3 end3
BattleScript_WeatherFormChanges:: BattleScript_ActivateWeatherAbilities:
setbyte sBATTLER, 0 savetarget
BattleScript_WeatherFormChangesLoop:: setbyte gBattlerTarget, 0
tryweatherformdatachange BattleScript_ActivateWeatherAbilities_Loop:
activateweatherchangeabilities BS_SCRIPTING copybyte sBATTLER, gBattlerTarget
addbyte sBATTLER, 1 activateweatherchangeabilities BS_TARGET
jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_WeatherFormChangesLoop BattleScript_ActivateWeatherAbilities_Increment:
return addbyte gBattlerTarget, 1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_ActivateWeatherAbilities_Loop
BattleScript_WeatherFormChange:: restoretarget
call BattleScript_DoWeatherFormChange
end3
BattleScript_DoWeatherFormChange::
copybyte gBattlerAbility, sBATTLER
.if B_WEATHER_FORMS >= GEN_5
jumpifspecies BS_SCRIPTING, SPECIES_CASTFORM, BattleScript_DoWeatherFormChange_ForecastCheck
BattleScript_DoWeatherFormChange_FlowerGiftCheck:
jumpifability BS_SCRIPTING, ABILITY_FLOWER_GIFT, BattleScript_DoWeatherFormChange_PopUp
goto BattleScript_DoWeatherFormChange_AfterPopUp
.endif
BattleScript_DoWeatherFormChange_ForecastCheck:
jumpifability BS_SCRIPTING, ABILITY_FORECAST, BattleScript_DoWeatherFormChange_PopUp
goto BattleScript_DoWeatherFormChange_AfterPopUp
BattleScript_DoWeatherFormChange_PopUp:
call BattleScript_AbilityPopUp
BattleScript_DoWeatherFormChange_AfterPopUp:
doweatherformchangeanimation
waitstate
printstring STRINGID_PKMNTRANSFORMED
waitmessage B_WAIT_TIME_LONG
return return
BattleScript_TryAdrenalineOrb: BattleScript_TryAdrenalineOrb:
@ -8828,7 +8875,7 @@ BattleScript_DroughtActivates::
printstring STRINGID_PKMNSXINTENSIFIEDSUN printstring STRINGID_PKMNSXINTENSIFIEDSUN
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_DesolateLandActivates:: BattleScript_DesolateLandActivates::
@ -8837,7 +8884,7 @@ BattleScript_DesolateLandActivates::
printstring STRINGID_EXTREMELYHARSHSUNLIGHT printstring STRINGID_EXTREMELYHARSHSUNLIGHT
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_DesolateLandEvaporatesWaterTypeMoves:: BattleScript_DesolateLandEvaporatesWaterTypeMoves::
@ -8857,7 +8904,7 @@ BattleScript_PrimordialSeaActivates::
printstring STRINGID_HEAVYRAIN printstring STRINGID_HEAVYRAIN
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_PrimordialSeaFizzlesOutFireTypeMoves:: BattleScript_PrimordialSeaFizzlesOutFireTypeMoves::
@ -8928,13 +8975,22 @@ BattleScript_MimicryActivates_End3::
waitmessage B_WAIT_TIME_SHORT waitmessage B_WAIT_TIME_SHORT
end3 end3
BattleScript_SnowWarningActivates:: BattleScript_SnowWarningActivatesHail::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
printstring STRINGID_SNOWWARNINGHAIL printstring STRINGID_SNOWWARNINGHAIL
waitstate waitstate
playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3
BattleScript_SnowWarningActivatesSnow::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
printstring STRINGID_SNOWWARNINGSNOW
waitstate
playanimation BS_BATTLER_0, B_ANIM_SNOW_CONTINUES
call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_ActivateTerrainEffects: BattleScript_ActivateTerrainEffects:
@ -9075,8 +9131,8 @@ BattleScript_MoveStatDrain::
setgraphicalstatchangevalues setgraphicalstatchangevalues
playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
waitanimation waitanimation
.if B_ABSORBING_ABILITY_STRING >= GEN_5
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_MoveStatDrain_Cont statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_MoveStatDrain_Cont
.if B_ABSORBING_ABILITY_STRING >= GEN_5
printfromtable gStatUpStringIds printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
.else .else
@ -9215,7 +9271,6 @@ BattleScript_GrassyTerrainLoopIncrement::
BattleScript_GrassyTerrainLoopEnd:: BattleScript_GrassyTerrainLoopEnd::
bicword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE bicword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_TERRAIN_PERMANENT, BattleScript_GrassyTerrainHealEnd jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_TERRAIN_PERMANENT, BattleScript_GrassyTerrainHealEnd
jumpifbyte CMP_EQUAL, gFieldTimers + 5, 0, BattleScript_GrassyTerrainEnds
BattleScript_GrassyTerrainHealEnd: BattleScript_GrassyTerrainHealEnd:
end2 end2
@ -9356,6 +9411,7 @@ BattleScript_WeakArmorActivatesEnd:
return return
BattleScript_RaiseStatOnFaintingTarget:: BattleScript_RaiseStatOnFaintingTarget::
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_RaiseStatOnFaintingTarget_End
copybyte gBattlerAbility, gBattlerAttacker copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
setgraphicalstatchangevalues setgraphicalstatchangevalues
@ -9363,9 +9419,11 @@ BattleScript_RaiseStatOnFaintingTarget::
waitanimation waitanimation
printstring STRINGID_LASTABILITYRAISEDSTAT printstring STRINGID_LASTABILITYRAISEDSTAT
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
BattleScript_RaiseStatOnFaintingTarget_End:
return return
BattleScript_AttackerAbilityStatRaise:: BattleScript_AttackerAbilityStatRaise::
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AttackerAbilityStatRaise_End
copybyte gBattlerAbility, gBattlerAttacker copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
setgraphicalstatchangevalues setgraphicalstatchangevalues
@ -9373,6 +9431,7 @@ BattleScript_AttackerAbilityStatRaise::
waitanimation waitanimation
printstring STRINGID_ATTACKERABILITYSTATRAISE printstring STRINGID_ATTACKERABILITYSTATRAISE
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
BattleScript_AttackerAbilityStatRaise_End:
return return
BattleScript_FellStingerRaisesStat:: BattleScript_FellStingerRaisesStat::
@ -9426,8 +9485,8 @@ BattleScript_FriskActivates::
end3 end3
BattleScript_ImposterActivates:: BattleScript_ImposterActivates::
transformdataexecution
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
transformdataexecution
playmoveanimation BS_ATTACKER, MOVE_TRANSFORM playmoveanimation BS_ATTACKER, MOVE_TRANSFORM
waitanimation waitanimation
printstring STRINGID_IMPOSTERTRANSFORM printstring STRINGID_IMPOSTERTRANSFORM
@ -9652,6 +9711,18 @@ BattleScript_BerryCureFrzRet::
removeitem BS_SCRIPTING removeitem BS_SCRIPTING
return return
BattleScript_BerryCureFsbEnd2::
call BattleScript_BerryCureFrzRet
end2
BattleScript_BerryCureFsbRet::
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT
printstring STRINGID_PKMNSITEMHEALEDFROSTBITE
waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_SCRIPTING
removeitem BS_SCRIPTING
return
BattleScript_BerryCureSlpEnd2:: BattleScript_BerryCureSlpEnd2::
call BattleScript_BerryCureSlpRet call BattleScript_BerryCureSlpRet
end2 end2
@ -10075,29 +10146,48 @@ BattleScript_PrintPlayerForfeitedLinkBattle::
end2 end2
BattleScript_TotemFlaredToLife:: BattleScript_TotemFlaredToLife::
playanimation BS_ATTACKER, B_ANIM_TOTEM_FLARE playanimation BS_ATTACKER, B_ANIM_TOTEM_FLARE, NULL
printstring STRINGID_AURAFLAREDTOLIFE printstring STRINGID_AURAFLAREDTOLIFE
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_ApplyTotemVarBoost call BattleScript_ApplyTotemVarBoost
end2
@ remove the mirror herb, do totem loop
BattleScript_MirrorHerbCopyStatChangeEnd2::
call BattleScript_MirrorHerbCopyStatChange
end2
BattleScript_MirrorHerbCopyStatChange::
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_MIRRORHERBCOPIED
waitmessage B_WAIT_TIME_LONG
removeitem BS_SCRIPTING
call BattleScript_TotemVar_Ret
copybyte gBattlerAttacker, sSAVED_BATTLER @ restore the original attacker just to be safe
return
BattleScript_TotemVar:: BattleScript_TotemVar::
call BattleScript_TotemVar_Ret
end2
BattleScript_TotemVar_Ret::
gettotemboost BattleScript_ApplyTotemVarBoost gettotemboost BattleScript_ApplyTotemVarBoost
BattleScript_TotemVarEnd: BattleScript_TotemVarEnd:
end2 return
BattleScript_ApplyTotemVarBoost: BattleScript_ApplyTotemVarBoost:
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TotemVarEnd statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TotemVarEnd
setgraphicalstatchangevalues setgraphicalstatchangevalues
playanimation BS_SCRIPTING, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 playanimation BS_SCRIPTING, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
BattleScript_TotemVarPrintStatMsg:
printfromtable gStatUpStringIds printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_TotemVar @loop until stats bitfield is empty goto BattleScript_TotemVar_Ret @loop until stats bitfield is empty
BattleScript_AnnounceAirLockCloudNine:: BattleScript_AnnounceAirLockCloudNine::
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
printstring STRINGID_AIRLOCKACTIVATES printstring STRINGID_AIRLOCKACTIVATES
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
call BattleScript_WeatherFormChanges call BattleScript_ActivateWeatherAbilities
end3 end3
BattleScript_QuickClawActivation:: BattleScript_QuickClawActivation::
@ -10167,6 +10257,8 @@ BattleScript_JabocaRowapBerryActivate_Dmg:
@ z moves / effects @ z moves / effects
BattleScript_ZMoveActivateDamaging:: BattleScript_ZMoveActivateDamaging::
printstring STRINGID_EMPTYSTRING3
trytrainerslidezmovemsg BS_ATTACKER
printstring STRINGID_ZPOWERSURROUNDS printstring STRINGID_ZPOWERSURROUNDS
playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL
printstring STRINGID_ZMOVEUNLEASHED printstring STRINGID_ZMOVEUNLEASHED
@ -10174,6 +10266,8 @@ BattleScript_ZMoveActivateDamaging::
return return
BattleScript_ZMoveActivateStatus:: BattleScript_ZMoveActivateStatus::
printstring STRINGID_EMPTYSTRING3
trytrainerslidezmovemsg BS_ATTACKER
savetarget savetarget
printstring STRINGID_ZPOWERSURROUNDS printstring STRINGID_ZPOWERSURROUNDS
playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL
@ -10479,3 +10573,40 @@ BattleScript_CouldntFullyProtect::
printstring STRINGID_COULDNTFULLYPROTECT printstring STRINGID_COULDNTFULLYPROTECT
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
return return
BattleScript_BerserkGeneRet::
BattleScript_BerserkGeneRet_Anim:
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_BerserkGeneRet_TryConfuse
setgraphicalstatchangevalues
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, sB_ANIM_ARG1
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM
call BattleScript_StatUp
BattleScript_BerserkGeneRet_TryConfuse:
jumpifability BS_SCRIPTING, ABILITY_OWN_TEMPO, BattleScript_BerserkGeneRet_OwnTempoPrevents
jumpifsafeguard BattleScript_BerserkGeneRet_SafeguardProtected
setmoveeffect MOVE_EFFECT_CONFUSION
seteffectprimary
goto BattleScript_BerserkGeneRet_End
BattleScript_BerserkGeneRet_SafeguardProtected::
pause B_WAIT_TIME_SHORT
printstring STRINGID_PKMNUSEDSAFEGUARD
waitmessage B_WAIT_TIME_LONG
goto BattleScript_BerserkGeneRet_End
BattleScript_BerserkGeneRet_OwnTempoPrevents:
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
printstring STRINGID_PKMNPREVENTSCONFUSIONWITH
waitmessage B_WAIT_TIME_LONG
BattleScript_BerserkGeneRet_End:
removeitem BS_SCRIPTING
end3
BattleScript_EffectSnow::
attackcanceler
attackstring
ppreduce
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, B_WEATHER_SUN_PRIMAL, BattleScript_ExtremelyHarshSunlightWasNotLessened
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, B_WEATHER_RAIN_PRIMAL, BattleScript_NoReliefFromHeavyRain
jumpifhalfword CMP_COMMON_BITS, gBattleWeather, B_WEATHER_STRONG_WINDS, BattleScript_MysteriousAirCurrentBlowsOn
setsnow
goto BattleScript_MoveWeatherChange

View File

@ -49,34 +49,33 @@ BattleScript_UseItemMessage:
BattleScript_ItemRestoreHP:: BattleScript_ItemRestoreHP::
call BattleScript_UseItemMessage call BattleScript_UseItemMessage
itemrestorehp itemrestorehp
printstring STRINGID_ITEMRESTOREDSPECIESHEALTH
waitmessage B_WAIT_TIME_LONG
jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_ItemRestoreHP_SendOutRevivedBattler jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_ItemRestoreHP_SendOutRevivedBattler
bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE
healthbarupdate BS_ATTACKER healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER datahpupdate BS_ATTACKER
updatestatusicon BS_ATTACKER printstring STRINGID_ITEMRESTOREDSPECIESHEALTH
waitmessage B_WAIT_TIME_LONG
end end
BattleScript_ItemRestoreHP_SendOutRevivedBattler: BattleScript_ItemRestoreHP_SendOutRevivedBattler:
switchinanim BS_ATTACKER, FALSE switchinanim BS_SCRIPTING, FALSE
waitstate waitstate
switchineffects BS_ATTACKER switchineffects BS_SCRIPTING
end end
BattleScript_ItemCureStatus:: BattleScript_ItemCureStatus::
call BattleScript_UseItemMessage call BattleScript_UseItemMessage
itemcurestatus itemcurestatus
updatestatusicon BS_ATTACKER
printstring STRINGID_ITEMCUREDSPECIESSTATUS printstring STRINGID_ITEMCUREDSPECIESSTATUS
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_ATTACKER
end end
BattleScript_ItemHealAndCureStatus:: BattleScript_ItemHealAndCureStatus::
call BattleScript_UseItemMessage call BattleScript_UseItemMessage
itemrestorehp itemrestorehp
curestatus BS_ATTACKER itemcurestatus
printstring STRINGID_ITEMRESTOREDSPECIESHEALTH printstring STRINGID_ITEMRESTOREDSPECIESHEALTH
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
@ -84,6 +83,8 @@ BattleScript_ItemHealAndCureStatus::
healthbarupdate BS_ATTACKER healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER datahpupdate BS_ATTACKER
updatestatusicon BS_ATTACKER updatestatusicon BS_ATTACKER
printstring STRINGID_ITEMRESTOREDSPECIESHEALTH
waitmessage B_WAIT_TIME_LONG
end end
BattleScript_ItemIncreaseStat:: BattleScript_ItemIncreaseStat::

View File

@ -1,3 +1,5 @@
.if DEBUG_OVERWORLD_MENU == TRUE
Debug_ShowFieldMessageStringVar4:: Debug_ShowFieldMessageStringVar4::
special ShowFieldMessageStringVar4 special ShowFieldMessageStringVar4
waitmessage waitmessage
@ -90,3 +92,24 @@ Debug_Script_7::
Debug_Script_8:: Debug_Script_8::
end end
Debug_CheckSaveBlock::
callnative CheckSaveBlock1Size
msgbox Debug_SaveBlock1Size, MSGBOX_DEFAULT
callnative CheckSaveBlock2Size
msgbox Debug_SaveBlock2Size, MSGBOX_DEFAULT
callnative CheckPokemonStorageSize
msgbox Debug_PokemonStorageSize, MSGBOX_DEFAULT
release
end
Debug_SaveBlock1Size::
.string "SaveBlock1 size: {STR_VAR_1}/{STR_VAR_2}.$"
Debug_SaveBlock2Size::
.string "SaveBlock2 size: {STR_VAR_1}/{STR_VAR_2}.$"
Debug_PokemonStorageSize::
.string "{PKMN}Storage size: {STR_VAR_1}/{STR_VAR_2}.$"
.endif

View File

@ -1,37 +1,18 @@
#include "global.h" #include "global.h"
#include "malloc.h"
static void *sHeapStart; static void *sHeapStart;
static u32 sHeapSize; static u32 sHeapSize;
#define MALLOC_SYSTEM_ID 0xA3A3
struct MemBlock {
// Whether this block is currently allocated.
bool16 flag;
// Magic number used for error checking. Should equal MALLOC_SYSTEM_ID.
u16 magic;
// Size of the block (not including this header struct).
u32 size;
// Previous block pointer. Equals sHeapStart if this is the first block.
struct MemBlock *prev;
// Next block pointer. Equals sHeapStart if this is the last block.
struct MemBlock *next;
// Data in the memory block. (Arrays of length 0 are a GNU extension.)
u8 data[0];
};
void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next, u32 size) void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next, u32 size)
{ {
struct MemBlock *header = (struct MemBlock *)block; struct MemBlock *header = (struct MemBlock *)block;
header->flag = FALSE; header->allocated = FALSE;
header->locationHi = 0;
header->magic = MALLOC_SYSTEM_ID; header->magic = MALLOC_SYSTEM_ID;
header->size = size; header->size = size;
header->locationLo = 0;
header->prev = prev; header->prev = prev;
header->next = next; header->next = next;
} }
@ -41,7 +22,7 @@ void PutFirstMemBlockHeader(void *block, u32 size)
PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock)); PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock));
} }
void *AllocInternal(void *heapStart, u32 size) void *AllocInternal(void *heapStart, u32 size, const char *location)
{ {
struct MemBlock *pos = (struct MemBlock *)heapStart; struct MemBlock *pos = (struct MemBlock *)heapStart;
struct MemBlock *head = pos; struct MemBlock *head = pos;
@ -55,14 +36,14 @@ void *AllocInternal(void *heapStart, u32 size)
for (;;) { for (;;) {
// Loop through the blocks looking for unused block that's big enough. // Loop through the blocks looking for unused block that's big enough.
if (!pos->flag) { if (!pos->allocated) {
foundBlockSize = pos->size; foundBlockSize = pos->size;
if (foundBlockSize >= size) { if (foundBlockSize >= size) {
if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) { if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
// The block isn't much bigger than the requested size, // The block isn't much bigger than the requested size,
// so just use it. // so just use it.
pos->flag = TRUE; pos->allocated = TRUE;
} else { } else {
// The block is significantly bigger than the requested // The block is significantly bigger than the requested
// size, so split the rest into a separate block. // size, so split the rest into a separate block.
@ -71,7 +52,7 @@ void *AllocInternal(void *heapStart, u32 size)
splitBlock = (struct MemBlock *)(pos->data + size); splitBlock = (struct MemBlock *)(pos->data + size);
pos->flag = TRUE; pos->allocated = TRUE;
pos->size = size; pos->size = size;
PutMemBlockHeader(splitBlock, pos, pos->next, foundBlockSize); PutMemBlockHeader(splitBlock, pos, pos->next, foundBlockSize);
@ -82,6 +63,9 @@ void *AllocInternal(void *heapStart, u32 size)
splitBlock->next->prev = splitBlock; splitBlock->next->prev = splitBlock;
} }
pos->locationHi = ((uintptr_t)location) >> 14;
pos->locationLo = (uintptr_t)location;
return pos->data; return pos->data;
} }
} }
@ -98,12 +82,12 @@ void FreeInternal(void *heapStart, void *pointer)
if (pointer) { if (pointer) {
struct MemBlock *head = (struct MemBlock *)heapStart; struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock)); struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
block->flag = FALSE; block->allocated = FALSE;
// If the freed block isn't the last one, merge with the next block // If the freed block isn't the last one, merge with the next block
// if it's not in use. // if it's not in use.
if (block->next != head) { if (block->next != head) {
if (!block->next->flag) { if (!block->next->allocated) {
block->size += sizeof(struct MemBlock) + block->next->size; block->size += sizeof(struct MemBlock) + block->next->size;
block->next->magic = 0; block->next->magic = 0;
block->next = block->next->next; block->next = block->next->next;
@ -115,7 +99,7 @@ void FreeInternal(void *heapStart, void *pointer)
// If the freed block isn't the first one, merge with the previous block // If the freed block isn't the first one, merge with the previous block
// if it's not in use. // if it's not in use.
if (block != head) { if (block != head) {
if (!block->prev->flag) { if (!block->prev->allocated) {
block->prev->next = block->next; block->prev->next = block->next;
if (block->next != head) if (block->next != head)
@ -128,9 +112,9 @@ void FreeInternal(void *heapStart, void *pointer)
} }
} }
void *AllocZeroedInternal(void *heapStart, u32 size) void *AllocZeroedInternal(void *heapStart, u32 size, const char *location)
{ {
void *mem = AllocInternal(heapStart, size); void *mem = AllocInternal(heapStart, size, location);
if (mem != NULL) { if (mem != NULL) {
if (size & 3) if (size & 3)
@ -175,14 +159,14 @@ void InitHeap(void *heapStart, u32 heapSize)
PutFirstMemBlockHeader(heapStart, heapSize); PutFirstMemBlockHeader(heapStart, heapSize);
} }
void *Alloc(u32 size) void *Alloc_(u32 size, const char *location)
{ {
return AllocInternal(sHeapStart, size); return AllocInternal(sHeapStart, size, location);
} }
void *AllocZeroed(u32 size) void *AllocZeroed_(u32 size, const char *location)
{ {
return AllocZeroedInternal(sHeapStart, size); return AllocZeroedInternal(sHeapStart, size, location);
} }
void Free(void *pointer) void Free(void *pointer)
@ -207,3 +191,16 @@ bool32 CheckHeap()
return TRUE; return TRUE;
} }
const struct MemBlock *HeapHead(void)
{
return (const struct MemBlock *)sHeapStart;
}
const char *MemBlockLocation(const struct MemBlock *block)
{
if (!block->allocated)
return NULL;
return (const char *)(ROM_START | (block->locationHi << 14) | block->locationLo);
}

View File

@ -11,11 +11,57 @@
#define TRY_FREE_AND_SET_NULL(ptr) if (ptr != NULL) FREE_AND_SET_NULL(ptr) #define TRY_FREE_AND_SET_NULL(ptr) if (ptr != NULL) FREE_AND_SET_NULL(ptr)
#define MALLOC_SYSTEM_ID 0xA3A3
struct MemBlock
{
// Whether this block is currently allocated.
u16 allocated:1;
u16 unused_00:4;
// High 11 bits of location pointer.
u16 locationHi:11;
// Magic number used for error checking. Should equal MALLOC_SYSTEM_ID.
u16 magic;
// Size of the block (not including this header struct).
u32 size:18;
// Low 14 bits of location pointer.
u32 locationLo:14;
// Previous block pointer. Equals sHeapStart if this is the first block.
struct MemBlock *prev;
// Next block pointer. Equals sHeapStart if this is the last block.
struct MemBlock *next;
// Data in the memory block. (Arrays of length 0 are a GNU extension.)
u8 data[0];
};
extern u8 gHeap[]; extern u8 gHeap[];
void *Alloc(u32 size); #if TESTING || !defined(NDEBUG)
void *AllocZeroed(u32 size);
#define Alloc(size) Alloc_(size, __FILE__ ":" STR(__LINE__))
#define AllocZeroed(size) AllocZeroed_(size, __FILE__ ":" STR(__LINE__))
#else
#define Alloc(size) Alloc_(size, NULL)
#define AllocZeroed(size) AllocZeroed_(size, NULL)
#endif
void *Alloc_(u32 size, const char *location);
void *AllocZeroed_(u32 size, const char *location);
void Free(void *pointer); void Free(void *pointer);
void InitHeap(void *pointer, u32 size); void InitHeap(void *pointer, u32 size);
const struct MemBlock *HeapHead(void);
const char *MemBlockLocation(const struct MemBlock *block);
#endif // GUARD_ALLOC_H #endif // GUARD_ALLOC_H

View File

@ -1600,7 +1600,7 @@ u8 LoadSpritePalette(const struct SpritePalette *palette)
else else
{ {
sSpritePaletteTags[index] = palette->tag; sSpritePaletteTags[index] = palette->tag;
DoLoadSpritePalette(palette->data, index * 16); DoLoadSpritePalette(palette->data, PLTT_ID(index));
return index; return index;
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 530 B

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 530 B

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 B

After

Width:  |  Height:  |  Size: 458 B

View File

@ -0,0 +1,19 @@
JASC-PAL
0100
16
212 146 75
49 49 49
131 123 131
98 90 98
74 65 74
164 90 222
230 180 255
255 230 238
255 230 106
255 189 74
255 171 32
238 148 0
255 246 189
123 82 32
0 0 0
0 0 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 B

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 B

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 B

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 B

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 B

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 B

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 B

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 B

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 B

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 B

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 B

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 B

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 87 B

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