summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlibjet <libj3t@gmail.com>2020-05-21 00:46:21 +0100
committerlibjet <libj3t@gmail.com>2020-05-21 00:46:21 +0100
commit6342c09d98027c18f5636aa377bab04a54166181 (patch)
treed26aa69450812223d4d2f9eb44b4961bc9f6007c
parent1fca66421ad18d7dc979d4871caf653febd9fa20 (diff)
Add fruit_trees.asm
-rwxr-xr-xdata/items/fruit_trees.asm32
-rwxr-xr-xengine/events/fruit_trees.asm116
-rw-r--r--main.asm5
-rw-r--r--wram.asm21
4 files changed, 159 insertions, 15 deletions
diff --git a/data/items/fruit_trees.asm b/data/items/fruit_trees.asm
new file mode 100755
index 00000000..9c4e4793
--- /dev/null
+++ b/data/items/fruit_trees.asm
@@ -0,0 +1,32 @@
+FruitTreeItems:
+; entries correspond to FRUITTREE_* constants
+ db BERRY ; ROUTE_29
+ db BERRY ; ROUTE_30_1
+ db BERRY ; ROUTE_38
+ db BERRY ; ROUTE_46_1
+ db PSNCUREBERRY ; ROUTE_30_2
+ db PSNCUREBERRY ; ROUTE_33
+ db BITTER_BERRY ; ROUTE_31
+ db BITTER_BERRY ; ROUTE_43
+ db PRZCUREBERRY ; VIOLET_CITY
+ db PRZCUREBERRY ; ROUTE_46_2
+ db MYSTERYBERRY ; ROUTE_35
+ db MYSTERYBERRY ; ROUTE_45
+ db ICE_BERRY ; ROUTE_36
+ db ICE_BERRY ; ROUTE_26
+ db MINT_BERRY ; ROUTE_39
+ db BURNT_BERRY ; ROUTE_44
+ db RED_APRICORN ; ROUTE_37_1
+ db BLU_APRICORN ; ROUTE_37_2
+ db BLK_APRICORN ; ROUTE_37_3
+ db WHT_APRICORN ; AZALEA_TOWN
+ db PNK_APRICORN ; ROUTE_42_1
+ db GRN_APRICORN ; ROUTE_42_2
+ db YLW_APRICORN ; ROUTE_42_3
+ db BERRY ; ROUTE_11
+ db PSNCUREBERRY ; ROUTE_2
+ db BITTER_BERRY ; ROUTE_1
+ db PRZCUREBERRY ; ROUTE_8
+ db ICE_BERRY ; PEWTER_CITY_1
+ db MINT_BERRY ; PEWTER_CITY_2
+ db BURNT_BERRY ; FUCHSIA_CITY
diff --git a/engine/events/fruit_trees.asm b/engine/events/fruit_trees.asm
new file mode 100755
index 00000000..0177eb6f
--- /dev/null
+++ b/engine/events/fruit_trees.asm
@@ -0,0 +1,116 @@
+FruitTreeScript::
+ callasm GetCurTreeFruit
+ opentext
+ readmem wCurFruit
+ getitemname STRING_BUFFER_3, USE_SCRIPT_VAR
+ writetext FruitBearingTreeText
+ promptbutton
+ callasm TryResetFruitTrees
+ callasm CheckFruitTree
+ iffalse .fruit
+ writetext NothingHereText
+ waitbutton
+ sjump .end
+
+.fruit
+ writetext HeyItsFruitText
+ readmem wCurFruit
+ giveitem ITEM_FROM_MEM
+ iffalse .packisfull
+ promptbutton
+ writetext ObtainedFruitText
+ callasm PickedFruitTree
+ specialsound
+ itemnotify
+ sjump .end
+
+.packisfull
+ promptbutton
+ writetext FruitPackIsFullText
+ waitbutton
+
+.end
+ closetext
+ end
+
+GetCurTreeFruit:
+ ld a, [wCurFruitTree]
+ dec a
+ call GetFruitTreeItem
+ ld [wCurFruit], a
+ ret
+
+TryResetFruitTrees:
+ ld hl, wDailyFlags1
+ bit DAILYFLAGS1_ALL_FRUIT_TREES_F, [hl]
+ ret nz
+ jp ResetFruitTrees
+
+CheckFruitTree:
+ ld b, 2
+ call GetFruitTreeFlag
+ ld a, c
+ ld [wScriptVar], a
+ ret
+
+PickedFruitTree:
+ ld b, 1
+ jp GetFruitTreeFlag
+
+ResetFruitTrees:
+ xor a
+ ld hl, wFruitTreeFlags
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld hl, wDailyFlags1
+ set DAILYFLAGS1_ALL_FRUIT_TREES_F, [hl]
+ ret
+
+GetFruitTreeFlag:
+ push hl
+ push de
+ ld a, [wCurFruitTree]
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, wFruitTreeFlags
+ call FlagAction
+ pop de
+ pop hl
+ ret
+
+GetFruitTreeItem:
+ push hl
+ push de
+ ld e, a
+ ld d, 0
+ ld hl, FruitTreeItems
+ add hl, de
+ ld a, [hl]
+ pop de
+ pop hl
+ ret
+
+INCLUDE "data/items/fruit_trees.asm"
+
+FruitBearingTreeText:
+ text_far _FruitBearingTreeText
+ text_end
+
+HeyItsFruitText:
+ text_far _HeyItsFruitText
+ text_end
+
+ObtainedFruitText:
+ text_far _ObtainedFruitText
+ text_end
+
+FruitPackIsFullText:
+ text_far _FruitPackIsFullText
+ text_end
+
+NothingHereText:
+ text_far _NothingHereText
+ text_end
diff --git a/main.asm b/main.asm
index 5f74bc3b..a348fede 100644
--- a/main.asm
+++ b/main.asm
@@ -346,16 +346,17 @@ INCLUDE "engine/pokemon/evolve.asm"
SECTION "bank11", ROMX
-FruitTreeScript::
- dr $44000, $440c8
+INCLUDE "engine/events/fruit_trees.asm"
INCLUDE "engine/battle/ai/move.asm"
INCLUDE "engine/pokedex/pokedex_2.asm"
+
PlayBattleMusic::
dr $44556, $445f2
ClearBattleRAM::
dr $445f2, $44648
PlaceGraphic::
dr $44648, $44679
+
SendMailToPC::
dr $44679, $4475f
CheckPokeMail::
diff --git a/wram.asm b/wram.asm
index 9c593d4f..59730d68 100644
--- a/wram.asm
+++ b/wram.asm
@@ -2531,19 +2531,14 @@ wMomItemTriggerBalance:: ds 3 ; d963
wDailyResetTimer:: dw ; d966
wDailyFlags1:: db ; d968
wDailyFlags2:: db ; d969
-wd96a:: ds 1 ; d96a
-wd96b:: ds 1 ; d96b
-wd96c:: ds 1 ; d96c
-wTimerEventStartDay:: db ; d96d
-wd96e:: ds 1 ; d96e
-wd96f:: ds 1 ; d96f
-wd970:: ds 1 ; d970
-wd971:: ds 1 ; d971
-wd972:: ds 1 ; d972
-wd973:: ds 1 ; d973
-wd974:: ds 1 ; d974
-wd975:: ds 1 ; d975
-wd976:: ds 1 ; d976
+wSwarmFlags:: db ; d96a
+ ds 2
+wTimerEventStartDay:: db
+ ds 3
+
+wFruitTreeFlags:: flag_array NUM_FRUIT_TREES ; d971
+
+ ds 2
wLuckyNumberDayBuffer:: dw ; d977
wd979:: ds 1 ; d979