Skip to content

Commit

Permalink
Make Stats Viewer an item
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseurae committed Oct 16, 2024
1 parent 863e614 commit 071c333
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 101 deletions.
3 changes: 3 additions & 0 deletions config.asm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
; Auto-change to lowercase after first letter in naming screen.
.definelabel AUTOCASE, 1

; Adds an item which allows you to see your Pokemon's base stats, IVs and EVs.
.definelabel STATS_VIEWER, 1

; Bugfixes
; --------

Expand Down
2 changes: 1 addition & 1 deletion include/constants/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
#define ITEM_GASEOUS_ZINC 223
#define ITEM_POKEGEAR 224
#define ITEM_PACHI_SWORD 225
#define ITEM_0E2 226
#define ITEM_STATS_VIEWER 226
#define ITEM_0E3 227
#define ITEM_0E4 228
#define ITEM_0E5 229
Expand Down
50 changes: 25 additions & 25 deletions include/naming_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "main.h"

#define KBEVENT_NONE 0
#define KBEVENT_PRESSED_A 5
#define KBEVENT_PRESSED_B 6
#define KBEVENT_NONE 0
#define KBEVENT_PRESSED_A 5
#define KBEVENT_PRESSED_B 6
#define KBEVENT_PRESSED_SELECT 8
#define KBEVENT_PRESSED_START 9
#define KBEVENT_PRESSED_START 9

