summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorProjectRevoTPP <projectrevotpp@hotmail.com>2017-03-18 04:00:15 +0100
committerProjectRevoTPP <projectrevotpp@hotmail.com>2017-03-18 04:00:15 +0100
commit6035511c139549a0291b6b3d43b9b080f792b2b6 (patch)
tree128cb1580f3c1ac1a6f897ea2e8e703265e88914
parentd4703599837531d1118b64822c85755f28747ee1 (diff)
reorganize and add new headers for many files
-rw-r--r--asm/battle_message.s26
-rw-r--r--asm/choose_party.s38
-rw-r--r--asm/hall_of_fame.s6
-rw-r--r--asm/reset_rtc_screen.s2
-rw-r--r--asm/rom_81258BC.s10
-rw-r--r--include/asm.inc.h101
-rw-r--r--include/battle.h7
-rw-r--r--include/battle_ai.h31
-rw-r--r--include/battle_anim.h58
-rw-r--r--include/battle_party_menu.h15
-rw-r--r--include/battle_setup.h152
-rw-r--r--include/bike.h56
-rw-r--r--include/braille_puzzles.h14
-rw-r--r--include/clock.h8
-rw-r--r--include/contest.h26
-rw-r--r--include/contest_painting.h77
-rw-r--r--include/dewford_trend.h10
-rw-r--r--include/field_control_avatar.h13
-rw-r--r--include/field_door.h25
-rw-r--r--include/field_map_obj_helpers.h11
-rw-r--r--include/field_player_avatar.h2
-rw-r--r--include/gba/flash_internal.h7
-rw-r--r--include/global.h31
-rw-r--r--include/intro.h1
-rw-r--r--include/matsuda_debug_menu.h11
-rw-r--r--include/name_string_util.h7
-rw-r--r--include/naming_screen.h83
-rw-r--r--include/rom4.h2
-rw-r--r--include/rom6.h7
-rw-r--r--include/save.h69
-rw-r--r--include/script_menu.h31
-rw-r--r--include/script_pokemon_80C4.h22
-rw-r--r--include/script_pokemon_80F9.h17
-rw-r--r--include/trainer_see.h2
-rw-r--r--include/vars.h2
-rw-r--r--ld_script.txt15
-rw-r--r--src/agb_flash.c8
-rw-r--r--src/battle_ai.c27
-rw-r--r--src/battle_anim.c54
-rw-r--r--src/battle_anim_80A7E7C.c3
-rw-r--r--src/battle_party_menu.c13
-rw-r--r--src/battle_setup.c57
-rw-r--r--src/berry.c1
-rw-r--r--src/bike.c42
-rw-r--r--src/clock.c1
-rw-r--r--src/contest_painting.c86
-rw-r--r--src/dewford_trend.c4
-rw-r--r--src/field_control_avatar.c2
-rw-r--r--src/field_door.c15
-rw-r--r--src/field_player_avatar.c2
-rw-r--r--src/field_special_scene.c55
-rw-r--r--src/fldeff_strength.c2
-rw-r--r--src/fldeff_teleport.c1
-rw-r--r--src/intro.c18
-rw-r--r--src/link.c2
-rw-r--r--src/load_save.c1
-rw-r--r--src/mail.c1
-rw-r--r--src/main_menu.c1
-rw-r--r--src/map_obj_lock.c1
-rw-r--r--src/matsuda_debug_menu.c25
-rw-r--r--src/metatile_behavior.c250
-rw-r--r--src/mystery_event_menu.c2
-rw-r--r--src/naming_screen.c86
-rw-r--r--src/new_game.c17
-rw-r--r--src/record_mixing.c1
-rw-r--r--src/rom4.c4
-rw-r--r--src/rom6.c6
-rw-r--r--src/save_failed_screen.c68
-rw-r--r--src/save_menu_util.c8
-rw-r--r--src/scrcmd.c7
-rw-r--r--src/script_movement.c1
-rw-r--r--src/script_pokemon_util_80F99CC.c13
-rw-r--r--src/start_menu.c20
-rw-r--r--src/task.c70
-rw-r--r--src/trainer_card.c1
-rw-r--r--src/trainer_see.c2
-rw-r--r--sym_common.txt16
-rw-r--r--sym_ewram.txt19
78 files changed, 1225 insertions, 783 deletions
diff --git a/asm/battle_message.s b/asm/battle_message.s
index 17841a4e9..0e3588d14 100644
--- a/asm/battle_message.s
+++ b/asm/battle_message.s
@@ -16,7 +16,7 @@ sub_8120AA8: @ 8120AA8
lsls r0, 16
lsrs r7, r0, 16
movs r6, 0
- ldr r5, _08120B70 @ =gUnknown_02039270
+ ldr r5, _08120B70 @ =gSelectedOrderFromParty
ldr r4, _08120B74 @ =gUnknown_02024A60
ldrb r1, [r4]
lsls r1, 9
@@ -73,7 +73,7 @@ _08120B10:
movs r2, 0
ldr r0, _08120B9C @ =gUnknown_030041C0
mov r8, r0
- ldr r3, _08120B70 @ =gUnknown_02039270
+ ldr r3, _08120B70 @ =gSelectedOrderFromParty
ldr r1, _08120BA4 @ =gUnknown_03004290
mov r12, r1
ldr r5, _08120BA8 @ =gUnknown_030042B0
@@ -111,7 +111,7 @@ _08120B64:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_08120B70: .4byte gUnknown_02039270
+_08120B70: .4byte gSelectedOrderFromParty
_08120B74: .4byte gUnknown_02024A60
_08120B78: .4byte gUnknown_02023A64
_08120B7C: .4byte gUnknown_02024C04
@@ -414,7 +414,7 @@ _08120DE4: .4byte gUnknown_08400622
_08120DE8:
mov r0, r10
bl sub_8121D1C
- ldr r0, _08120E14 @ =gUnknown_02039270
+ ldr r0, _08120E14 @ =gSelectedOrderFromParty
ldr r2, [r0]
ldrh r1, [r2]
movs r0, 0xB1
@@ -433,7 +433,7 @@ _08120DE8:
bl StringCopy
b _08120E38
.align 2, 0
-_08120E14: .4byte gUnknown_02039270
+_08120E14: .4byte gSelectedOrderFromParty
_08120E18: .4byte gUnknown_03004290
_08120E1C: .4byte gUnknown_08401674
_08120E20: .4byte 0x02000000
@@ -1368,7 +1368,7 @@ _081215E8:
.align 2, 0
_081215F4: .4byte gUnknown_02024A6A
_081215F8:
- ldr r0, _08121610 @ =gUnknown_02039270
+ ldr r0, _08121610 @ =gSelectedOrderFromParty
ldr r2, [r0]
ldrh r1, [r2]
movs r0, 0xB1
@@ -1380,14 +1380,14 @@ _081215F8:
adds r0, r2
b _08121634
.align 2, 0
-_08121610: .4byte gUnknown_02039270
+_08121610: .4byte gSelectedOrderFromParty
_08121614: .4byte 0x02000000
_08121618: .4byte 0x000160a0
_0812161C:
ldrh r1, [r2]
b _08121652
_08121620:
- ldr r0, _08121640 @ =gUnknown_02039270
+ ldr r0, _08121640 @ =gSelectedOrderFromParty
ldr r2, [r0]
ldrh r1, [r2, 0x2]
movs r0, 0xB1
@@ -1404,7 +1404,7 @@ _08121634:
adds r4, r0, r1
b _081219E6
.align 2, 0
-_08121640: .4byte gUnknown_02039270
+_08121640: .4byte gSelectedOrderFromParty
_08121644: .4byte 0x02000000
_08121648: .4byte 0x000160a0
_0812164C: .4byte gUnknown_08401674
@@ -2274,7 +2274,7 @@ sub_8121D1C: @ 8121D1C
push {r4,r5,lr}
adds r4, r0, 0
movs r2, 0
- ldr r5, _08121D50 @ =gUnknown_02039270
+ ldr r5, _08121D50 @ =gSelectedOrderFromParty
ldr r3, _08121D54 @ =gUnknown_084016BC
_08121D26:
cmp r2, 0x4
@@ -2299,7 +2299,7 @@ _08121D3C:
bl StringCopy
b _08121D68
.align 2, 0
-_08121D50: .4byte gUnknown_02039270
+_08121D50: .4byte gSelectedOrderFromParty
_08121D54: .4byte gUnknown_084016BC
_08121D58: .4byte gUnknown_08400E5E
_08121D5C:
@@ -2329,7 +2329,7 @@ _08121D7E:
cmp r0, 0xFF
bne _08121D7C
ldr r1, _08121DB4 @ =gUnknown_084016BC
- ldr r5, _08121DB8 @ =gUnknown_02039270
+ ldr r5, _08121DB8 @ =gSelectedOrderFromParty
movs r0, 0
lsls r0, 1
adds r2, r0, r1
@@ -2356,7 +2356,7 @@ _08121DA8:
mov pc, r0
.align 2, 0
_08121DB4: .4byte gUnknown_084016BC
-_08121DB8: .4byte gUnknown_02039270
+_08121DB8: .4byte gSelectedOrderFromParty
_08121DBC: .4byte _08121DC0
.align 2, 0
_08121DC0:
diff --git a/asm/choose_party.s b/asm/choose_party.s
index 673933814..9995ceb30 100644
--- a/asm/choose_party.s
+++ b/asm/choose_party.s
@@ -47,7 +47,7 @@ _08121E54: .4byte 0x00000263
sub_8121E58: @ 8121E58
push {lr}
movs r1, 0
- ldr r3, _08121E74 @ =gUnknown_02039270
+ ldr r3, _08121E74 @ =gSelectedOrderFromParty
movs r2, 0
_08121E60:
adds r0, r1, r3
@@ -60,7 +60,7 @@ _08121E60:
pop {r0}
bx r0
.align 2, 0
-_08121E74: .4byte gUnknown_02039270
+_08121E74: .4byte gSelectedOrderFromParty
thumb_func_end sub_8121E58
thumb_func_start sub_8121E78
@@ -192,7 +192,7 @@ _08121F78:
_08121F7E:
cmp r4, 0x2
bhi _08121FA0
- ldr r0, _08121FC4 @ =gUnknown_02039270
+ ldr r0, _08121FC4 @ =gSelectedOrderFromParty
adds r0, r4, r0
ldrb r0, [r0]
cmp r0, r6
@@ -223,7 +223,7 @@ _08121FA0:
bl sub_806BC3C
b _08121FD4
.align 2, 0
-_08121FC4: .4byte gUnknown_02039270
+_08121FC4: .4byte gSelectedOrderFromParty
_08121FC8: .4byte gPlayerParty
_08121FCC:
adds r0, r5, 0
@@ -372,7 +372,7 @@ sub_81220C8: @ 81220C8
ldrb r0, [r0]
cmp r0, 0
beq _081221A2
- ldr r0, _081220F4 @ =gUnknown_02039270
+ ldr r0, _081220F4 @ =gSelectedOrderFromParty
ldrb r0, [r0, 0x2]
cmp r0, 0
bne _08122100
@@ -381,7 +381,7 @@ sub_81220C8: @ 81220C8
.align 2, 0
_081220EC: .4byte 0x0201b000
_081220F0: .4byte 0x00000263
-_081220F4: .4byte gUnknown_02039270
+_081220F4: .4byte gSelectedOrderFromParty
_081220F8:
movs r0, 0x12
b _081221A4
@@ -391,7 +391,7 @@ _081220FC:
_08122100:
movs r5, 0
_08122102:
- ldr r4, _081221B4 @ =gUnknown_02039270
+ ldr r4, _081221B4 @ =gSelectedOrderFromParty
adds r4, r5, r4
ldrb r0, [r4]
movs r1, 0x64
@@ -430,7 +430,7 @@ _0812214A:
add r0, r9
movs r1, 0
ldrsh r4, [r0, r1]
- ldr r0, _081221B4 @ =gUnknown_02039270
+ ldr r0, _081221B4 @ =gSelectedOrderFromParty
adds r6, r5, r0
ldrb r0, [r6]
mov r2, r8
@@ -481,7 +481,7 @@ _081221A4:
pop {r1}
bx r1
.align 2, 0
-_081221B4: .4byte gUnknown_02039270
+_081221B4: .4byte gSelectedOrderFromParty
_081221B8: .4byte gUnknown_030042FC
_081221BC: .4byte 0x0201b000
_081221C0: .4byte 0x00000282
@@ -495,7 +495,7 @@ sub_81221CC: @ 81221CC
lsls r0, 24
lsrs r2, r0, 24
movs r1, 0
- ldr r3, _081221E4 @ =gUnknown_02039270
+ ldr r3, _081221E4 @ =gSelectedOrderFromParty
_081221D6:
adds r0, r1, r3
ldrb r0, [r0]
@@ -504,7 +504,7 @@ _081221D6:
movs r0, 0x1
b _081221F4
.align 2, 0
-_081221E4: .4byte gUnknown_02039270
+_081221E4: .4byte gSelectedOrderFromParty
_081221E8:
adds r0, r1, 0x1
lsls r0, 24
@@ -868,7 +868,7 @@ sub_81224A8: @ 81224A8
.align 2, 0
_081224CC: .4byte gTasks
_081224D0:
- ldr r0, _081224F8 @ =gUnknown_02039270
+ ldr r0, _081224F8 @ =gSelectedOrderFromParty
ldrb r0, [r0]
cmp r0, 0
beq _08122504
@@ -888,7 +888,7 @@ _081224D0:
str r1, [r0]
b _08122520
.align 2, 0
-_081224F8: .4byte gUnknown_02039270
+_081224F8: .4byte gSelectedOrderFromParty
_081224FC: .4byte gTasks
_08122500: .4byte sub_8122450
_08122504:
@@ -1088,7 +1088,7 @@ sub_8122694: @ 8122694
lsls r0, 24
lsrs r5, r0, 24
movs r4, 0
- ldr r3, _081226D4 @ =gUnknown_02039270
+ ldr r3, _081226D4 @ =gSelectedOrderFromParty
ldr r2, _081226D8 @ =gUnknown_03005CE0
_081226A0:
adds r1, r4, r3
@@ -1116,7 +1116,7 @@ _081226CC:
bl sub_8122838
b _08122716
.align 2, 0
-_081226D4: .4byte gUnknown_02039270
+_081226D4: .4byte gSelectedOrderFromParty
_081226D8: .4byte gUnknown_03005CE0
_081226DC:
adds r0, r4, 0x1
@@ -1197,7 +1197,7 @@ sub_8122770: @ 8122770
lsrs r6, r0, 24
movs r4, 0
ldr r5, _08122798 @ =gUnknown_03005CE0
- ldr r3, _0812279C @ =gUnknown_02039270
+ ldr r3, _0812279C @ =gSelectedOrderFromParty
_0812277C:
adds r2, r4, r3
ldrb r1, [r2]
@@ -1214,7 +1214,7 @@ _0812277C:
b _081227BE
.align 2, 0
_08122798: .4byte gUnknown_03005CE0
-_0812279C: .4byte gUnknown_02039270
+_0812279C: .4byte gSelectedOrderFromParty
_081227A0:
ldrb r0, [r3, 0x1]
strb r0, [r3]
@@ -1237,7 +1237,7 @@ _081227BE:
ldrb r0, [r5]
movs r1, 0x70
bl sub_806BC3C
- ldr r4, _081227F8 @ =gUnknown_02039270
+ ldr r4, _081227F8 @ =gSelectedOrderFromParty
ldrb r0, [r4]
cmp r0, 0
beq _081227DA
@@ -1262,7 +1262,7 @@ _081227EC:
pop {r0}
bx r0
.align 2, 0
-_081227F8: .4byte gUnknown_02039270
+_081227F8: .4byte gSelectedOrderFromParty
thumb_func_end sub_8122770
thumb_func_start sub_81227FC
diff --git a/asm/hall_of_fame.s b/asm/hall_of_fame.s
index f0295656c..3ad85d7cf 100644
--- a/asm/hall_of_fame.s
+++ b/asm/hall_of_fame.s
@@ -539,11 +539,11 @@ sub_8142274: @ 8142274
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
- ldr r1, _081422A8 @ =gUnknown_03005EBC
+ ldr r1, _081422A8 @ =gGameContinueCallback
ldr r0, _081422AC @ =sub_8141FC4
str r0, [r1]
movs r0, 0x3
- bl sub_8125D44
+ bl TrySavingData
movs r0, 0x37
bl PlaySE
ldr r1, _081422B0 @ =gTasks
@@ -559,7 +559,7 @@ sub_8142274: @ 8142274
pop {r0}
bx r0
.align 2, 0
-_081422A8: .4byte gUnknown_03005EBC
+_081422A8: .4byte gGameContinueCallback
_081422AC: .4byte sub_8141FC4
_081422B0: .4byte gTasks
_081422B4: .4byte sub_81422B8
diff --git a/asm/reset_rtc_screen.s b/asm/reset_rtc_screen.s
index 1b58b417b..2fbc559c8 100644
--- a/asm/reset_rtc_screen.s
+++ b/asm/reset_rtc_screen.s
@@ -1238,7 +1238,7 @@ _0806AE54: .4byte 0x00004040
_0806AE58: .4byte gSystemText_ClockResetDataSave
_0806AE5C:
movs r0, 0
- bl sub_8125D44
+ bl TrySavingData
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
diff --git a/asm/rom_81258BC.s b/asm/rom_81258BC.s
index a169258ae..483209fd5 100644
--- a/asm/rom_81258BC.s
+++ b/asm/rom_81258BC.s
@@ -21701,7 +21701,7 @@ _08135750: .4byte 0x00000564
_08135754:
movs r2, 0
ldr r4, _0813576C @ =gSaveBlock2 + 0x565
- ldr r3, _08135770 @ =gUnknown_02039270
+ ldr r3, _08135770 @ =gSelectedOrderFromParty
_0813575A:
adds r0, r2, r4
adds r1, r2, r3
@@ -21713,7 +21713,7 @@ _0813575A:
b _0813589A
.align 2, 0
_0813576C: .4byte gSaveBlock2 + 0x565
-_08135770: .4byte gUnknown_02039270
+_08135770: .4byte gSelectedOrderFromParty
_08135774:
ldr r3, _081357C0 @ =0x00000564
adds r0, r5, r3
@@ -22042,7 +22042,7 @@ _08135A10: .4byte 0x00000554
sub_8135A14: @ 8135A14
push {r4,lr}
movs r2, 0
- ldr r4, _08135A34 @ =gUnknown_02039270
+ ldr r4, _08135A34 @ =gSelectedOrderFromParty
ldr r3, _08135A38 @ =gSaveBlock2 + 0x565
_08135A1C:
adds r0, r2, r4
@@ -22057,7 +22057,7 @@ _08135A1C:
pop {r0}
bx r0
.align 2, 0
-_08135A34: .4byte gUnknown_02039270
+_08135A34: .4byte gSelectedOrderFromParty
_08135A38: .4byte gSaveBlock2 + 0x565
thumb_func_end sub_8135A14
@@ -22293,7 +22293,7 @@ _08135BF8:
orrs r0, r1
strb r0, [r2]
movs r0, 0x2
- bl sub_8125D44
+ bl TrySavingData
pop {r4,r5}
pop {r0}
bx r0
diff --git a/include/asm.inc.h b/include/asm.inc.h
index 8189914fa..9ee10aa58 100644
--- a/include/asm.inc.h
+++ b/include/asm.inc.h
@@ -38,14 +38,6 @@ void CreatePokeballSprite(u8 r0, u8 r1, u8 r2, u8 r3, u8 s1, u8 s2, u8 s3, u16 s
// asm/berry_blender.o
void sub_80516C4(u8, u16);
-// src/field_door.o
-void FieldSetDoorOpened(u32, u32);
-void FieldSetDoorClosed(u32, u32);
-s8 FieldAnimateDoorClose(u32, u32);
-s8 FieldAnimateDoorOpen(u32, u32);
-bool8 FieldIsDoorAnimationRunning(void);
-u32 sub_8058790(u32 x, u32 y);
-
// asm/field_map_obj.o
void sub_805AA98();
u8 sub_805AB54(void);
@@ -137,32 +129,11 @@ u8 ZCoordToPriority(u8);
void FieldObjectUpdateZCoord(struct MapObject *pObject);
void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8);
-// src/field_map_obj_helpers.o
-bool8 FreezeMapObject(struct MapObject *);
-void FreezeMapObjects(void);
-void FreezeMapObjectsExceptOne(u8);
-void UnfreezeMapObjects(void);
-void sub_806487C(struct Sprite *sprite, bool8 invisible);
-void sub_8064990(u8, u8);
-
-// asm/field_control_avatar.o
-void FieldClearPlayerInput(struct FieldInput *pStruct);
-void FieldGetPlayerInput(struct FieldInput *pStruct, u16 keys, u16 heldKeys);
-int sub_8068024(struct FieldInput *pStruct);
-u8 *sub_80682A8(struct MapPosition *, u8, u8);
-void overworld_poison_timer_set(void);
-void prev_quest_postbuffer_cursor_backup_reset(void);
-u8 *sub_8068E24(struct MapPosition *);
-u8 *GetFieldObjectScriptPointerForComparison();
-
// asm/field_tasks.o
void SetUpFieldTasks();
void ActivatePerStepCallback(u8);
void ResetFieldTasksArgs(void);
-// asm/clock.o
-void DoTimeBasedEvents(void);
-
// asm/reset_rtc_screen.o
void CB2_InitResetRtcScreen(void);
@@ -203,10 +174,6 @@ u8 sub_8083664(void);
void sub_8083A84(TaskFunc);
s32 sub_8083BF4(u8 id);
-// src/fldeff_emotion.o
-void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3);
-void objc_exclamation_mark_probably(struct Sprite *sprite);
-
// asm/rom_80859BC.o
u8 CreateTrainerSprite_BirchSpeech(u8, u16, u16, u8, void *);
void LoadTrainerGfx_TrainerCard(u8 gender, int, void *);
@@ -259,11 +226,6 @@ u8 sub_80A7D8C(u8 berry, int i, int i1);
void sub_80A7DD4(void);
u8 sub_80A7E5C(u8);
-// src/matsuda_debug_menu.o
-void sub_80AA280(u8);
-void sub_80AA5E8(u8);
-void sub_80AA658(u8);
-
// asm/contest.o
void sub_80AB1B0(void);
void sub_80AE098(u8);
@@ -279,18 +241,6 @@ void CreatePokemartMenu(void *);
void CreateDecorationShop1Menu(void *);
void CreateDecorationShop2Menu(void *);
-// src/script_menu.o
-bool8 sub_80B5054(u8, u8, u8, u8);
-bool8 sub_80B50B0(u8, u8, u8, u8, u8);
-bool8 Multichoice(u8, u8, u8, u8);
-bool8 yes_no_box(u8, u8);
-bool8 sub_80B5578(u8, u8, u8, u8, u8);
-bool8 sub_80B58C4(u16, u8, u8);
-void *picbox_close(void);
-
-// asm/naming_screen.o
-void DoNamingScreen(u8 r0, u8 *r1, u16 r2, u16 r3, u32 s0, MainCallback s4);
-
// asm/secret_base.o
void sub_80BB5B4(void);
u8 sub_80BBB24(void);
@@ -330,15 +280,6 @@ void sub_80C4940(void);
void sub_80C4980(u8);
u8 sub_80C4B34(u8 *);
-// asm/script_pokemon_util_80C4BF0.o
-u8 sub_80C4D50(void);
-void ShowContestWinner(void);
-void HealPlayerParty();
-u8 ScriptGiveMon(u16, u8, u16, u32, u32, u8);
-u8 ScriptGiveEgg(u16);
-void ScriptWildBattle(u16, u8, u16);
-void ScriptSetMonMoveSlot(u8, u16, u8);
-
// asm/fldeff_80C5CD4.o
void DoFieldPoisonEffect(void);
bool32 FieldPoisonEffectIsRunning(void);
@@ -357,16 +298,6 @@ void sub_80C8E1C(u8);
void sub_80C8EBC(u8);
void sub_80C8F34(u8);
-// asm/bike.o
-void MovePlayerOnBike(u8, u16, u16);
-void sub_80E5B38(u16 i, u16 c);
-u8 IsRunningDisallowed(u8);
-bool8 player_should_look_direction_be_enforced_upon_movement(void);
-void BikeClearState(int i, int i1);
-void sub_80E6010(u8 i);
-s16 GetPlayerSpeed(void);
-void sub_80E6084();
-
// asm/easy_chat.o
void sub_80E6764(void);
void sub_80EB3FC(u8 *, u16);
@@ -385,13 +316,6 @@ bool8 sub_80F9344(void);
void sub_80F9368(void);
void sub_80F9438(void);
-// asm/script_pokemon_util_80F99CC.o
-void sub_80F99CC(void);
-
-// src/dewford_trend.o
-void sub_80FA17C(void);
-void sub_80FA4E4(void *, u32, u8);
-
// asm/region_map.o
void sub_80FBFB4(u8 *str, u8 region, u8);
void CopyMapName();
@@ -400,13 +324,6 @@ u8 *CopyLocationName(u8 *dest, u8 location);
// asm/slot_machine.o
void PlaySlotMachine(u8, void *);
-// asm/contest_painting.o
-void sub_8106630(u32);
-
-// asm/rom6.o
-bool8 npc_before_player_of_type(u8);
-u8 oei_task_add(void);
-
// asm/pokeblock.o
void sub_810C994(void);
void sub_810CA6C(s32);
@@ -464,13 +381,6 @@ void sub_8134AC0(void *);
// src/player_pc.o
void NewGameInitPCItems(void);
-// src/intro.o
-void sub_813CE30(u16, u16, u16, u16);
-
-// asm/braille_puzzles.o
-bool8 ShouldDoBrailleStrengthEffect(void);
-void DoBrailleStrengthEffect(void);
-
// asm/intro_credits_graphics.o
void load_intro_part2_graphics(/*TODO: arg types*/);
void sub_8148C78(/*TODO: arg types*/);
@@ -482,14 +392,3 @@ u8 intro_create_brendan_sprite(/*TODO: arg types*/);
u8 intro_create_may_sprite(/*TODO: arg types*/);
u8 intro_create_latios_sprite(/*TODO: arg types*/);
u8 intro_create_latias_sprite(/*TODO: arg types*/);
-
-// asm/name_string_util.o
-void SanitizeNameString(u8*);
-
-// src/agb_flash.o
-u16 ReadFlashId(void);
-u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void));
-void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size);
-u32 ProgramFlashSectorAndVerify();
-u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n);
-u16 IdentifyFlash(void);
diff --git a/include/battle.h b/include/battle.h
index daaa78cd3..4b9144721 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -107,9 +107,12 @@ struct SmallItemStruct
struct BattleStruct /* 0x2000000 */
{
- u8 filler0[0x1601C];
+ u8 filler0[0x15DDE];
+ /*0x15DDE*/ u8 unk15DDE;
+ /*0x15DDF*/ u8 unk15DDF;
+ /*0x15DE0*/ u8 filler15DE0[0x23C]; // 0xAF off?
struct SmallBattleStruct1 unk;
- u8 filler1[0x68]; // 0x2016020
+ u8 filler1[0x68];
/* 0x16089 */ u8 safariFleeRate;
u8 filler1_2[0x42];
/* 0x160CB */ u8 linkPlayerIndex;
diff --git a/include/battle_ai.h b/include/battle_ai.h
new file mode 100644
index 000000000..a5fea3480
--- /dev/null
+++ b/include/battle_ai.h
@@ -0,0 +1,31 @@
+#ifndef GUARD_BATTLEAI_H
+#define GUARD_BATTLEAI_H
+
+#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
+#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8)
+#define AIScriptRead8(ptr) ((ptr)[0])
+#define AIScriptReadPtr(ptr) (u8*) AIScriptRead32(ptr)
+
+enum
+{
+ TARGET,
+ USER
+};
+
+// AI states
+enum
+{
+ AIState_SettingUp,
+ AIState_Processing,
+ AIState_FinishedProcessing,
+ AIState_DoNotProcess
+};
+
+// battle_ai
+void BattleAI_SetupAIData(void);
+void BattleAI_DoAIProcessing(void);
+void sub_810745C(void);
+void AIStackPushVar(u8 *);
+u8 AIStackPop(void);
+
+#endif
diff --git a/include/battle_anim.h b/include/battle_anim.h
new file mode 100644
index 000000000..eb98ebf09
--- /dev/null
+++ b/include/battle_anim.h
@@ -0,0 +1,58 @@
+#ifndef GUARD_BATTLEANIM_H
+#define GUARD_BATTLEANIM_H
+
+#define SCRIPT_READ_8(ptr) ((ptr)[0])
+#define SCRIPT_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8))
+#define SCRIPT_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24))
+
+#define REG_BGnCNT_BITFIELD(n) (*(struct BGCntrlBitfield *)REG_ADDR_BG##n##CNT)
+#define REG_BG1CNT_BITFIELD REG_BGnCNT_BITFIELD(1)
+#define REG_BG2CNT_BITFIELD REG_BGnCNT_BITFIELD(2)
+
+#define EWRAM_14800 ((u16 *)(unk_2000000 + 0x14800))
+#define EWRAM_17800 ((struct UnknownStruct1 *)(unk_2000000 + 0x17800))
+#define EWRAM_17810 ((struct UnknownStruct3 *)(unk_2000000 + 0x17810))
+#define EWRAM_18000 ((u16 *)(unk_2000000 + 0x18000))
+#define EWRAM_19348 (*(u16 *)(unk_2000000 + 0x19348))
+
+struct BGCntrlBitfield
+{
+ volatile u16 priority:2;
+ volatile u16 charBaseBlock:2;
+ volatile u16 field_0_2:4;
+ volatile u16 field_1_0:5;
+ volatile u16 areaOverflowMode:1;
+ volatile u16 screenSize:2;
+};
+
+struct BattleAnimBackground
+{
+ void *image;
+ void *palette;
+ void *tilemap;
+};
+
+struct UnknownStruct1
+{
+ u8 unk0;
+};
+
+struct UnknownStruct2
+{
+ void *unk0;
+ u16 *unk4;
+ u8 unk8;
+};
+
+struct UnknownStruct3
+{
+ u8 unk0;
+ u8 filler1[0xB];
+};
+
+void move_something(const u8 *const moveAnims[], u16 b, u8 c);
+bool8 b_side_obj__get_some_boolean(u8 a);
+void sub_8076034(u8, u8);
+bool8 sub_8076BE0(void);
+
+#endif
diff --git a/include/battle_party_menu.h b/include/battle_party_menu.h
index c808cdcd7..d0ae8da35 100644
--- a/include/battle_party_menu.h
+++ b/include/battle_party_menu.h
@@ -13,8 +13,23 @@ struct UnknownStruct1
s16 unk266;
};
+struct PartyMenuItem
+{
+ const u8 *text;
+ TaskFunc func;
+};
+
+struct PartyPopupMenu
+{
+ u8 unk0;
+ u8 unk1;
+ const u8 *unk4;
+};
+
extern u8 unk_2000000[];
+void SetUpBattlePokemonMenu(u8);
+
#define EWRAM_1609D unk_2000000[0x1609D]
#define EWRAM_1B000 (*(struct UnknownStruct1 *)(unk_2000000 + 0x1B000))
diff --git a/include/battle_setup.h b/include/battle_setup.h
index 2a1a2e717..e88aefe6d 100644
--- a/include/battle_setup.h
+++ b/include/battle_setup.h
@@ -1,84 +1,136 @@
#ifndef GUARD_BATTLE_SETUP_H
#define GUARD_BATTLE_SETUP_H
-// task01_battle_start
-// task_add_01_battle_start
+#define NUM_TRAINER_EYE_TRAINERS 56
+#define TRAINER_REMATCH_STEPS 255
+
+// IV + LEVEL + SPECIES
+struct TrainerPartyMember0
+{
+ u16 iv;
+ u8 level;
+ u16 species;
+};
+
+// IV + LEVEL + SPECIES + MOVES
+struct TrainerPartyMember1
+{
+ u16 iv;
+ u8 level;
+ u16 species;
+ u16 moves[4];
+};
+
+// IV + LEVEL + SPECIES + ITEMS
+struct TrainerPartyMember2
+{
+ u16 iv;
+ u8 level;
+ u16 species;
+ u16 heldItem;
+};
+
+// IV + LEVEL + SPECIES + ITEMS + MOVES
+struct TrainerPartyMember3
+{
+ u16 iv;
+ u8 level;
+ u16 species;
+ u16 heldItem;
+ u16 moves[4];
+};
+
+struct TrainerBattleSpec
+{
+ void *ptr;
+ u8 ptrType;
+};
+
+struct TrainerEyeTrainer
+{
+ u16 trainerNums[5];
+ u16 mapGroup;
+ u16 mapNum;
+};
+
+//void task01_battle_start(u8 taskId);
+//void task_add_01_battle_start(u8 transition, u16 song);
void CheckForSafariZoneAndProceed(void);
void StartBattle_StandardWild(void);
void StartBattle_Roamer(void);
void StartBattle_Safari(void);
-// task_add_01_battle_start_with_music_and_stats
-// StartBattle_WallyTutorial
+//void task_add_01_battle_start_with_music_and_stats(void);
+//void StartBattle_WallyTutorial(void);
void StartBattle_ScriptedWild(void);
-// StartBattle_SouthernIsland
-// StartBattle_Rayquaza
-// StartBattle_GroudonKyogre
-// StartBattle_Regi
+//void StartBattle_SouthernIsland(void);
+//void StartBattle_Rayquaza(void);
+//void StartBattle_GroudonKyogre(void);
+//void StartBattle_Regi(void);
void HandleWildBattleEnd(void);
void HandleScriptedWildBattleEnd(void);
-// GetBattleTerrain
-// GetBattleTransitionTypeByMap
-// GetSumOfPartyMonLevel
-// GetSumOfEnemyPartyLevel
+s8 GetBattleTerrain(void);
+//s8 GetBattleTransitionTypeByMap(void);
+//u16 GetSumOfPartyMonLevel(u8 numMons);
+//u8 GetSumOfEnemyPartyLevel(u16 trainerNum, u8 numMons);
u8 GetWildBattleTransition(void);
u8 GetTrainerBattleTransition(void);
-// GetBattleTowerBattleTransition
-// ChooseStarter
+u8 GetBattleTowerBattleTransition(void);
+//void ChooseStarter(void);
void CB2_GiveStarter(void);
void CB2_StartFirstBattle(void);
void HandleFirstBattleEnd(void);
-// TrainerBattleLoadArg32
-// TrainerBattleLoadArg16
-// TrainerBattleLoadArg8
-// trainerflag_opponent
+//u32 TrainerBattleLoadArg32(u8 *ptr);
+//u16 TrainerBattleLoadArg16(u8 *ptr);
+//u8 TrainerBattleLoadArg8(u8 *ptr);
+//u16 trainerflag_opponent(void);
bool32 battle_exit_is_player_defeat(u32 a1);
-// sub_80822BC
-// TrainerBattleLoadArgs
-// battle_80801F0
+//void sub_80822BC(void);
+//void TrainerBattleLoadArgs(const struct TrainerBattleSpec *specs, u8 *data);
+//void battle_80801F0(void);
u8 *TrainerBattleConfigure(u8 *data);
void TrainerWantsBattle(u8, u8 *);
bool32 GetTrainerFlagFromScriptPointer(u8 *data);
-// sub_8082524
-// sub_8082558
-// sub_8082564
-// sub_808257C
-// unref_sub_8082590
+//void sub_8082524(void);
+//u8 sub_8082558(void);
+//u8 sub_8082564(void);
+//void sub_808257C(void);
+//void unref_sub_8082590(void); // unused
u8 trainer_flag_check(u16);
void trainer_flag_set(u16);
void trainer_flag_clear(u16);
void sub_80825E4(void);
void sub_808260C(void);
-// do_choose_name_or_words_screen
-// sub_80826B0
-// sub_80826D8
+void do_choose_name_or_words_screen(void);
+//void sub_80826B0(void);
+//void sub_80826D8(void);
u8 *sub_80826E8(void);
u8 *sub_8082700(void);
-// sub_8082718
-// PlayTrainerEncounterMusic
-// SanitizeString
+//void sub_8082718(void);
+//void PlayTrainerEncounterMusic(void);
+//u8 *SanitizeString(u8 *str);
u8 *sub_808281C(void);
-// sub_8082830
-// unref_sub_808286C
+u8 *sub_8082830(void);
+//u8 *unref_sub_808286C(void);
u8 *sub_8082880(void);
-// sub_8082894
-// sub_80828B8
-// sub_80828FC
-// sub_80829A8
-// sub_80829E8
-// sub_8082A18
-// sub_8082A54
-// sub_8082A90
-// sub_8082AE4
-// sub_8082B10
-// sub_8082B44
+//s32 sub_8082894(const struct TrainerEyeTrainer *trainers, u16 trainerNum);
+//s32 sub_80828B8(const struct TrainerEyeTrainer *trainers, u16 trainerNum);
+//bool32 sub_80828FC(const struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum);
+//s32 sub_80829A8(const struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum);
+//s32 sub_80829E8(const struct TrainerEyeTrainer *trainers, u16 mapGroup, u16 mapNum);
+//bool8 sub_8082A18(const struct TrainerEyeTrainer *trainers, u16 trainerNum);
+//bool8 sub_8082A54(const struct TrainerEyeTrainer *trainers, u16 trainerNum);
+//u16 sub_8082A90(const struct TrainerEyeTrainer *trainers, u16 trainerNum);
+//void sub_8082AE4(const struct TrainerEyeTrainer *trainers, u16 trainerNum);
+//bool8 sub_8082B10(const struct TrainerEyeTrainer *trainers, u16 trainerNum);
+//bool32 sub_8082B44(void);
void sub_8082B78(void);
-// sub_8082BA4
+//bool32 sub_8082BA4(void);
void sub_8082BD0(u16, u16);
-// sub_8082C0C
-// unref_sub_8082C2C
+s32 sub_8082C0C(u16 mapGroup, u16 mapNum);
+s32 unref_sub_8082C2C(u16 mapGroup, u16 mapNum);
u16 sub_8082C4C(u16 a1);
-// sub_8082C68
-// sub_8082C9C
+//s32 sub_8082C68(void);
+//u8 sub_8082C9C(void);
void sub_8082CB8(void);
#endif // GUARD_BATTLE_SETUP_H
diff --git a/include/bike.h b/include/bike.h
new file mode 100644
index 000000000..decbd1d49
--- /dev/null
+++ b/include/bike.h
@@ -0,0 +1,56 @@
+#ifndef GUARD_BIKE_H
+#define GUARD_BIKE_H
+
+struct UnknownStruct1
+{
+ u32 unk0;
+ u32 unk4;
+ u32 unk8;
+ u32 unkC;
+ const u8 *unk10;
+ const u8 *unk14;
+ u32 unk18;
+};
+
+// Player speeds
+enum
+{
+ SPEED_STANDING,
+ SPEED_NORMAL,
+ SPEED_FAST,
+ SPEED_FASTER,
+ SPEED_FASTEST,
+};
+
+//Acro bike states
+enum
+{
+ ACRO_STATE_NORMAL,
+ ACRO_STATE_TURNING,
+ ACRO_STATE_WHEELIE_STANDING,
+ ACRO_STATE_BUNNY_HOP,
+ ACRO_STATE_WHEELIE_MOVING,
+ ACRO_STATE_5,
+ ACRO_STATE_6,
+};
+
+//Acro bike transitions
+enum
+{
+ ACRO_TRANS_FACE_DIRECTION,
+ ACRO_TRANS_NORMAL_TO_WHEELIE = 3,
+ ACRO_TRANS_WHEELIE_TO_NORMAL,
+};
+
+void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys);
+void sub_80E5B38(u16 a, u16 b);
+bool8 IsRunningDisallowed(u8 tile);
+bool8 IsBikingDisallowedByPlayer(void);
+bool8 player_should_look_direction_be_enforced_upon_movement(void);
+void GetOnOffBike(u8 var);
+void BikeClearState(int var1, int var2);
+void sub_80E6010(u8 var);
+s16 GetPlayerSpeed(void);
+void sub_80E6084(void);
+
+#endif
diff --git a/include/braille_puzzles.h b/include/braille_puzzles.h
new file mode 100644
index 000000000..2b0e2bb96
--- /dev/null
+++ b/include/braille_puzzles.h
@@ -0,0 +1,14 @@
+#ifndef GUARD_BRAILLEPUZZLES_H
+#define GUARD_BRAILLEPUZZLES_H
+
+bool8 ShouldDoBrailleStrengthEffect(void);
+void DoBrailleStrengthEffect(void);
+void UseFlyAncientTomb_Callback(void);
+void UseFlyAncientTomb_Finish(void);
+void Task_BrailleWait(u8 taskId);
+bool32 BrailleWait_CheckButtonPress(void);
+void SealedChamberShakingEffect(u8 taskId);
+bool8 ShouldDoBrailleDigEffect(void);
+void DoBrailleDigEffect(void);
+
+#endif
diff --git a/include/clock.h b/include/clock.h
new file mode 100644
index 000000000..4e6560c91
--- /dev/null
+++ b/include/clock.h
@@ -0,0 +1,8 @@
+#ifndef GUARD_CLOCK_H
+#define GUARD_CLOCK_H
+
+// TODO: time of day and seconds in a day defines
+
+void DoTimeBasedEvents(void);
+
+#endif
diff --git a/include/contest.h b/include/contest.h
new file mode 100644
index 000000000..82520717f
--- /dev/null
+++ b/include/contest.h
@@ -0,0 +1,26 @@
+#ifndef GUARD_CONTEST_H
+#define GUARD_CONTEST_H
+
+struct ContestPokemon
+{
+ /* 0x00 */ u16 species;
+ /* 0x02 */ u8 nickname[POKEMON_NAME_LENGTH];
+ /* 0x0D */ u8 trainerName[8];
+ /* 0x15 */ u8 unk15;
+ /* 0x16 */ u8 unk16;
+ /* 0x17 */ u8 filler17[7];
+ /* 0x1E */ u16 moves[4]; // moves
+ /* 0x26 */ u8 cool; // cool
+ /* 0x27 */ u8 beauty; // beauty
+ /* 0x28 */ u8 cute; // cute
+ /* 0x29 */ u8 smart; // smart
+ /* 0x2A */ u8 tough; // tough
+ /* 0x2B */ u8 sheen; // sheen
+ /* 0x2C */ u8 filler2C[12];
+ /* 0x38 */ u32 unk38;
+ /* 0x3C */ u32 unk3C;
+}; // wow
+
+extern struct ContestPokemon gContestMons[];
+
+#endif // GUARD_CONTEST_H
diff --git a/include/contest_painting.h b/include/contest_painting.h
new file mode 100644
index 000000000..896aa299b
--- /dev/null
+++ b/include/contest_painting.h
@@ -0,0 +1,77 @@
+#ifndef GUARD_CONTESTPAINTING_H
+#define GUARD_CONTESTPAINTING_H
+
+#define MOSAIC_BIT_BG_HSIZE (0)
+#define MOSAIC_BIT_BG_VSIZE (4)
+#define MOSAIC_BIT_OBJ_HSIZE (8)
+#define MOSAIC_BIT_OBJ_VSIZE (12)
+
+enum
+{
+ CONTEST_COOL,
+ CONTEST_BEAUTY,
+ CONTEST_CUTE,
+ CONTEST_SMART,
+ CONTEST_TOUGH,
+};
+
+enum
+{
+ CONTESTRESULT_COOL = 9,
+ CONTESTRESULT_BEAUTY = 13,
+ CONTESTRESULT_CUTE = 2,
+ CONTESTRESULT_SMART = 36,
+ CONTESTRESULT_TOUGH = 6,
+};
+
+struct Unk2015E00
+{
+ u16 unk2015e00[128][32];
+ u16 unk2017e00[0];
+};
+
+struct ContestEntry
+{
+ /*0x00*/ u8 var0;
+ /*0x04*/ u32 var4;
+ /*0x08*/ u16 var8;
+ /*0x0A*/ u8 contestType;
+ /*0x0B*/ u8 pokemon_name[POKEMON_NAME_LENGTH];
+ /*0x15*/ u8 pad15;
+ /*0x16*/ u8 trainer_name[OT_NAME_LENGTH];
+};
+
+struct Unk3000756
+{
+ /*0x00*/ u8 var_0;
+};
+
+struct LabelPair
+{
+ const u8 *prefix;
+ const u8 *suffix;
+};
+
+struct Unk03005E20
+{
+ u8 var_0;
+ u8 pad1[3];
+ u16 (*var_4)[][32];
+ u16 (*var_8)[];
+ u8 pad0C[4];
+ u32 var_10;
+ u16 var_14;
+ u16 var_16;
+ u8 var_18;
+ u8 var_19;
+ u8 var_1A;
+ u8 var_1B;
+ u8 var_1C;
+ u8 var_1D;
+ u8 var_1E;
+ u8 var_1F;
+};
+
+void sub_8106630(u32);
+
+#endif
diff --git a/include/dewford_trend.h b/include/dewford_trend.h
new file mode 100644
index 000000000..713d491b6
--- /dev/null
+++ b/include/dewford_trend.h
@@ -0,0 +1,10 @@
+#ifndef GUARD_DEWFORDTREND_H
+#define GUARD_DEWFORDTREND_H
+
+#define ARRAY_2007800 ((struct EasyChatPair *)(unk_2000000 + 0x7800))
+#define ARRAY_2007900 ((struct EasyChatPair *)(unk_2000000 + 0x7900))
+
+void sub_80FA17C(void);
+void sub_80FA4E4(void *, u32, u8);
+
+#endif
diff --git a/include/field_control_avatar.h b/include/field_control_avatar.h
new file mode 100644
index 000000000..3f17ebee9
--- /dev/null
+++ b/include/field_control_avatar.h
@@ -0,0 +1,13 @@
+#ifndef GUARD_FIELDCONTROLAVATAR_H
+#define GUARD_FIELDCONTROLAVATAR_H
+
+void FieldClearPlayerInput(struct FieldInput *pStruct);
+void FieldGetPlayerInput(struct FieldInput *pStruct, u16 keys, u16 heldKeys);
+int sub_8068024(struct FieldInput *pStruct);
+u8 *sub_80682A8(struct MapPosition *, u8, u8);
+void overworld_poison_timer_set(void);
+void prev_quest_postbuffer_cursor_backup_reset(void);
+u8 *sub_8068E24(struct MapPosition *);
+u8 *GetFieldObjectScriptPointerForComparison();
+
+#endif
diff --git a/include/field_door.h b/include/field_door.h
new file mode 100644
index 000000000..1759e0dc1
--- /dev/null
+++ b/include/field_door.h
@@ -0,0 +1,25 @@
+#ifndef GUARD_FIELDDOOR_H
+#define GUARD_FIELDDOOR_H
+
+struct DoorGraphics
+{
+ u16 metatileNum;
+ u8 unk2;
+ void *tiles;
+ void *palette;
+};
+
+struct DoorAnimFrame
+{
+ u8 time;
+ u16 offset;
+};
+
+void FieldSetDoorOpened(u32, u32);
+void FieldSetDoorClosed(u32, u32);
+s8 FieldAnimateDoorClose(u32, u32);
+s8 FieldAnimateDoorOpen(u32, u32);
+bool8 FieldIsDoorAnimationRunning(void);
+u32 sub_8058790(u32 x, u32 y);
+
+#endif
diff --git a/include/field_map_obj_helpers.h b/include/field_map_obj_helpers.h
new file mode 100644
index 000000000..5498bde12
--- /dev/null
+++ b/include/field_map_obj_helpers.h
@@ -0,0 +1,11 @@
+#ifndef GUARD_FIELDMAPOBJHELP_H
+#define GUARD_FIELDMAPOBJHELP_H
+
+bool8 FreezeMapObject(struct MapObject *);
+void FreezeMapObjects(void);
+void FreezeMapObjectsExceptOne(u8);
+void UnfreezeMapObjects(void);
+void sub_806487C(struct Sprite *sprite, bool8 invisible);
+void sub_8064990(u8, u8);
+
+#endif
diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h
index 3efca3af7..a4f77a172 100644
--- a/include/field_player_avatar.h
+++ b/include/field_player_avatar.h
@@ -78,7 +78,7 @@ u8 GetPlayerAvatarGraphicsIdByCurrentState(void);
void SetPlayerAvatarExtraStateTransition(u8 a, u8 b);
void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d);
// sub_8059B88
-// sub_8059BF4
+void sub_8059BF4(void);
// sub_8059C3C
void sub_8059C94(u8);
// sub_8059D08
diff --git a/include/gba/flash_internal.h b/include/gba/flash_internal.h
index 6156b6c14..cbcfb5466 100644
--- a/include/gba/flash_internal.h
+++ b/include/gba/flash_internal.h
@@ -65,6 +65,10 @@ u16 ReadFlashId(void);
void StartFlashTimer(u8 phase);
void SetReadFlash1(u16 *dest);
void StopFlashTimer(void);
+u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void));
+u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src);
+void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size);
+u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n);
u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData);
@@ -73,4 +77,7 @@ u16 EraseFlashSector_MX(u16 sectorNum);
u16 ProgramFlashByte_MX(u16 sectorNum, u32 offset, u8 data);
u16 ProgramFlashSector_MX(u16 sectorNum, u8 *src);
+// agb_flash_1m
+u16 IdentifyFlash(void);
+
#endif // GUARD_GBA_FLASH_INTERNAL_H
diff --git a/include/global.h b/include/global.h
index 56338a9e8..ad08af84f 100644
--- a/include/global.h
+++ b/include/global.h
@@ -71,6 +71,11 @@ enum
BAG_KEYITEMS
};
+struct TextStruct
+{
+ const u8 *text;
+};
+
struct Coords16
{
s16 x;
@@ -167,7 +172,8 @@ struct RamScript
struct SB1_2EFC_Struct
{
- u8 unknown[0x20];
+ u16 var;
+ u8 unknown[0x1E];
};
struct EasyChatPair
@@ -295,6 +301,25 @@ typedef union OldMan {
struct UnkMauvilleOldManStruct2 oldMan2;
} OldMan;
+struct Unk_SB_Access_Struct1
+{
+ u8 filler0[0xF8];
+ struct SB1_2EFC_Struct sb1_2EFC_struct[5];
+};
+
+struct Unk_SB_Access_Struct2
+{
+ struct SB1_2EFC_Struct sb1_2EFC_struct2[12]; // each is 0x20
+ /*0x2F84*/ u8 filler[0x18];
+};
+
+/*0x2E04*/
+typedef union SB_Struct {
+ struct Unk_SB_Access_Struct1 unkSB1;
+ struct Unk_SB_Access_Struct2 unkSB2;
+} SB_Struct;
+// size is 0x198
+
struct SaveBlock1 /* 0x02025734 */
{
/*0x00*/ struct Coords16 pos;
@@ -364,8 +389,8 @@ struct SaveBlock1 /* 0x02025734 */
/*0x2D94*/ OldMan oldMan;
/*0x2DC0*/ u8 unk_2DC0[0x14];
/*0x2DD4*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff
- /*0x2DFC*/ u8 filler_2DFC[0x100];
- /*0x2EFC*/ struct SB1_2EFC_Struct sb1_2EFC_struct[5];
+ /*0x2DFC*/ u8 filler_2DFC[0x8];
+ /*0x2E04*/ SB_Struct sbStruct;
/*0x2F9C*/ u8 filler_2F9C[0xA0];
/*0x303C*/ u8 filler_303C[0x38];
/*0x3074*/ u8 filler_3074[0x42];
diff --git a/include/intro.h b/include/intro.h
index a859a9ce4..7fdbd9cb0 100644
--- a/include/intro.h
+++ b/include/intro.h
@@ -3,5 +3,6 @@
void c2_copyright_1(void);
void CB2_InitCopyrightScreen(void);
+void sub_813CE30(u16, u16, u16, u16);
#endif // GUARD_INTRO_H
diff --git a/include/matsuda_debug_menu.h b/include/matsuda_debug_menu.h
new file mode 100644
index 000000000..5df53d688
--- /dev/null
+++ b/include/matsuda_debug_menu.h
@@ -0,0 +1,11 @@
+#ifndef GUARD_MATSUDADEBUG_H
+#define GUARD_MATSUDADEBUG_H
+
+#define BIT(n) (1 << (n))
+
+void sub_80AB184(void);
+void sub_80AA280(u8);
+void sub_80AA5E8(u8);
+void sub_80AA658(u8);
+
+#endif
diff --git a/include/name_string_util.h b/include/name_string_util.h
new file mode 100644
index 000000000..110f8cc22
--- /dev/null
+++ b/include/name_string_util.h
@@ -0,0 +1,7 @@
+#ifndef GUARD_NAMESTRINGUTIL_H
+#define GUARD_NAMESTRINGUTIL_H
+
+void PadNameString(u8 *a1, u8 a2);
+void SanitizeNameString(u8 *a1);
+
+#endif
diff --git a/include/naming_screen.h b/include/naming_screen.h
new file mode 100644
index 000000000..b6b464538
--- /dev/null
+++ b/include/naming_screen.h
@@ -0,0 +1,83 @@
+#ifndef GUARD_NAMINGSCREEN_H
+#define GUARD_NAMINGSCREEN_H
+
+#define KBEVENT_NONE 0
+#define KBEVENT_PRESSED_A 5
+#define KBEVENT_PRESSED_B 6
+#define KBEVENT_PRESSED_SELECT 8
+#define KBEVENT_PRESSED_START 9
+
+enum
+{
+ NAMING_SCREEN_TEMPLATE_PLAYER_NAME,
+ NAMING_SCREEN_TEMPLATE_BOX_NAME,
+ NAMING_SCREEN_TEMPLATE_MON_NAME,
+};
+
+struct NamingScreenTemplate
+{
+ u8 unk0;
+ u8 maxChars;
+ u8 unk2;
+ u8 unk3;
+ u8 unk4; //mode?
+ u8 unk5;
+ u8 unk6;
+ u8 unk7;
+ const u8 *title;
+};
+
+struct NamingScreenData
+{
+ /*0x00*/ u8 state;
+ /*0x01*/ u8 templateNum;
+ /*0x02*/ u16 unk2;
+ /*0x04*/ u16 bg1vOffset;
+ /*0x06*/ u16 bg2vOffset;
+ /*0x08*/ u16 unk8;
+ /*0x0A*/ u16 unkA;
+ /*0x0C*/ u8 unkC;
+ /*0x0D*/ u8 unkD;
+ /*0x0E*/ u8 currentPage;
+ /*0x0F*/ u8 cursorSpriteId;
+ /*0x10*/ u8 unk10;
+ /*0x11*/ u8 textBuffer[0x10];
+ /*0x21*/ u8 filler21[0x13];
+ const struct NamingScreenTemplate *template;
+ /*0x38*/ u8 *destBuffer;
+ /*0x3C*/ u16 unk3C; //savedKeyRepeatStartDelay
+ /*0x3E*/ u16 unk3E;
+ /*0x40*/ u16 unk40;
+ /*0x42*/ u32 unk42;
+ /*0x46*/ MainCallback returnCallback;
+};
+
+enum
+{
+ PAGE_UPPER,
+ PAGE_LOWER,
+ PAGE_OTHERS,
+};
+
+enum
+{
+ MAIN_STATE_BEGIN_FADE_IN,
+ MAIN_STATE_WAIT_FADE_IN,
+ MAIN_STATE_HANDLE_INPUT,
+ MAIN_STATE_MOVE_TO_OK_BUTTON,
+ MAIN_STATE_START_PAGE_SWAP,
+ MAIN_STATE_WAIT_PAGE_SWAP,
+ MAIN_STATE_6,
+ MAIN_STATE_UPDATE_SENT_TO_PC_MESSAGE,
+ MAIN_STATE_BEGIN_FADE_OUT,
+};
+
+enum
+{
+ INPUT_STATE_DISABLED,
+ INPUT_STATE_ENABLED,
+};
+
+void DoNamingScreen(u8 r0, u8 *r1, u16 r2, u16 r3, u32 s0, MainCallback s4);
+
+#endif
diff --git a/include/rom4.h b/include/rom4.h
index bb3486c38..5aae277a6 100644
--- a/include/rom4.h
+++ b/include/rom4.h
@@ -20,7 +20,7 @@ struct LinkPlayerMapObject
// sub_8052F5C
// flag_var_implications_of_teleport_
void new_game(void);
-// sub_8053014
+void sub_8053014(void);
void sub_8053050(void);
// sub_805308C
void ResetGameStats(void);
diff --git a/include/rom6.h b/include/rom6.h
new file mode 100644
index 000000000..e7a3ba48e
--- /dev/null
+++ b/include/rom6.h
@@ -0,0 +1,7 @@
+#ifndef GUARD_ROM6_H
+#define GUARD_ROM6_H
+
+bool8 npc_before_player_of_type(u8);
+u8 oei_task_add(void);
+
+#endif
diff --git a/include/save.h b/include/save.h
index fe22e4ad7..b9d4121ec 100644
--- a/include/save.h
+++ b/include/save.h
@@ -12,38 +12,63 @@ struct SaveSection
u8 data[0xFF4];
u16 id;
u16 checksum;
- u32 unknown;
+ u32 security;
u32 counter;
-};
+}; // size is 0x1000
+// headless save section?
struct UnkSaveSection
{
u8 data[0xFF4];
- u32 unknown;
+ u32 security;
+}; // size is 0xFF8
+
+// Ruby/Sapphire's save data is Flash 128K, which is 32 save sectors.
+#define NUM_SECTORS 32 // defined in agb_flash but not in a header
+
+#define UNKNOWN_CHECK_VALUE 0x8012025
+
+// SetDamagedSectorBits states
+enum
+{
+ ENABLE,
+ DISABLE,
+ CHECK // unused
+};
+
+// Do save types
+enum
+{
+ NORMAL_SAVE,
+ LINK_SAVE,
+ EREADER_SAVE, // mossdeep event
+ HOF_SAVE,
+ DIFFERENT_FILE_SAVE,
+ HOF_DELETE_SAVE // unused
};
void ClearSaveData(void);
-void sub_81251B8(void);
-bool32 sub_81251D4(u8 op, u8 bit);
-u8 save_write_to_flash(u16 a1, struct SaveSectionLocation *a2);
-u8 sub_81252D8(u16, struct SaveSectionLocation *);
-u8 sub_81253C8(u8 sector, u8 *data, u16 size);
-u8 sub_8125440(u8, u8 *);
-u32 sub_812546C(struct SaveSectionLocation *a1);
-u32 sub_81254C8(struct SaveSectionLocation *a1);
-u8 sub_812550C(u16 a1, struct SaveSectionLocation *a2);
-u8 sub_812556C(u16 a1, struct SaveSectionLocation *a2);
-u8 sub_81255B8(u16, struct SaveSectionLocation *);
-u8 sub_8125758(u16 a1, struct SaveSectionLocation *a2);
-u8 sub_81257F0(u16 a1, struct SaveSectionLocation *a2);
-u8 sub_812587C(u16 a1, struct SaveSectionLocation *a2);
-u8 sub_81258BC(u16, struct SaveSectionLocation *);
-u8 sub_8125974(struct SaveSectionLocation *);
+void ResetSaveCounters(void);
+bool32 ManipulateSectorBits(u8 op, u8 bit);
+u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *a2);
+u8 HandleWriteSector(u16, const struct SaveSectionLocation *);
+u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size);
+u8 TryWriteSector(u8, u8 *);
+u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location);
+u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location);
+u8 sub_812550C(u16 a1, const struct SaveSectionLocation *location);
+u8 sub_812556C(u16 a1, const struct SaveSectionLocation *location);
+u8 sub_81255B8(u16, const struct SaveSectionLocation *location);
+u8 sub_8125758(u16 a1, const struct SaveSectionLocation *location);
+u8 sub_81257F0(u16 a1, const struct SaveSectionLocation *location);
+u8 sub_812587C(u16 a1, const struct SaveSectionLocation *location);
+u8 sub_81258BC(u16, const struct SaveSectionLocation *location);
+u8 sub_8125974(const struct SaveSectionLocation *location);
u8 sub_8125B88(u8 a1, u8 *data, u16 size);
u8 sub_8125BF8(u8, struct SaveSection *);
-u16 sub_8125C10(void *, u16);
-u8 sub_8125C3C(u8 a1);
-u8 sub_8125D44(u8 a1);
+u16 CalculateChecksum(void *, u16);
+u8 HandleSavingData(u8 saveType);
+u8 TrySavingData(u8 saveType);
u8 sub_8125D80(void);
bool8 sub_8125DA8(void);
u8 sub_8125DDC(void);
diff --git a/include/script_menu.h b/include/script_menu.h
new file mode 100644
index 000000000..7a504556e
--- /dev/null
+++ b/include/script_menu.h
@@ -0,0 +1,31 @@
+#ifndef GUARD_SCRIPTMENU_H
+#define GUARD_SCRIPTMENU_H
+
+struct MultichoiceListStruct
+{
+ struct MenuAction *list;
+ u8 count;
+};
+
+bool8 sub_80B5054(u8 left, u8 top, u8 var3, u8 var4);
+bool8 sub_80B50B0(u8 left, u8 top, u8 var3, u8 var4, u8 var5);
+u16 GetStringWidthInTilesForScriptMenu(const u8 *str);
+void DrawMultichoiceMenu(u8, u8, u8, struct MenuAction *list, u8, u8);
+void sub_80B5230(u8, u8, u8, u8, u8, u8);
+void sub_80B52B4(u8);
+bool8 Multichoice(u8 var1, u8 var2, u8 var3, u8 var4);
+void sub_80B53B4(u8, u8, u8, struct MenuAction *list, u8);
+bool8 yes_no_box(u8 var1, u8 var2);
+bool8 IsScriptActive(void); // unused
+void task_yes_no_maybe(u8);
+bool8 sub_80B5578(u8 left, u8 top, u8 multichoiceId, u8 a4, u8 columnCount);
+void sub_80B5684(u8);
+bool8 TryCreatePCMenu(void);
+void CreatePCMenu(void);
+void sub_80B5838(void);
+void task_picbox(u8 taskId);
+bool8 sub_80B58C4(u16 var1, u8 var2, u8 var3);
+void *picbox_close(void);
+bool8 sub_80B59AC(void);
+
+#endif
diff --git a/include/script_pokemon_80C4.h b/include/script_pokemon_80C4.h
new file mode 100644
index 000000000..6d4e689b5
--- /dev/null
+++ b/include/script_pokemon_80C4.h
@@ -0,0 +1,22 @@
+#ifndef GUARD_SCRIPTPOKE80C4_H
+#define GUARD_SCRIPTPOKE80C4_H
+
+struct MonCoords
+{
+ u8 x, y;
+};
+
+void sub_80C5190(u8);
+void sub_80C5580(void);
+void SetBattleTowerPlayerParty(void);
+void ReducePlayerPartyToThree(void);
+
+u8 sub_80C4D50(void);
+void ShowContestWinner(void);
+void HealPlayerParty();
+u8 ScriptGiveMon(u16, u8, u16, u32, u32, u8);
+u8 ScriptGiveEgg(u16);
+void ScriptWildBattle(u16, u8, u16);
+void ScriptSetMonMoveSlot(u8, u16, u8);
+
+#endif
diff --git a/include/script_pokemon_80F9.h b/include/script_pokemon_80F9.h
new file mode 100644
index 000000000..d65c99c15
--- /dev/null
+++ b/include/script_pokemon_80F9.h
@@ -0,0 +1,17 @@
+#ifndef GUARD_SCRIPTPOKE80F9_H
+#define GUARD_SCRIPTPOKE80F9_H
+
+struct UnknownStruct2018000
+{
+ u8 filler0[0x8];
+ u8 unk8;
+};
+
+extern struct UnknownStruct2018000 unk_2018000;
+
+void sub_80F9A8C(u8);
+void sub_80F9C00(void);
+void sub_80F9E1C(void);
+void sub_80F99CC(void);
+
+#endif
diff --git a/include/trainer_see.h b/include/trainer_see.h
index e4d1fe270..dd04912e7 100644
--- a/include/trainer_see.h
+++ b/include/trainer_see.h
@@ -30,5 +30,7 @@ void sub_80846E4(u8 taskId);
void sub_8084794(u32 var);
void sub_80847C8(void);
void sub_80847D8(u8);
+void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3);
+void objc_exclamation_mark_probably(struct Sprite *sprite);
#endif // GUARD_TRAINER_SEE_H
diff --git a/include/vars.h b/include/vars.h
index e041e33bb..3fc71dc15 100644
--- a/include/vars.h
+++ b/include/vars.h
@@ -23,4 +23,6 @@
#define VAR_BARBOACH_SIZE_RECORD 0x404F
+#define VAR_PORTHOLE 0x40B4
+
#endif // GUARD_VARS_H
diff --git a/ld_script.txt b/ld_script.txt
index 808effb55..cc7a64ecb 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -139,6 +139,7 @@ SECTIONS {
src/pokemon_summary_screen.o(.text);
asm/pokemon_summary_screen.o(.text_80A0958);
src/script_movement.o(.text);
+ src/fldeff_cut.o(.text);
asm/fldeff_cut.o(.text);
asm/mail_data.o(.text);
src/map_name_popup.o(.text);
@@ -167,7 +168,7 @@ SECTIONS {
asm/tv.o(.text_80C1C5C);
src/tv.o(.text_d);
asm/contest_link_80C2020.o(.text);
- asm/script_pokemon_util_80C4BF0.o(.text);
+ src/script_pokemon_util_80C4BF0.o(.text);
src/field_poison.o(.text);
src/pokemon_size_record.o(.text);
asm/fldeff_80C5CD4.o(.text);
@@ -313,7 +314,7 @@ SECTIONS {
data/tilesets.o(.rodata);
data/maps.o(.rodata);
src/fieldmap.o(.rodata);
- data/metatile_behavior.o(.rodata);
+ src/metatile_behavior.o(.rodata);
data/field_door.o(.rodata);
src/field_player_avatar.o(.rodata);
data/field_player_avatar.o(.rodata);
@@ -367,7 +368,7 @@ SECTIONS {
data/contest.o(.rodata);
data/shop.o(.rodata);
src/berry.o(.rodata);
- data/script_menu.o(.rodata);
+ src/script_menu.o(.rodata);
src/naming_screen.o(.rodata);
data/naming_screen.o(.rodata);
data/money.o(.rodata);
@@ -379,6 +380,7 @@ SECTIONS {
data/contest_link_80C2020.o(.rodata);
src/pokemon_size_record.o(.rodata);
data/fldeff_80C5CD4.o(.rodata);
+ src/field_special_scene.o(.rodata);
data/field_special_scene.o(.rodata);
data/rotating_gate.o(.rodata);
data/item_use.o(.rodata);
@@ -412,7 +414,7 @@ SECTIONS {
data/battle_message.o(.rodata);
data/choose_party.o(.rodata);
data/cable_car.o(.rodata);
- data/save.o(.rodata);
+ src/save.o(.rodata);
data/field_effect_helpers.o(.rodata);
data/contest_ai.o(.rodata);
data/rom_81258BC.o(.rodata);
@@ -423,11 +425,10 @@ SECTIONS {
src/credits.o(.rodata);
data/credits.o(.rodata);
src/lottery_corner.o(.rodata);
- data/diploma.o(.rodata);
- data/strings.o(.rodata);
+ src/diploma.o(.rodata);
+ src/strings.o(.rodata);
data/berry_tag_screen.o(.rodata);
src/save_failed_screen.o(.rodata);
- data/save_failed_screen.o(.rodata);
data/pokeblock_feed.o(.rodata);
data/intro_credits_graphics.o(.rodata);
data/evolution_graphics.o(.rodata);
diff --git a/src/agb_flash.c b/src/agb_flash.c
index 34fb4e84a..340d469a7 100644
--- a/src/agb_flash.c
+++ b/src/agb_flash.c
@@ -217,7 +217,7 @@ u32 VerifyFlashSector(u16 sectorNum, u8 *src)
tgt = FLASH_BASE + (sectorNum << gFlash->sector.shift);
size = gFlash->sector.size;
- return verifyFlashSector_Core(src, tgt, size);
+ return verifyFlashSector_Core(src, tgt, size); // return 0 if verified.
}
u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n)
@@ -256,12 +256,12 @@ u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n)
return verifyFlashSector_Core(src, tgt, n);
}
-u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src)
+u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src) // 3rd is unused
{
u8 i;
u32 result;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) // 3 attempts
{
result = ProgramFlashSector(sectorNum, src);
if (result != 0)
@@ -272,7 +272,7 @@ u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src)
break;
}
- return result;
+ return result; // return 0 if verified and programmed.
}
u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n)
diff --git a/src/battle_ai.c b/src/battle_ai.c
index ceab60ca0..07f319e40 100644
--- a/src/battle_ai.c
+++ b/src/battle_ai.c
@@ -8,29 +8,10 @@
#include "rng.h"
#include "species.h"
#include "moves.h"
-
-#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
-#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8)
-#define AIScriptRead8(ptr) ((ptr)[0])
-#define AIScriptReadPtr(ptr) (u8*) AIScriptRead32(ptr)
+#include "battle_ai.h"
extern void sub_801CAF8(u8, u8);
-enum
-{
- TARGET,
- USER
-};
-
-// AI states
-enum
-{
- AIState_SettingUp,
- AIState_Processing,
- AIState_FinishedProcessing,
- AIState_DoNotProcess
-};
-
extern void move_effectiveness_something(u16, u8, u8);
extern u16 gBattleTypeFlags;
@@ -283,12 +264,6 @@ const u16 sDiscouragedPowerfulMoveEffects[] =
0xFFFF
};
-void BattleAI_SetupAIData(void);
-void BattleAI_DoAIProcessing(void);
-void sub_810745C(void);
-void AIStackPushVar(u8 *);
-u8 AIStackPop(void);
-
// if the AI is a Link battle, safari, battle tower, or ereader, it will ignore considering item uses.
void BattleAI_HandleItemUseBeforeAISetup(void)
{
diff --git a/src/battle_anim.c b/src/battle_anim.c
index 4cc337a0c..c381f4f87 100644
--- a/src/battle_anim.c
+++ b/src/battle_anim.c
@@ -6,55 +6,7 @@
#include "sound.h"
#include "sprite.h"
#include "task.h"
-
-#define SCRIPT_READ_8(ptr) ((ptr)[0])
-#define SCRIPT_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8))
-#define SCRIPT_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24))
-
-#define REG_BGnCNT_BITFIELD(n) (*(struct BGCntrlBitfield *)REG_ADDR_BG##n##CNT)
-#define REG_BG1CNT_BITFIELD REG_BGnCNT_BITFIELD(1)
-#define REG_BG2CNT_BITFIELD REG_BGnCNT_BITFIELD(2)
-
-#define EWRAM_14800 ((u16 *)(unk_2000000 + 0x14800))
-#define EWRAM_17800 ((struct UnknownStruct1 *)(unk_2000000 + 0x17800))
-#define EWRAM_17810 ((struct UnknownStruct3 *)(unk_2000000 + 0x17810))
-#define EWRAM_18000 ((u16 *)(unk_2000000 + 0x18000))
-#define EWRAM_19348 (*(u16 *)(unk_2000000 + 0x19348))
-
-struct BGCntrlBitfield
-{
- volatile u16 priority:2;
- volatile u16 charBaseBlock:2;
- volatile u16 field_0_2:4;
- volatile u16 field_1_0:5;
- volatile u16 areaOverflowMode:1;
- volatile u16 screenSize:2;
-};
-
-struct BattleAnimBackground
-{
- void *image;
- void *palette;
- void *tilemap;
-};
-
-struct UnknownStruct1
-{
- u8 unk0;
-};
-
-struct UnknownStruct2
-{
- void *unk0;
- u16 *unk4;
- u8 unk8;
-};
-
-struct UnknownStruct3
-{
- u8 unk0;
- u8 filler1[0xB];
-};
+#include "battle_anim.h"
extern u8 unk_2000000[];
extern u16 gUnknown_02024A6A[4];
@@ -117,7 +69,6 @@ extern void sub_800D7B8(void);
extern u8 obj_id_for_side_relative_to_move();
extern u8 battle_get_per_side_status_permutated();
-void move_something(const u8 *const moveAnims[], u16 b, u8 c);
static void sub_80759D0(void);
static void ScriptCmd_loadsprite(void);
static void ScriptCmd_unloadsprite(void);
@@ -130,8 +81,6 @@ static void ScriptCmd_hang2(void);
static void ScriptCmd_end(void);
static void ScriptCmd_playse(void);
static void ScriptCmd_monbg(void);
-bool8 b_side_obj__get_some_boolean(u8 a);
-void sub_8076034(u8, u8);
static void sub_8076380(void);
static void task_pA_ma0A_obj_to_bg_pal(u8);
static void ScriptCmd_clearmonbg(void);
@@ -148,7 +97,6 @@ static void ScriptCmd_setvar(void);
static void ScriptCmd_ifelse(void);
static void ScriptCmd_jumpif(void);
static void ScriptCmd_jump(void);
-bool8 sub_8076BE0(void);
static void ScriptCmd_fadetobg(void);
static void ScriptCmd_fadetobg_25(void);
static void task_p5_load_battle_screen_elements(u8);
diff --git a/src/battle_anim_80A7E7C.c b/src/battle_anim_80A7E7C.c
index 8cb6fdf9c..474d268a0 100644
--- a/src/battle_anim_80A7E7C.c
+++ b/src/battle_anim_80A7E7C.c
@@ -2,6 +2,7 @@
#include "sprite.h"
#include "task.h"
#include "trig.h"
+#include "battle_anim.h"
#define TASK gTasks[task]
#define SPRITE gSprites[TASK.data[0]]
@@ -16,7 +17,6 @@ extern u8 gUnknown_0202F7C9;
extern u8 obj_id_for_side_relative_to_move(u8 side);
extern void move_anim_task_del(u8 task);
-extern bool8 b_side_obj__get_some_boolean(u8 side);
extern u8 battle_get_side_with_given_state(u8 state);
extern u8 battle_side_get_owner(u8 side);
extern void oamt_set_x3A_32(struct Sprite *sprite, void(*callback)(struct Sprite*));
@@ -27,7 +27,6 @@ extern void sub_80784A8(struct Sprite *sprite);
extern void sub_8078E70(u8 sprite, u8);
extern void obj_id_set_rotscale(u8 sprite, int, int, u16);
extern void sub_8078F40(u8 sprite);
-extern bool8 sub_8076BE0();
extern void sub_8078F9C(u8 sprite);
static void sub_80A7EF0(u8 task);
diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c
index dab97db9b..2d47f4e7d 100644
--- a/src/battle_party_menu.c
+++ b/src/battle_party_menu.c
@@ -11,19 +11,6 @@
#include "text.h"
#include "battle_party_menu.h"
-struct PartyMenuItem
-{
- const u8 *text;
- TaskFunc func;
-};
-
-struct PartyPopupMenu
-{
- u8 unk0;
- u8 unk1;
- const u8 *unk4;
-};
-
extern u8 IsLinkDoubleBattle(void);
extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *);
extern void LoadHeldItemIconGraphics(void);
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 858b6cca1..c9839bb87 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -23,61 +23,12 @@
#include "weather.h"
#include "map_constants.h"
#include "opponent_constants.h"
-
-#define NUM_TRAINER_EYE_TRAINERS 56
-#define TRAINER_REMATCH_STEPS 255
+#include "script_pokemon_80C4.h"
+#include "field_map_obj_helpers.h"
+#include "field_control_avatar.h"
extern u16 gScriptResult;
-// IV + LEVEL + SPECIES
-struct TrainerPartyMember0
-{
- u16 iv;
- u8 level;
- u16 species;
-};
-
-// IV + LEVEL + SPECIES + MOVES
-struct TrainerPartyMember1
-{
- u16 iv;
- u8 level;
- u16 species;
- u16 moves[4];
-};
-
-// IV + LEVEL + SPECIES + ITEMS
-struct TrainerPartyMember2
-{
- u16 iv;
- u8 level;
- u16 species;
- u16 heldItem;
-};
-
-// IV + LEVEL + SPECIES + ITEMS + MOVES
-struct TrainerPartyMember3
-{
- u16 iv;
- u8 level;
- u16 species;
- u16 heldItem;
- u16 moves[4];
-};
-
-struct TrainerBattleSpec
-{
- void *ptr;
- u8 ptrType;
-};
-
-struct TrainerEyeTrainer
-{
- u16 trainerNums[5];
- u16 mapGroup;
- u16 mapNum;
-};
-
extern void (*gUnknown_0300485C)(void);
extern struct Pokemon gEnemyParty[];
@@ -1158,7 +1109,7 @@ u8 *sub_8082700(void)
return gUnknown_081C6C02;
}
-void sub_8082718()
+void sub_8082718(void)
{
ShowFieldMessage(sub_8082880());
}
diff --git a/src/berry.c b/src/berry.c
index 2f8f6a799..e81c7a5ff 100644
--- a/src/berry.c
+++ b/src/berry.c
@@ -6,6 +6,7 @@
#include "main.h"
#include "rng.h"
#include "text.h"
+#include "field_control_avatar.h"
#define BERRY_NAME_LENGTH 6
diff --git a/src/bike.c b/src/bike.c
index a1a3fded9..7693c7539 100644
--- a/src/bike.c
+++ b/src/bike.c
@@ -8,20 +8,10 @@
#include "songs.h"
#include "sound.h"
#include "rom4.h"
+#include "bike.h"
extern u8 sub_80608A4(u8);
-struct UnknownStruct1
-{
- u32 unk0;
- u32 unk4;
- u32 unk8;
- u32 unkC;
- const u8 *unk10;
- const u8 *unk14;
- u32 unk18;
-};
-
extern u8 gUnknown_02039250;
extern u8 gUnknown_02039251;
extern u8 gUnknown_0202E854;
@@ -84,36 +74,6 @@ static void (*const gUnknown_083DB5A4[])(u8) =
sub_80593F4,
};
-// Player speeds
-enum
-{
- SPEED_STANDING,
- SPEED_NORMAL,
- SPEED_FAST,
- SPEED_FASTER,
- SPEED_FASTEST,
-};
-
-//Acro bike states
-enum
-{
- ACRO_STATE_NORMAL,
- ACRO_STATE_TURNING,
- ACRO_STATE_WHEELIE_STANDING,
- ACRO_STATE_BUNNY_HOP,
- ACRO_STATE_WHEELIE_MOVING,
- ACRO_STATE_5,
- ACRO_STATE_6,
-};
-
-//Acro bike transitions
-enum
-{
- ACRO_TRANS_FACE_DIRECTION,
- ACRO_TRANS_NORMAL_TO_WHEELIE = 3,
- ACRO_TRANS_WHEELIE_TO_NORMAL,
-};
-
static void (*const sAcroBikeTransitions[])(u8) =
{
AcroBikeTransition_FaceDirection,
diff --git a/src/clock.c b/src/clock.c
index 85188cd19..fd9e6915a 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -6,6 +6,7 @@
#include "rom4.h"
#include "rtc.h"
#include "wallclock.h"
+#include "clock.h"
extern void sub_80FA220(u16);
extern void sub_80BE8C4(u16);
diff --git a/src/contest_painting.c b/src/contest_painting.c
index 556456814..41f6afabf 100644
--- a/src/contest_painting.c
+++ b/src/contest_painting.c
@@ -8,91 +8,21 @@
#include "sprite.h"
#include "string_util.h"
#include "text.h"
-
-#define MOSAIC_BIT_BG_HSIZE (0)
-#define MOSAIC_BIT_BG_VSIZE (4)
-#define MOSAIC_BIT_OBJ_HSIZE (8)
-#define MOSAIC_BIT_OBJ_VSIZE (12)
-
-enum
-{
- CONTEST_COOL,
- CONTEST_BEAUTY,
- CONTEST_CUTE,
- CONTEST_SMART,
- CONTEST_TOUGH,
-};
-
-enum
-{
- CONTESTRESULT_COOL = 9,
- CONTESTRESULT_BEAUTY = 13,
- CONTESTRESULT_CUTE = 2,
- CONTESTRESULT_SMART = 36,
- CONTESTRESULT_TOUGH = 6,
-};
-
-struct Unk2015E00
-{
- u16 unk2015e00[128][32];
- u16 unk2017e00[0];
-};
-
-struct ContestEntry
-{
- /*0x00*/ u8 var0;
- /*0x04*/ u32 var4;
- /*0x08*/ u16 var8;
- /*0x0A*/ u8 contestType;
- /*0x0B*/ u8 pokemon_name[POKEMON_NAME_LENGTH];
- /*0x15*/ u8 pad15;
- /*0x16*/ u8 trainer_name[OT_NAME_LENGTH];
-};
-
-struct Unk3000756
-{
- /*0x00*/ u8 var_0;
-};
-
-struct LabelPair
-{
- const u8 *prefix;
- const u8 *suffix;
-};
-
-struct Unk03005E20
-{
- u8 var_0;
- u8 pad1[3];
- u16 (*var_4)[][32];
- u16 (*var_8)[];
- u8 pad0C[4];
- u32 var_10;
- u16 var_14;
- u16 var_16;
- u8 var_18;
- u8 var_19;
- u8 var_1A;
- u8 var_1B;
- u8 var_1C;
- u8 var_1D;
- u8 var_1E;
- u8 var_1F;
-};
+#include "contest_painting.h"
extern u8 unk_2000000[];
-extern struct ContestEntry unk_2015de0;
-extern struct Unk2015E00 unk_2015e00;
extern u8 gUnknown_03000750;
extern u16 gUnknown_03000752;
extern u16 gUnknown_03000754;
-extern struct Unk3000756 gUnknown_03000756;
extern u16 (*gUnknown_03005E10)[][32];
-extern struct Unk03005E20 gUnknown_03005E20;
extern u8 gUnknown_03005E40[];
-extern struct ContestEntry *gUnknown_03005E8C;
extern u16 (*gUnknown_03005E90)[];
+extern struct ContestEntry unk_2015de0;
+extern struct Unk2015E00 unk_2015e00;
+extern struct Unk3000756 gUnknown_03000756;
+extern struct Unk03005E20 gUnknown_03005E20;
+extern struct ContestEntry *gUnknown_03005E8C;
extern const struct SpriteSheet gMonFrontPicTable[];
extern const struct MonCoords gMonFrontPicCoords[];
extern const struct SpriteSheet gMonBackPicTable[];
@@ -112,7 +42,7 @@ extern const u8 OtherText_Terminator8[];
extern const u8 OtherText_CenturyLastVenus[];
extern const u8 OtherText_Terminator9[];
extern const u8 OtherText_Terminator10[];
-extern const u8 OtherText_DazzlingSlime[];
+extern const u8 OtherText_DazzlingSmile[];
extern const u8 OtherText_PokeCenterIdol[];
extern const u8 OtherText_Terminator11[];
extern const u8 OtherText_LovelyAndSweet[];
@@ -174,7 +104,7 @@ const struct LabelPair gUnknown_083F60C0[] =
{OtherText_GoodLookingPoke, OtherText_Terminator7},
{OtherText_MarvelousGreat, OtherText_Terminator8},
{OtherText_CenturyLastVenus, OtherText_Terminator9},
- {OtherText_Terminator10, OtherText_DazzlingSlime},
+ {OtherText_Terminator10, OtherText_DazzlingSmile},
{OtherText_PokeCenterIdol, OtherText_Terminator11},
{OtherText_LovelyAndSweet, OtherText_Terminator12},
{OtherText_ThePretty, OtherText_WinningPortrait},
diff --git a/src/dewford_trend.c b/src/dewford_trend.c
index 751d6c416..b2a8e81da 100644
--- a/src/dewford_trend.c
+++ b/src/dewford_trend.c
@@ -4,12 +4,10 @@
#include "link.h"
#include "rng.h"
#include "text.h"
+#include "dewford_trend.h"
extern u8 unk_2000000[];
-#define ARRAY_2007800 ((struct EasyChatPair *)(unk_2000000 + 0x7800))
-#define ARRAY_2007900 ((struct EasyChatPair *)(unk_2000000 + 0x7900))
-
extern u16 gScriptResult;
extern u16 gSpecialVar_0x8004;
diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c
index 992e461eb..a0485444a 100644
--- a/src/field_control_avatar.c
+++ b/src/field_control_avatar.c
@@ -13,6 +13,8 @@
#include "trainer_see.h"
#include "vars.h"
#include "wild_encounter.h"
+#include "bike.h"
+#include "field_control_avatar.h"
struct Coords32
{
diff --git a/src/field_door.c b/src/field_door.c
index f527681ac..4b1390d11 100644
--- a/src/field_door.c
+++ b/src/field_door.c
@@ -3,20 +3,7 @@
#include "field_camera.h"
#include "metatile_behavior.h"
#include "task.h"
-
-struct DoorGraphics
-{
- u16 metatileNum;
- u8 unk2;
- void *tiles;
- void *palette;
-};
-
-struct DoorAnimFrame
-{
- u8 time;
- u16 offset;
-};
+#include "field_door.h"
extern struct DoorAnimFrame gDoorOpenAnimFrames[];
extern struct DoorAnimFrame gDoorCloseAnimFrames[];
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index d52a68271..9a7b25459 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -16,6 +16,8 @@
#include "task.h"
#include "wild_encounter.h"
#include "map_object_constants.h"
+#include "bike.h"
+#include "field_map_obj_helpers.h"
extern u8 gOtherText_OhABite[];
extern u8 gOtherText_PokeOnHook[];
diff --git a/src/field_special_scene.c b/src/field_special_scene.c
index 819a4ab5f..fe7daea0a 100644
--- a/src/field_special_scene.c
+++ b/src/field_special_scene.c
@@ -11,6 +11,17 @@
#include "sprite.h"
#include "task.h"
+#define SECONDS(value) ((signed) (60.0 * value + 0.5))
+
+// porthole states
+enum
+{
+ INIT_PORTHOLE,
+ IDLE_CHECK,
+ EXECUTE_MOVEMENT,
+ EXIT_PORTHOLE,
+};
+
extern s8 gTruckCamera_HorizontalTable[];
extern u8 gUnknown_083D295F[];
@@ -44,20 +55,18 @@ void Task_Truck1(u8 taskId)
u8 mapNum, mapGroup;
register s16 zero asm("r4");
- box1 = GetTruckBoxMovement(data[0] + 30) * 4; // box 1 happens 30 frames earlier than the other 2.
+ box1 = GetTruckBoxMovement(data[0] + 30) * 4; // top box.
sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3, box1 + 3);
- box2 = GetTruckBoxMovement(data[0]) * 2;
+ box2 = GetTruckBoxMovement(data[0]) * 2; // bottom left box.
sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 0, box2 - 3);
- box3 = GetTruckBoxMovement(data[0]) * 4;
+ box3 = GetTruckBoxMovement(data[0]) * 4; // bottom right box.
mapNum = gSaveBlock1.location.mapNum;
mapGroup = gSaveBlock1.location.mapGroup;
zero = 0;
sub_805BD90(3, mapNum, mapGroup, -3, box3);
- data[0]++;
-
- if (data[0] == 0x7530) // timer?
- data[0] = zero;
+ if (++data[0] == SECONDS(500)) // this will never run
+ data[0] = zero; // reset the timer if it gets stuck.
cameraYpan = GetTruckCameraBobbingY(data[0]);
SetCameraPanning(0, cameraYpan);
@@ -142,7 +151,7 @@ void Task_HandleTruckSequence(u8 taskId)
*/
case 0:
data[1]++;
- if (data[1] == 90)
+ if (data[1] == SECONDS(1.5))
{
SetCameraPanningCallback(0);
data[1] = 0; // reset the timer.
@@ -153,7 +162,7 @@ void Task_HandleTruckSequence(u8 taskId)
break;
case 1:
data[1]++;
- if (data[1] == 150)
+ if (data[1] == SECONDS(2.5))
{
pal_fill_black();
data[1] = 0;
@@ -162,7 +171,7 @@ void Task_HandleTruckSequence(u8 taskId)
break;
case 2:
data[1]++;
- if (!gPaletteFade.active && data[1] > 300)
+ if (!gPaletteFade.active && data[1] > SECONDS(5))
{
data[1] = 0;
DestroyTask(data[2]);
@@ -241,22 +250,22 @@ bool8 sub_80C7754(void)
}
}
-void sub_80C77A0(u8 taskId)
+void Task_HandlePorthole(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- u16 *var = GetVarPointer(0x40B4);
+ u16 *var = GetVarPointer(VAR_PORTHOLE);
struct WarpData *location = &gSaveBlock1.location;
switch (data[0])
{
- case 0:
+ case INIT_PORTHOLE: // finish fading before making porthole finish.
if (!gPaletteFade.active)
{
data[1] = 0;
- data[0] = 2;
+ data[0] = EXECUTE_MOVEMENT; // execute movement before checking if should be exited. strange?
}
break;
- case 1:
+ case IDLE_CHECK: // idle and move.
if (gMain.newKeys & A_BUTTON)
data[1] = 1;
if (!sub_80A212C(0xFF, location->mapNum, location->mapGroup))
@@ -271,25 +280,25 @@ void sub_80C77A0(u8 taskId)
return;
}
data[0] = 2;
- case 2:
+ case EXECUTE_MOVEMENT: // execute movement.
if (data[1])
{
- data[0] = 3;
+ data[0] = EXIT_PORTHOLE; // exit porthole.
return;
}
-
- if (*var == 2)
+ // run this once.
+ if (*var == 2) // which direction?
{
exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_083D295F);
- data[0] = 1;
+ data[0] = IDLE_CHECK; // run case 1.
}
else
{
exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_083D2961);
- data[0] = 1;
+ data[0] = IDLE_CHECK; // run case 1.
}
break;
- case 3:
+ case EXIT_PORTHOLE: // exit porthole.
FlagReset(0x4001);
FlagReset(0x4000);
copy_saved_warp2_bank_and_enter_x_to_warp1(0);
@@ -320,7 +329,7 @@ void sub_80C791C(void)
sub_80C78A0();
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = TRUE;
pal_fill_black();
- CreateTask(sub_80C77A0, 80);
+ CreateTask(Task_HandlePorthole, 80);
ScriptContext2_Enable();
}
diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c
index dedb62a90..9166cb3dd 100644
--- a/src/fldeff_strength.c
+++ b/src/fldeff_strength.c
@@ -5,6 +5,8 @@
#include "script.h"
#include "task.h"
#include "text.h"
+#include "braille_puzzles.h"
+#include "rom6.h"
static void sub_811AA18(void);
static void sub_811AA38(void);
diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c
index afa5ea997..47a7d223a 100644
--- a/src/fldeff_teleport.c
+++ b/src/fldeff_teleport.c
@@ -3,6 +3,7 @@
#include "field_effect.h"
#include "field_player_avatar.h"
#include "rom4.h"
+#include "rom6.h"
extern void sub_8087BA8(void);
diff --git a/src/intro.c b/src/intro.c
index 72478b773..fd0a3316e 100644
--- a/src/intro.c
+++ b/src/intro.c
@@ -34,7 +34,7 @@ extern u16 gUnknown_0203931A;
extern u16 gUnknown_02039358;
extern u16 gUnknown_0203935A;
extern u32 gIntroFrameCounter;
-extern struct GcmbStruct gUnknown_03005EE0;
+extern struct GcmbStruct gMultibootProgramStruct;
extern u16 gSaveFileStatus;
extern u8 gReservedSpritePaletteCount;
extern struct SpriteSheet gMonFrontPicTable[];
@@ -851,7 +851,7 @@ static void LoadCopyrightGraphics(u16 a1, u16 a2, u16 a3)
static void SerialCb_CopyrightScreen(void)
{
- GameCubeMultiBoot_HandleSerialInterrupt(&gUnknown_03005EE0);
+ GameCubeMultiBoot_HandleSerialInterrupt(&gMultibootProgramStruct);
}
static u8 SetUpCopyrightScreen(void)
@@ -892,15 +892,15 @@ static u8 SetUpCopyrightScreen(void)
SetVBlankCallback(VBlankCB_Intro);
REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON;
SetSerialCallback(SerialCb_CopyrightScreen);
- GameCubeMultiBoot_Init(&gUnknown_03005EE0);
+ GameCubeMultiBoot_Init(&gMultibootProgramStruct);
default:
UpdatePaletteFade();
gMain.state++;
- GameCubeMultiBoot_Main(&gUnknown_03005EE0);
+ GameCubeMultiBoot_Main(&gMultibootProgramStruct);
break;
case 140:
- GameCubeMultiBoot_Main(&gUnknown_03005EE0);
- if (gUnknown_03005EE0.gcmb_field_2 != 1)
+ GameCubeMultiBoot_Main(&gMultibootProgramStruct);
+ if (gMultibootProgramStruct.gcmb_field_2 != 1)
{
BeginNormalPaletteFade(0xFFFFFFFFu, 0, 0, 0x10, 0);
gMain.state++;
@@ -911,9 +911,9 @@ static u8 SetUpCopyrightScreen(void)
break;
CreateTask(Task_IntroLoadPart1Graphics, 0);
SetMainCallback2(MainCB2_Intro);
- if (gUnknown_03005EE0.gcmb_field_2)
+ if (gMultibootProgramStruct.gcmb_field_2)
{
- GameCubeMultiBoot_ExecuteProgram(&gUnknown_03005EE0);
+ GameCubeMultiBoot_ExecuteProgram(&gMultibootProgramStruct);
}
else
{
@@ -931,7 +931,7 @@ void c2_copyright_1(void)
if (!SetUpCopyrightScreen())
{
sub_8052E4C();
- sub_81251B8();
+ ResetSaveCounters();
sub_8125EC8(0);
if (gSaveFileStatus == 0 || gSaveFileStatus == 2)
ClearSav2();
diff --git a/src/link.c b/src/link.c
index 3a3e9eebf..783f6aecd 100644
--- a/src/link.c
+++ b/src/link.c
@@ -402,7 +402,7 @@ static void LinkTestProcessKeyInput(void)
if (gMain.newKeys & START_BUTTON)
SetSuppressLinkErrorMessage(TRUE);
if (gMain.newKeys & R_BUTTON)
- sub_8125D44(1);
+ TrySavingData(LINK_SAVE);
if (gMain.newKeys & SELECT_BUTTON)
sub_800832C();
if (gLinkTestDebugValuesEnabled)
diff --git a/src/load_save.c b/src/load_save.c
index 0642c4cb3..0add1b0e3 100644
--- a/src/load_save.c
+++ b/src/load_save.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "gba/flash_internal.h"
#include "load_save.h"
#include "asm.h"
#include "main.h"
diff --git a/src/mail.c b/src/mail.c
index 466a64c9c..97c8dab5b 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -9,6 +9,7 @@
#include "string_util.h"
#include "task.h"
#include "text.h"
+#include "name_string_util.h"
struct UnkMailStruct
{
diff --git a/src/main_menu.c b/src/main_menu.c
index f47b3bb47..3c8df52d4 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -17,6 +17,7 @@
#include "task.h"
#include "text.h"
#include "title_screen.h"
+#include "naming_screen.h"
#define BirchSpeechUpdateWindowText() ((u8)MenuUpdateWindowText_OverrideLineLength(24))
diff --git a/src/map_obj_lock.c b/src/map_obj_lock.c
index b1e7bb3df..e500deca0 100644
--- a/src/map_obj_lock.c
+++ b/src/map_obj_lock.c
@@ -3,6 +3,7 @@
#include "asm.h"
#include "field_player_avatar.h"
#include "task.h"
+#include "field_map_obj_helpers.h"
extern u16 gScriptFacing;
diff --git a/src/matsuda_debug_menu.c b/src/matsuda_debug_menu.c
index 66e865ed6..6177d9edb 100644
--- a/src/matsuda_debug_menu.c
+++ b/src/matsuda_debug_menu.c
@@ -10,8 +10,8 @@
#include "string_util.h"
#include "task.h"
#include "text.h"
-
-#define BIT(n) (1 << (n))
+#include "contest.h"
+#include "matsuda_debug_menu.h"
extern u8 gUnknown_0203856C;
extern u8 gUnknown_0203857D[][64];
@@ -63,24 +63,6 @@ extern u8* gMatsudaDebugMenuTextList2[];
extern u8* gMatsudaDebugMenuTextList3[];
extern u8 gMatsudaDebugMenuContestTopLeft[][2];
-struct ContestPokemon
-{
- /* 0x00 */ u16 species;
- /* 0x02 */ u8 nickname[POKEMON_NAME_LENGTH];
- /* 0x0D */ u8 trainerName[8];
- /* 0x15 */ u8 filler15[9];
- /* 0x1E */ u16 moves[4]; // moves
- /* 0x26 */ u8 cool; // cool
- /* 0x27 */ u8 beauty; // beauty
- /* 0x28 */ u8 cute; // cute
- /* 0x29 */ u8 smart; // smart
- /* 0x2A */ u8 tough; // tough
- /* 0x2B */ u8 sheen; // sheen
- /* 0x2C */ u8 filler2C[20];
-};
-
-extern struct ContestPokemon gContestMons[];
-
extern bool8 gReceivedRemoteLinkPlayers;
extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2];
@@ -103,7 +85,6 @@ static void sub_80AA10C(void);
static void sub_80AA5BC(u8);
static void sub_80AA614(u8, u8);
static void sub_80AAD08(struct Sprite *, s8);
-extern void sub_80AB184(void);
extern void sub_80AB47C(void);
extern int sub_80B2A7C(u8); //Don't know return type size
@@ -431,7 +412,7 @@ static void sub_80AA10C(void)
gSprites[spriteId].data3 = zero; // only this assignment of zero is necessary. other replacements of 0 with zero do not change the asm, compiler will treat it the same.
}
-void sub_80AA280(u8 var)
+void sub_80AA280(u8 var) // no?
{
u8 i;
diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c
index 9a049bb40..611a368fe 100644
--- a/src/metatile_behavior.c
+++ b/src/metatile_behavior.c
@@ -1,7 +1,251 @@
#include "global.h"
#include "metatile_behaviors.h"
-extern u8 gUnknown_08308E2C[];
+#define TILE_ATTRIBUTES(three, two, one) (((one) ? 1 : 0) | ((two) ? 2 : 0) | ((three) ? 4 : 0))
+
+static const u8 sTileBitAttributes[] =
+{
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
+ TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
+ TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+ TILE_ATTRIBUTES(FALSE, FALSE, FALSE)
+};
bool8 MetatileBehavior_IsWaterfall(u8);
@@ -13,7 +257,7 @@ bool8 MetatileBehavior_IsATile(u8 var)
bool8 MetatileBehavior_IsEncounterTile(u8 var)
{
- if ((gUnknown_08308E2C[var] & 1) != 0)
+ if ((sTileBitAttributes[var] & 1) != 0)
return TRUE;
else
return FALSE;
@@ -149,7 +393,7 @@ bool8 MetatileBehavior_IsDeepSouthWarp(u8 var)
bool8 MetatileBehavior_IsSurfableWaterOrUnderwater(u8 var)
{
- if ((gUnknown_08308E2C[var] & 2) != 0)
+ if ((sTileBitAttributes[var] & 2) != 0)
return TRUE;
else
return FALSE;
diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c
index 3c867fb01..693b28948 100644
--- a/src/mystery_event_menu.c
+++ b/src/mystery_event_menu.c
@@ -295,7 +295,7 @@ static void CB2_MysteryEventMenu(void)
unkVal = sub_812613C(unk_2000000);
CpuFill32(0, unk_2000000, 0x7D4);
if (!GetEventLoadMessage(gStringVar4, unkVal))
- sub_8125D44(0);
+ TrySavingData(NORMAL_SAVE);
gMain.state++;
break;
case 12:
diff --git a/src/naming_screen.c b/src/naming_screen.c
index aa8066eb5..54a796264 100644
--- a/src/naming_screen.c
+++ b/src/naming_screen.c
@@ -10,64 +10,13 @@
#include "task.h"
#include "text.h"
#include "trig.h"
+#include "naming_screen.h"
extern u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8, u8);
extern u8 CreateMonIcon();
extern void sub_809D51C(void);
extern void MultiplyInvertedPaletteRGBComponents(u16, u8, u8, u8);
-enum
-{
- NAMING_SCREEN_TEMPLATE_PLAYER_NAME,
- NAMING_SCREEN_TEMPLATE_BOX_NAME,
- NAMING_SCREEN_TEMPLATE_MON_NAME,
-};
-
-struct NamingScreenTemplate
-{
- u8 unk0;
- u8 maxChars;
- u8 unk2;
- u8 unk3;
- u8 unk4; //mode?
- u8 unk5;
- u8 unk6;
- u8 unk7;
- const u8 *title;
-};
-
-struct NamingScreenData
-{
- u8 state;
- u8 templateNum;
- u16 unk2;
- u16 bg1vOffset;
- u16 bg2vOffset;
- u16 unk8;
- u16 unkA;
- u8 unkC;
- u8 unkD;
- u8 currentPage;
- u8 cursorSpriteId;
- u8 unk10;
- u8 textBuffer[0x10];
- u8 filler21[0x13];
- const struct NamingScreenTemplate *template;
- u8 *destBuffer;
- u16 unk3C; //savedKeyRepeatStartDelay
- u16 unk3E;
- u16 unk40;
- u32 unk44;
- MainCallback returnCallback;
-};
-
-enum
-{
- PAGE_UPPER,
- PAGE_LOWER,
- PAGE_OTHERS,
-};
-
extern u16 gKeyRepeatStartDelay;
extern u8 unk_2000000[];
@@ -140,7 +89,7 @@ static void sub_80B6CA8(void);
static void sub_80B6D04(void);
static void sub_80B6E44(void);
static void InputInit(void);
-static void sub_80B6438(void);
+static void sub_80B6438(void);
static void sub_80B5E50(void);
static void Task_NamingScreenMain(u8);
static void SetInputState(u8);
@@ -188,31 +137,6 @@ static void sub_80B76E0();
static void nullsub_20(u8, u8);
static void PrintKeyboardCharacters(u8);
-enum
-{
- MAIN_STATE_BEGIN_FADE_IN,
- MAIN_STATE_WAIT_FADE_IN,
- MAIN_STATE_HANDLE_INPUT,
- MAIN_STATE_MOVE_TO_OK_BUTTON,
- MAIN_STATE_START_PAGE_SWAP,
- MAIN_STATE_WAIT_PAGE_SWAP,
- MAIN_STATE_6,
- MAIN_STATE_UPDATE_SENT_TO_PC_MESSAGE,
- MAIN_STATE_BEGIN_FADE_OUT,
-};
-
-enum
-{
- INPUT_STATE_DISABLED,
- INPUT_STATE_ENABLED,
-};
-
-#define KBEVENT_NONE 0
-#define KBEVENT_PRESSED_A 5
-#define KBEVENT_PRESSED_B 6
-#define KBEVENT_PRESSED_SELECT 8
-#define KBEVENT_PRESSED_START 9
-
void DoNamingScreen(u8 templateNum, u8 *destBuffer, u16 c, u16 d, u32 e, MainCallback returnCallback)
{
StoreNamingScreenParameters(templateNum, destBuffer, c, d, e, returnCallback);
@@ -307,7 +231,7 @@ static void GetNamingScreenParameters(void)
namingScreenData.templateNum = task->data[0];
namingScreenData.unk3E = task->data[1];
namingScreenData.unk40 = task->data[2];
- namingScreenData.unk44 = (task->data[3] << 16) | (u16)task->data[4];
+ namingScreenData.unk42 = (task->data[3] << 16) | (u16)task->data[4];
LoadWordFromTwoHalfwords(&task->data[5], (u32 *)&namingScreenData.destBuffer);
LoadWordFromTwoHalfwords(&task->data[7], (u32 *)&namingScreenData.returnCallback);
DestroyTask(taskId);
@@ -1406,7 +1330,7 @@ static void sub_80B6EFC(void)
u8 spriteId;
sub_809D51C();
- spriteId = CreateMonIcon(namingScreenData.unk3E, SpriteCallbackDummy, 0x34, 0x18, 0, namingScreenData.unk44);
+ spriteId = CreateMonIcon(namingScreenData.unk3E, SpriteCallbackDummy, 0x34, 0x18, 0, namingScreenData.unk42);
gSprites[spriteId].oam.priority = 3;
}
@@ -1476,7 +1400,7 @@ static bool8 sub_80B7004(void)
return FALSE;
}
-static void sub_80B7090(void)
+static void sub_80B7090(void) // DoInput?
{
u8 r5;
u8 r4;
diff --git a/src/new_game.c b/src/new_game.c
index 99c7839eb..82a26b52b 100644
--- a/src/new_game.c
+++ b/src/new_game.c
@@ -11,8 +11,9 @@
#include "rom4.h"
#include "rtc.h"
#include "script.h"
+#include "dewford_trend.h"
-extern u8 gUnknown_020297EC;
+extern u8 gDifferentSaveFile;
extern u8 gPlayerPartyCount;
extern u8 gUnknown_03005CE8;
@@ -22,8 +23,9 @@ extern u8 gUnknown_0819FA81[];
const struct SB1_2EFC_Struct gUnknown_08216604 =
{
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
+ 0x0000,
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
@@ -73,7 +75,7 @@ void sub_8052DA8(void)
sub_80B2D1C();
for (i = 0; i < 5; i++)
- gSaveBlock1.sb1_2EFC_struct[i] = gUnknown_08216604;
+ gSaveBlock1.sbStruct.unkSB1.sb1_2EFC_struct[i] = gUnknown_08216604;
}
void sub_8052DE4(void)
@@ -95,7 +97,7 @@ void ClearSav2(void)
void sub_8052E4C(void)
{
- gUnknown_020297EC = 0;
+ gDifferentSaveFile = 0;
sub_808C0A0();
ZeroPlayerPartyMons();
ZeroEnemyPartyMons();
@@ -104,9 +106,10 @@ void sub_8052E4C(void)
void NewGameInitData(void)
{
- if (!gSaveFileStatus || gSaveFileStatus == 2)
+ if (gSaveFileStatus == 0 || gSaveFileStatus == 2)
RtcReset();
- gUnknown_020297EC = 1;
+
+ gDifferentSaveFile = 1;
ZeroPlayerPartyMons();
ZeroEnemyPartyMons();
sub_808C02C();
diff --git a/src/record_mixing.c b/src/record_mixing.c
index b148fa644..57a6790f1 100644
--- a/src/record_mixing.c
+++ b/src/record_mixing.c
@@ -10,6 +10,7 @@
#include "sound.h"
#include "string_util.h"
#include "task.h"
+#include "dewford_trend.h"
extern void *recordMixingSecretBases;
extern void *recordMixingTvShows;
diff --git a/src/rom4.c b/src/rom4.c
index 37c6b84ad..715f5d3f5 100644
--- a/src/rom4.c
+++ b/src/rom4.c
@@ -30,6 +30,10 @@
#include "tileset_anim.h"
#include "weather.h"
#include "wild_encounter.h"
+#include "script_pokemon_80C4.h"
+#include "clock.h"
+#include "field_map_obj_helpers.h"
+#include "field_control_avatar.h"
#ifdef SAPPHIRE
#define LEGENDARY_MUSIC BGM_OOAME // Heavy Rain
diff --git a/src/rom6.c b/src/rom6.c
index 581bd46b4..9ac412ad5 100644
--- a/src/rom6.c
+++ b/src/rom6.c
@@ -8,6 +8,8 @@
#include "sound.h"
#include "sprite.h"
#include "task.h"
+#include "rom6.h"
+#include "braille_puzzles.h"
extern u16 gScriptLastTalked;
extern u32 gUnknown_0202FF84[];
@@ -17,10 +19,6 @@ extern u8 gUnknown_03005CE0;
extern void (*gUnknown_03005CE4)(void);
extern u8 UseRockSmashScript[];
-extern bool8 ShouldDoBrailleDigEffect(void);
-extern void DoBrailleDigEffect(void);
-extern void sub_8053014(void);
-extern void sub_8059BF4(void);
extern void sub_808AB90(void);
extern void task08_080A1C44(u8);
extern u8 sub_80CA1C8(void);
diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c
index 1e2651aa6..dd0e1b966 100644
--- a/src/save_failed_screen.c
+++ b/src/save_failed_screen.c
@@ -20,18 +20,19 @@
#define CLOCK_WIN_TOP (MSG_WIN_TOP - 4)
-struct SaveFailedStruct
+struct SaveFailedClockStruct
{
- u16 unk0;
- u16 unk2;
+ bool16 clockRunning;
+ u16 timer; // appears to be unused, the only case its "used" cannot be reached normally
+ u8 unused[0xE]; // appears to be unused space. alternatively, there could have been multiple clock structs. however, neither of these cases are fulfilled, so the purpose of this space is unknown. one theory is that there is room for 3 more clock structs (2 16-bit values), so its possible GF intended there to be support for link-based save failed screens in case the synchronization failed, or it in fact was present in an earlier build but taken out for reasons.
};
extern u8 unk_2000000[];
-extern u16 gUnknown_0203933C;
-extern struct SaveFailedStruct gUnknown_0203933E;
-extern u32 gUnknown_03005EA8;
-extern u32 gUnknown_03005EBC;
+extern u16 gSaveFailedType;
+extern struct SaveFailedClockStruct gSaveFailedClockInfo;
+extern u32 gDamagedSaveSectors;
+extern u32 gGameContinueCallback;
extern u8 gBirchHelpGfx[];
@@ -44,10 +45,7 @@ extern u8 gSystemText_GameplayEnded[];
extern u8 gBirchGrassTilemap[];
extern u8 gBirchBagTilemap[];
-
-extern const u8 gSaveFailedClockGfx[];
-extern const u8 gSaveFailedClockPal[];
-extern u8 gBirchBagGrassPal[];
+extern u8 gBirchBagGrassPal[0x40];
static const struct OamData sClockOamData =
{
@@ -78,6 +76,9 @@ static const u8 sClockFrames[8][3] =
{ 5, 1, 0 },
};
+static const u8 gSaveFailedClockPal[] = INCBIN_U8("graphics/misc/clock_small.gbapal");
+static const u8 gSaveFailedClockGfx[] = INCBIN_U8("graphics/misc/clock_small.4bpp.lz");
+
static void VBlankCB(void);
static void CB2_SaveFailedScreen(void);
static void CB2_WipeSave(void);
@@ -89,11 +90,11 @@ static bool8 VerifySectorWipe(u16 sector);
static bool8 WipeSector(u16 sector);
static bool8 WipeSectors(u32 sectorBits);
-void DoSaveFailedScreen(u8 var)
+void DoSaveFailedScreen(u8 saveType)
{
SetMainCallback2(CB2_SaveFailedScreen);
- gUnknown_0203933C = var;
- gUnknown_0203933E.unk0 = 0;
+ gSaveFailedType = saveType;
+ gSaveFailedClockInfo.clockRunning = FALSE;
}
static void VBlankCB(void)
@@ -135,8 +136,8 @@ static void CB2_SaveFailedScreen(void)
ResetSpriteData();
ResetTasks();
ResetPaletteFade();
- LoadPalette(&gBirchBagGrassPal, 0, 0x40);
- LoadPalette(&gSaveFailedClockPal, 0x100, 0x20);
+ LoadPalette(&gBirchBagGrassPal, 0, sizeof(gBirchBagGrassPal));
+ LoadPalette(&gSaveFailedClockPal, 0x100, sizeof(gSaveFailedClockPal));
SetUpWindowConfig(&gWindowConfig_81E6C3C);
InitMenuWindow(&gWindowConfig_81E6CE4);
MenuDrawTextWindow(13, CLOCK_WIN_TOP, 16, CLOCK_WIN_TOP + 3); // clock window
@@ -169,11 +170,11 @@ static void CB2_WipeSave(void)
{
u8 wipeTries = 0;
- gUnknown_0203933E.unk0 = 1;
+ gSaveFailedClockInfo.clockRunning = TRUE;
- while (gUnknown_03005EA8 && wipeTries < 3)
+ while (gDamagedSaveSectors != 0 && wipeTries < 3) // while there are still attempts left, keep trying to fix the save sectors.
{
- if (WipeSectors(gUnknown_03005EA8))
+ if (WipeSectors(gDamagedSaveSectors) != FALSE)
{
MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1);
@@ -183,9 +184,9 @@ static void CB2_WipeSave(void)
MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
MenuPrint(gSystemText_CheckCompleteSaveAttempt, 2, MSG_WIN_TOP + 1);
- sub_8125C3C(gUnknown_0203933C);
+ HandleSavingData(gSaveFailedType);
- if (gUnknown_03005EA8)
+ if (gDamagedSaveSectors != 0)
{
#ifdef BUGFIX_SAVEFAILEDSCREEN2
MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
@@ -206,9 +207,10 @@ static void CB2_WipeSave(void)
{
MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
- if (!gUnknown_03005EBC) // cant continue game.
+ // no callback exists, so the game cannot continue.
+ if (gGameContinueCallback == 0)
MenuPrint(gSystemText_SaveCompletedGameEnd, 2, MSG_WIN_TOP + 1);
- else // can continue game.
+ else // callback exists, so continue
MenuPrint(gSystemText_SaveCompletedPressA, 2, MSG_WIN_TOP + 1);
}
@@ -217,7 +219,7 @@ static void CB2_WipeSave(void)
static void CB2_GameplayCannotBeContinued(void)
{
- gUnknown_0203933E.unk0 = 0;
+ gSaveFailedClockInfo.clockRunning = FALSE;
if (gMain.newKeys & A_BUTTON)
{
@@ -230,13 +232,11 @@ static void CB2_GameplayCannotBeContinued(void)
static void CB2_FadeAndReturnToTitleScreen(void)
{
- u8 zero;
-
- gUnknown_0203933E.unk0 = zero = 0;
+ gSaveFailedClockInfo.clockRunning = FALSE;
if (gMain.newKeys & A_BUTTON)
{
- BeginNormalPaletteFade(0xFFFFFFFF, 0, zero, 16, 0);
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
SetVBlankCallback(VBlankCB);
SetMainCallback2(CB2_ReturnToTitleScreen);
}
@@ -246,14 +246,14 @@ static void CB2_ReturnToTitleScreen(void)
{
if (!UpdatePaletteFade())
{
- if (!gUnknown_03005EBC)
+ if (gGameContinueCallback == 0) // no callback exists, so do a soft reset.
{
DoSoftReset();
}
else
{
- SetMainCallback2((MainCallback)gUnknown_03005EBC);
- gUnknown_03005EBC = 0;
+ SetMainCallback2((MainCallback)gGameContinueCallback);
+ gGameContinueCallback = 0;
}
}
}
@@ -266,7 +266,7 @@ static void VBlankCB_UpdateClockGraphics(void)
gMain.oamBuffer[0].x = 112;
gMain.oamBuffer[0].y = (CLOCK_WIN_TOP + 1) * 8;
- if (gUnknown_0203933E.unk0)
+ if (gSaveFailedClockInfo.clockRunning != FALSE)
{
gMain.oamBuffer[0].tileNum = sClockFrames[n][0];
gMain.oamBuffer[0].matrixNum = (sClockFrames[n][2] << 4) | (sClockFrames[n][1] << 3);
@@ -278,8 +278,8 @@ static void VBlankCB_UpdateClockGraphics(void)
CpuFastCopy(gMain.oamBuffer, (void *)OAM, 4);
- if (gUnknown_0203933E.unk2)
- gUnknown_0203933E.unk2--;
+ if (gSaveFailedClockInfo.timer) // maybe was used for debugging?
+ gSaveFailedClockInfo.timer--;
}
static bool8 VerifySectorWipe(u16 sector)
diff --git a/src/save_menu_util.c b/src/save_menu_util.c
index 7790bbb1b..7899fabb1 100644
--- a/src/save_menu_util.c
+++ b/src/save_menu_util.c
@@ -81,22 +81,18 @@ void PrintSaveMapName(s16 x, s16 y)
void PrintSaveBadges(s16 x, s16 y)
{
char badges[16];
- u8 badgeCount;
MenuPrint(gOtherText_Badges, x, y);
- badgeCount = GetBadgeCount();
- ConvertIntToDecimalString(badges, badgeCount);
+ ConvertIntToDecimalString(badges, GetBadgeCount());
MenuPrint_RightAligned(badges, x + 12, y);
}
void PrintSavePokedexCount(s16 x, s16 y)
{
char pokedex[16];
- u16 pokedexCount;
MenuPrint(gOtherText_Pokedex, x, y);
- pokedexCount = GetPokedexSeenCount();
- ConvertIntToDecimalStringN(pokedex, pokedexCount, 1, 3);
+ ConvertIntToDecimalStringN(pokedex, GetPokedexSeenCount(), 1, 3);
MenuPrint_RightAligned(pokedex, x + 12, y);
}
diff --git a/src/scrcmd.c b/src/scrcmd.c
index a13a42e87..b780cc6b4 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -9,6 +9,8 @@
#include "field_effect.h"
#include "field_message_box.h"
#include "field_player_avatar.h"
+#include "field_map_obj_helpers.h"
+#include "field_door.h"
#include "item.h"
#include "main.h"
#include "map_obj_lock.h"
@@ -23,6 +25,11 @@
#include "sound.h"
#include "string_util.h"
#include "weather.h"
+#include "script_menu.h"
+#include "script_pokemon_80F9.h"
+#include "script_pokemon_80C4.h"
+#include "clock.h"
+#include "contest_painting.h"
typedef u16 (*SpecialFunc)(void);
typedef void (*NativeFunc)(void);
diff --git a/src/script_movement.c b/src/script_movement.c
index 781235986..dcd772d5f 100644
--- a/src/script_movement.c
+++ b/src/script_movement.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "asm.h"
#include "task.h"
+#include "field_map_obj_helpers.h"
extern const u32 gBitTable[];
extern u8 *gUnknown_020384F8[];
diff --git a/src/script_pokemon_util_80F99CC.c b/src/script_pokemon_util_80F99CC.c
index 5e57ef84b..1a848c665 100644
--- a/src/script_pokemon_util_80F99CC.c
+++ b/src/script_pokemon_util_80F99CC.c
@@ -9,6 +9,7 @@
#include "pokemon.h"
#include "text.h"
#include "string_util.h"
+#include "script_pokemon_80F9.h"
extern u8 gPlayerPartyCount;
extern u16 gSpecialVar_0x8004;
@@ -36,18 +37,6 @@ extern void sub_8123138(u8);
extern u8 sub_8040574(struct Pokemon *party);
extern void sub_809D9F0(struct Pokemon *party, u8, u8, void *, u32);
-void sub_80F9A8C(u8);
-void sub_80F9C00(void);
-void sub_80F9E1C(void);
-
-struct UnknownStruct2018000
-{
- u8 filler0[0x8];
- u8 unk8;
-};
-
-extern struct UnknownStruct2018000 unk_2018000;
-
void sub_80F99CC(void)
{
u8 taskId;
diff --git a/src/start_menu.c b/src/start_menu.c
index 9c10c4cae..d1344ce90 100644
--- a/src/start_menu.c
+++ b/src/start_menu.c
@@ -22,6 +22,7 @@
#include "task.h"
#include "trainer_card.h"
#include "weather.h"
+#include "field_map_obj_helpers.h"
//Menu actions
enum {
@@ -41,7 +42,7 @@ static u8 (*saveDialogCallback)(void);
static u8 saveDialogTimer; //Number of frames to keep the window on screen after save was completed
static bool8 savingComplete;
-extern bool8 gUnknown_020297EC;
+extern bool8 gDifferentSaveFile;
extern u16 gSaveFileStatus;
extern u16 gScriptResult;
extern u8 (*gCallback_03004AE8)(void);
@@ -586,7 +587,6 @@ static u8 SaveDialogCB_DisplayConfirmMessage(void)
{
MenuZeroFillScreen();
HandleDrawSaveWindowInfo(0, 0);
- //"Would you like to save the game?"
DisplaySaveMessageWithCallback(gSaveText_WouldYouLikeToSave, SaveDialogCB_DisplayConfirmYesNoMenu);
return SAVE_IN_PROGRESS;
}
@@ -608,7 +608,7 @@ static u8 SaveDialogCB_ProcessConfirmYesNoMenu(void)
{
case 0:
case 2:
- if (gUnknown_020297EC == FALSE)
+ if (gDifferentSaveFile == FALSE)
{
saveDialogCallback = SaveDialogCB_SaveFileExists;
return SAVE_IN_PROGRESS;
@@ -632,7 +632,7 @@ static u8 SaveDialogCB_ProcessConfirmYesNoMenu(void)
static u8 SaveDialogCB_SaveFileExists(void)
{
DisplaySaveMessageWithCallback(
- gUnknown_020297EC == TRUE ? gSaveText_ThereIsADifferentFile : gSaveText_ThereIsAlreadyAFile,
+ gDifferentSaveFile == TRUE ? gSaveText_ThereIsADifferentFile : gSaveText_ThereIsAlreadyAFile,
SaveDialogCB_DisplayOverwriteYesNoMenu);
return SAVE_IN_PROGRESS;
}
@@ -670,20 +670,20 @@ static u8 SaveDialogCB_DisplaySavingMessage(void)
static u8 SaveDialogCB_DoSave(void)
{
- u8 a;
+ bool8 saveSucceeded;
IncrementGameStat(0);
- if (gUnknown_020297EC == TRUE)
+ if (gDifferentSaveFile == TRUE)
{
- a = sub_8125D44(4);
- gUnknown_020297EC = FALSE;
+ saveSucceeded = TrySavingData(DIFFERENT_FILE_SAVE);
+ gDifferentSaveFile = FALSE;
}
else
{
- a = sub_8125D44(0);
+ saveSucceeded = TrySavingData(NORMAL_SAVE);
}
- if (a == 1)
+ if (saveSucceeded == TRUE)
{
//"(Player) saved the game."
DisplaySaveMessageWithCallback(gSaveText_PlayerSavedTheGame, SaveDialogCB_SaveSuccess);
diff --git a/src/task.c b/src/task.c
index e79929c63..3c28a66d9 100644
--- a/src/task.c
+++ b/src/task.c
@@ -1,48 +1,48 @@
#include "global.h"
#include "task.h"
-#define NUM_TASKS 16
-
+#define ACTIVE_SENTINEL 0x10
#define HEAD_SENTINEL 0xFE
#define TAIL_SENTINEL 0xFF
-struct Task gTasks[NUM_TASKS];
+// gTasks is a queue of the active 16 tasks
+struct Task gTasks[ACTIVE_SENTINEL];
static void InsertTask(u8 newTaskId);
static u8 FindFirstActiveTask();
void ResetTasks()
{
- u8 i;
+ u8 taskId;
- for (i = 0; i < NUM_TASKS; i++)
+ for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++)
{
- gTasks[i].isActive = FALSE;
- gTasks[i].func = TaskDummy;
- gTasks[i].prev = i;
- gTasks[i].next = i + 1;
- gTasks[i].priority = -1;
- memset(gTasks[i].data, 0, sizeof(gTasks[i].data));
+ gTasks[taskId].isActive = FALSE;
+ gTasks[taskId].func = TaskDummy;
+ gTasks[taskId].prev = taskId;
+ gTasks[taskId].next = taskId + 1;
+ gTasks[taskId].priority = -1;
+ memset(gTasks[taskId].data, 0, sizeof(gTasks[taskId].data));
}
gTasks[0].prev = HEAD_SENTINEL;
- gTasks[NUM_TASKS - 1].next = TAIL_SENTINEL;
+ gTasks[ACTIVE_SENTINEL - 1].next = TAIL_SENTINEL;
}
u8 CreateTask(TaskFunc func, u8 priority)
{
- u8 i;
+ u8 taskId;
- for (i = 0; i < NUM_TASKS; i++)
+ for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++)
{
- if (!gTasks[i].isActive)
+ if (!gTasks[taskId].isActive)
{
- gTasks[i].func = func;
- gTasks[i].priority = priority;
- InsertTask(i);
- memset(gTasks[i].data, 0, sizeof(gTasks[i].data));
- gTasks[i].isActive = TRUE;
- return i;
+ gTasks[taskId].func = func;
+ gTasks[taskId].priority = priority;
+ InsertTask(taskId);
+ memset(gTasks[taskId].data, 0, sizeof(gTasks[taskId].data));
+ gTasks[taskId].isActive = TRUE;
+ return taskId;
}
}
@@ -53,9 +53,9 @@ static void InsertTask(u8 newTaskId)
{
u8 taskId = FindFirstActiveTask();
- if (taskId == NUM_TASKS)
+ if (taskId == ACTIVE_SENTINEL)
{
- // The new task is the only task.
+ // The task system inserts from the top downwards starting from the end (0xFF) to 0. If FindFirstActiveTask returned the value equivalent to ACTIVE_SENTINEL, it means it is the only task because it searched the entire queue.
gTasks[newTaskId].prev = HEAD_SENTINEL;
gTasks[newTaskId].next = TAIL_SENTINEL;
return;
@@ -69,12 +69,14 @@ static void InsertTask(u8 newTaskId)
// so we insert the new task before it.
gTasks[newTaskId].prev = gTasks[taskId].prev;
gTasks[newTaskId].next = taskId;
+
if (gTasks[taskId].prev != HEAD_SENTINEL)
- gTasks[gTasks[taskId].prev].next = newTaskId;
+ gTasks[gTasks[taskId].prev].next = newTaskId; // as long as we are not at the end, insert the newTask appropriately.
+
gTasks[taskId].prev = newTaskId;
return;
}
- if (gTasks[taskId].next == TAIL_SENTINEL)
+ if (gTasks[taskId].next == TAIL_SENTINEL) // we did not find a space for the task, so overwrite the last task as it is the lowest priority.
{
// We've reached the end.
gTasks[newTaskId].prev = taskId;
@@ -82,7 +84,7 @@ static void InsertTask(u8 newTaskId)
gTasks[taskId].next = newTaskId;
return;
}
- taskId = gTasks[taskId].next;
+ taskId = gTasks[taskId].next; // neither the priority was lower, nor the end. check the next task.
}
}
@@ -112,11 +114,11 @@ void DestroyTask(u8 taskId)
}
}
-void RunTasks()
+void RunTasks(void)
{
u8 taskId = FindFirstActiveTask();
- if (taskId != NUM_TASKS)
+ if (taskId != ACTIVE_SENTINEL)
{
do
{
@@ -126,11 +128,11 @@ void RunTasks()
}
}
-static u8 FindFirstActiveTask()
+static u8 FindFirstActiveTask(void)
{
u8 taskId;
- for (taskId = 0; taskId < NUM_TASKS; taskId++)
+ for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++)
if (gTasks[taskId].isActive == TRUE && gTasks[taskId].prev == HEAD_SENTINEL)
break;
@@ -173,7 +175,7 @@ bool8 FuncIsActiveTask(TaskFunc func)
{
u8 i;
- for (i = 0; i < NUM_TASKS; i++)
+ for (i = 0; i < ACTIVE_SENTINEL; i++)
if (gTasks[i].isActive == TRUE && gTasks[i].func == func)
return TRUE;
@@ -184,19 +186,19 @@ u8 FindTaskIdByFunc(TaskFunc func)
{
s32 i;
- for (i = 0; i < NUM_TASKS; i++)
+ for (i = 0; i < ACTIVE_SENTINEL; i++)
if (gTasks[i].isActive == TRUE && gTasks[i].func == func)
return (u8)i;
return -1;
}
-u8 GetTaskCount()
+u8 GetTaskCount(void)
{
u8 i;
u8 count = 0;
- for (i = 0; i < NUM_TASKS; i++)
+ for (i = 0; i < ACTIVE_SENTINEL; i++)
if (gTasks[i].isActive == TRUE)
count++;
diff --git a/src/trainer_card.c b/src/trainer_card.c
index 5239c6c90..0070e8a9a 100644
--- a/src/trainer_card.c
+++ b/src/trainer_card.c
@@ -14,6 +14,7 @@
#include "sprite.h"
#include "string_util.h"
#include "task.h"
+#include "script_pokemon_80C4.h"
typedef void (*Callback)(void);
diff --git a/src/trainer_see.c b/src/trainer_see.c
index 9d58faab8..56085f9be 100644
--- a/src/trainer_see.c
+++ b/src/trainer_see.c
@@ -1,5 +1,4 @@
#include "global.h"
-#include "trainer_see.h"
#include "asm.h"
#include "asm_fieldmap.h"
#include "battle_setup.h"
@@ -9,6 +8,7 @@
#include "script.h"
#include "sprite.h"
#include "task.h"
+#include "trainer_see.h"
extern bool8 (*gIsTrainerInRange[])(struct MapObject *, u16, s16, s16);
extern bool8 (*gTrainerSeeFuncList[])(u8, struct Task *, struct MapObject *);
diff --git a/sym_common.txt b/sym_common.txt
index 4a404ccf8..56f4cdf2f 100644
--- a/sym_common.txt
+++ b/sym_common.txt
@@ -309,22 +309,22 @@ gUnknown_03005E94: @ 3005E94
gUnknown_03005E98: @ 3005E98
.space 0x4
-gUnknown_03005E9C: @ 3005E9C
+gLastWrittenSector: @ 3005E9C
.space 0x4
-gUnknown_03005EA0: @ 3005EA0
+gLastSaveCounter: @ 3005EA0
.space 0x4
-gUnknown_03005EA4: @ 3005EA4
+gLastKnownGoodSector: @ 3005EA4
.space 0x4
-gUnknown_03005EA8: @ 3005EA8
+gDamagedSaveSectors: @ 3005EA8
.space 0x4
-gUnknown_03005EAC: @ 3005EAC
+gSaveCounter: @ 3005EAC
.space 0x4
-gUnknown_03005EB0: @ 3005EB0
+gFastSaveSection: @ 3005EB0
.space 0x4
gUnknown_03005EB4: @ 3005EB4
@@ -333,13 +333,13 @@ gUnknown_03005EB4: @ 3005EB4
gSaveFileStatus: @ 3005EB8
.space 0x4
-gUnknown_03005EBC: @ 3005EBC
+gGameContinueCallback: @ 3005EBC
.space 0x14
gIntroFrameCounter: @ 3005ED0
.space 0x10
-gUnknown_03005EE0: @ 3005EE0
+gMultibootProgramStruct: @ 3005EE0
.space 0x2C
gUnknown_03005F0C: @ 3005F0C
diff --git a/sym_ewram.txt b/sym_ewram.txt
index 10ebf59c9..fd8d4bb49 100644
--- a/sym_ewram.txt
+++ b/sym_ewram.txt
@@ -335,7 +335,7 @@ gUnknown_020297E4: @ 20297E4
gUnknown_020297E8: @ 20297E8
.space 0x4
-gUnknown_020297EC: @ 20297EC
+gDifferentSaveFile: @ 20297EC
.space 0x1
gUnknown_020297ED: @ 20297ED
@@ -512,13 +512,7 @@ gUnknown_0202FF58: @ 202FF58
.include "src/wild_encounter.o"
gUnknown_0202FF84: @ 202FF84
- .space 0x4
-
-gUnknown_0202FF88: @ 202FF88
- .space 0x4
-
-gUnknown_0202FF8C: @ 202FF8C
- .space 0x18
+ .space 0x20
gUnknown_0202FFA4: @ 202FFA4
.space 0x4
@@ -937,7 +931,7 @@ gUnknown_0203926A: @ 203926A
gUnknown_0203926C: @ 203926C
.space 0x4
-gUnknown_02039270: @ 2039270
+gSelectedOrderFromParty: @ 2039270
.space 0x4
gUnknown_02039274: @ 2039274
@@ -961,7 +955,7 @@ gUnknown_0203927C: @ 203927C
gUnknown_0203927D: @ 203927D
.space 0x7
-gUnknown_02039284: @ 2039284
+gLastSaveSectorStatus: @ 2039284
.space 0x4
gUnknown_02039288: @ 2039288
@@ -1025,12 +1019,13 @@ gUnknown_0203932E: @ 203932E
gUnknown_02039338: @ 2039338
.space 0x4
-gUnknown_0203933C: @ 203933C
+gSaveFailedType: @ 203933C
.space 0x2
-gUnknown_0203933E: @ 203933E
+gSaveFailedClockInfo: @ 203933E
.space 0x12
+ .align 2
gUnknown_02039350: @ 2039350
.space 0x8