enum
{
Expand Down Expand Up @@ -36,27 +36,27 @@ enum

struct NamingScreen
{
/*0x00*/ u8 state;
/*0x01*/ u8 templateNum;
/*0x02*/ u16 nameLeftOffset;
/*0x04*/ u16 bg1vOffset;
/*0x06*/ u16 bg2vOffset;
/*0x08*/ u16 bg1Priority;
/*0x0A*/ u16 bg2Priority;
/*0x0C*/ u8 bgToReveal;
/*0x0D*/ u8 bgToHide;
/*0x0E*/ u8 currentPage;
/*0x0F*/ u8 cursorSpriteId;
/*0x10*/ u8 pageIndicatorSpriteId;
/*0x11*/ u8 textBuffer[0x10];
/*0x21*/ u8 filler21[0x13];
/*0x34*/ const struct NamingScreenTemplate *template;
/*0x38*/ u8 *destBuffer;
/*0x3C*/ u16 keyRepeatStartDelayCopy;
/*0x3E*/ u16 speciesOrPlayerGender;
/*0x40*/ u16 monGender;
/*0x42*/ u32 monPersonality;
/*0x46*/ MainCallback returnCallback;
/*0x00*/ u8 state;
/*0x01*/ u8 templateNum;
/*0x02*/ u16 nameLeftOffset;
/*0x04*/ u16 bg1vOffset;
/*0x06*/ u16 bg2vOffset;
/*0x08*/ u16 bg1Priority;
/*0x0A*/ u16 bg2Priority;
/*0x0C*/ u8 bgToReveal;
/*0x0D*/ u8 bgToHide;
/*0x0E*/ u8 currentPage;
/*0x0F*/ u8 cursorSpriteId;
/*0x10*/ u8 pageIndicatorSpriteId;
/*0x11*/ u8 textBuffer[0x10];
/*0x21*/ u8 filler21[0x13];
/*0x34*/ const struct NamingScreenTemplate *template;
/*0x38*/ u8 *destBuffer;
/*0x3C*/ u16 keyRepeatStartDelayCopy;
/*0x3E*/ u16 speciesOrPlayerGender;
/*0x40*/ u16 monGender;
/*0x42*/ u32 monPersonality;
/*0x46*/ MainCallback returnCallback;
};

void LONG_CALL TryStartButtonFlash(u8, u8, u8);
Expand Down
4 changes: 4 additions & 0 deletions include/stats_viewer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

void GoToStatsViewerFromOverworld(void);
void GoToStatsViewerFromBag(void);
1 change: 1 addition & 0 deletions linker/text.ld
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,4 @@ SquishCursor = 0x80b6914 | 1;
SetInputState = 0x80b6210 | 1;
MainState_StartPageSwap = 0x80b61c8 | 1;
GetTextEntryPosition = 0x80b6f44 | 1;
sub_80F9368 = 0x80f9368 | 1;
1 change: 1 addition & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
.include "scripts/repel_prompt.asm"
.include "scripts/reusable_tms.asm"
.include "scripts/save_flash_failed.asm"
.include "scripts/stats_viewer.asm"
.include "scripts/summary_screen.asm"

.close
4 changes: 0 additions & 4 deletions scripts/ability_changer.asm
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
.if ABILITY_CHANGER
.org 0x88189F1
s_goto EventScript_AbilityChanger

.org 0x8152F2E
s_callnative (DrawFrameTest | 1)
s_end
.endif
2 changes: 1 addition & 1 deletion scripts/include/items.asm
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ITEM_POKEPHONE equ 222
ITEM_GASEOUS_ZINC equ 223
ITEM_POKEGEAR equ 224
ITEM_PACHI_SWORD equ 225
ITEM_0E2 equ 226
ITEM_STATS_VIEWER equ 226
ITEM_0E3 equ 227
ITEM_0E4 equ 228
ITEM_0E5 equ 229
Expand Down
25 changes: 25 additions & 0 deletions scripts/stats_viewer.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.if STATS_VIEWER

.org 0x83c5564 + (44 * ITEM_STATS_VIEWER)
.area 0xE, 0x0
.string "STATS VIEWER"
.endarea

.org 0x83c5564 + (44 * ITEM_STATS_VIEWER) + 28
.word (ItemUseOutOfBattle_StatsViewer | 1)

.org 0x83c5564 + (44 * ITEM_STATS_VIEWER) + 24
.byte 0x1, 0x1

.org 0x83c5564 + (44 * ITEM_STATS_VIEWER) + 26
.byte 0x5

.org 0x83c5564 + (44 * ITEM_STATS_VIEWER) + 20
.word @StatsViewer_Desc

.autoregion
@StatsViewer_Desc:
.string "A device which lets\nyou see your\nPOKeMON's stats."
.endautoregion

.endif
30 changes: 30 additions & 0 deletions src/item_use.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "types.h"
#include "item_use.h"
#include "palette.h"
#include "stats_viewer.h"
#include "task.h"
#include "constants/gba.h"

extern u8 gExpAllEnabled;

Expand All @@ -12,4 +15,31 @@ void ItemUseOutOfBattle_ExpShare(u8 taskId)
gExpAllEnabled = !gExpAllEnabled;
DisplayItemUseMessage(
taskId, gTasks[taskId].data[2], gExpAllEnabled ? sText_EnabledExpShare : sText_DisabledExpShare);
}

#define tState data[0]
#define tSelectedItem data[2]

#include "bios.h"
void Task_HandleStatsViewerPaletteFade(u8 taskId);

void ItemUseOutOfBattle_StatsViewer(u8 taskId)
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gTasks[taskId].func = Task_HandleStatsViewerPaletteFade;
}

void Task_HandleStatsViewerPaletteFade(u8 taskId)
{
if (gPaletteFade.active) return;

s16 *data = gTasks[taskId].data;

if (tSelectedItem)
GoToStatsViewerFromOverworld();
else
GoToStatsViewerFromBag();

DmaFill16(3, 0x0, VRAM, VRAM_SIZE);
DestroyTask(taskId);
}
2 changes: 1 addition & 1 deletion src/naming_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ u8 KeyboardKeyHandler_Character(u8 event)
{
u8 textFull = AddTextCharacter();

if (gNamingScreenPtr ->currentPage == PAGE_UPPER && GetTextEntryPosition() == 1)
if (gNamingScreenPtr->currentPage == PAGE_UPPER && GetTextEntryPosition() == 1)
MainState_StartPageSwap();

SquishCursor();
Expand Down
Loading

0 comments on commit 071c333

Please sign in to comment.