Skip to content

Commit

Permalink
Change to lowercase after first letter in naming screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseurae committed Oct 16, 2024
1 parent 974cd8d commit 863e614
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 40 deletions.
Binary file added assets/stats_viewer.4bpp.lz
Binary file not shown.
Binary file added assets/stats_viewer.bin.lz
Binary file not shown.
Binary file added assets/stats_viewer.gbapal.lz
Binary file not shown.
3 changes: 3 additions & 0 deletions config.asm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
; Gen 6 Exp. Share
.definelabel EXP_ALL, 1

; Auto-change to lowercase after first letter in naming screen.
.definelabel AUTOCASE, 1

; Bugfixes
; --------

Expand Down
1 change: 1 addition & 0 deletions include/decompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ struct CompressedSpriteSheet

void LONG_CALL LoadCompressedObjectPic(const struct CompressedSpriteSheet *src);
void LONG_CALL DecompressPicFromTable_2(const void *src, u8 coords, u8 y_offset, void *d, void *dest, s32 species);
void LONG_CALL LZDecompressVram(const void *src, void *dest);
67 changes: 67 additions & 0 deletions include/naming_screen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

#include "main.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
{
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,
};

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;
};

void LONG_CALL TryStartButtonFlash(u8, u8, u8);
bool8 LONG_CALL AddTextCharacter(void);
void LONG_CALL SquishCursor(void);
void LONG_CALL SetInputState(u8);
void LONG_CALL MainState_StartPageSwap(void);
u8 LONG_CALL GetTextEntryPosition(void);
1 change: 1 addition & 0 deletions include/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,6 @@ void SetCursorY(struct Window *, u8);
void LONG_CALL AddToCursorX(struct Window *, u8);
void LONG_CALL AddToCursorY(struct Window *, u8);
u16 *GetCursorTilemapPointerWithOffset(struct Window *win, u32, u32);
void LONG_CALL SetWindowBackgroundColor(struct Window *, u8);

extern const u8 gFontDefaultPalette[];
13 changes: 12 additions & 1 deletion include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ struct UCoords16

#define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0]))

#define _(s) (s)
#define _(s) (s)

#define INCBIN(...) \
{ \
0 \
}
#define INCBIN_U8 INCBIN
#define INCBIN_U16 INCBIN
#define INCBIN_U32 INCBIN
#define INCBIN_S8 INCBIN
#define INCBIN_S16 INCBIN
#define INCBIN_S32 INCBIN
2 changes: 1 addition & 1 deletion linker/ram.ld
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ gBagPocketScrollStates = 0x3005d10;
gCurrentBagPocketItemSlots = 0x3005d24;
gScriptContext1 = 0x3007440;
sMessageBoxMode = 0x30074b8;
gWindowTemplate_Contest_MoveDescription = 0x3004210;
gWindowTemplate_Contest_MoveDescription = 0x3004210;
3 changes: 2 additions & 1 deletion linker/rodata.ld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Event_NoRegisteredItem = 0x81a14af;
BattleScript_SubstituteFade = 0x81d99ab;
gFontDefaultPalette = 0x81e66b2;
gWindowTemplate_81E6C3C = 0x81E6C3C;
gWindowTemplate_81E6C3C = 0x81e6c3c;
gMenuTextWindowTemplate = 0x81e6ce4;
gMonFrontPicCoords = 0x81e7c74;
gMonFrontPicTable = 0x81e8354;
Expand Down Expand Up @@ -58,3 +58,4 @@ BattleStatText_SpAtk = 0x84007ea;
BattleStatText_SpDef = 0x84007f2;
OtherText_MaleSymbol = 0x8410458;
OtherText_FemaleSymbol = 0x841045a;
gNamingScreenPtr = 0x83ce214;
8 changes: 8 additions & 0 deletions linker/text.ld
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,11 @@ LoadOam = 0x8000f70 | 1;
CB2_ReturnToField = 0x80545e4 | 1;
Menu_EraseScreen = 0x8071ef4 | 1;
GetMonGender = 0x803c4b8 | 1;
LZDecompressVram = 0x800d244 | 1;
SetWindowBackgroundColor = 0x8003f60 | 1;
TryStartButtonFlash = 0x80b6460 | 1;
AddTextCharacter = 0x80b7004 | 1;
SquishCursor = 0x80b6914 | 1;
SetInputState = 0x80b6210 | 1;
MainState_StartPageSwap = 0x80b61c8 | 1;
GetTextEntryPosition = 0x80b6f44 | 1;
1 change: 1 addition & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
.include "scripts/bugfixes/text_colors.asm"

.include "scripts/ability_changer.asm"
.include "scripts/autocase.asm"
.include "scripts/autorun.asm"
.include "scripts/birch_speech.asm"
.include "scripts/bag_expansion.asm"
Expand Down
4 changes: 4 additions & 0 deletions scripts/autocase.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.if AUTOCASE
.org 0x83ce240
.word (KeyboardKeyHandler_Character | 1)
.endif
24 changes: 24 additions & 0 deletions src/naming_screen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "types.h"
#include "naming_screen.h"

extern struct NamingScreen *const gNamingScreenPtr;

u8 KeyboardKeyHandler_Character(u8 event)
{
TryStartButtonFlash(3, 0, 0);
if (event == KBEVENT_PRESSED_A)
{
u8 textFull = AddTextCharacter();

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

SquishCursor();
if (textFull)
{
SetInputState(INPUT_STATE_DISABLED);
gNamingScreenPtr->state = MAIN_STATE_MOVE_TO_OK_BUTTON;
}
}
return FALSE;
}
109 changes: 72 additions & 37 deletions src/stats_viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,6 @@
#include "constants/songs.h"
#include "constants/species.h"

/*
u16 paletteNum = (gMenuWindowPtr->paletteNum << 12);
SetCursorX(gMenuWindowPtr, 8);
SetCursorY(gMenuWindowPtr, 8);
for (u8 i = 0; i < 3; ++i)
{
u16 tileNum = GetCursorTileNum(gMenuWindowPtr, 0, 0);
u32 *tileData = (u32 *)(gMenuWindowPtr->tileData + 32 * tileNum);
for (u8 y = 0; y < 8; ++y)
for (u8 x = 0; x < 8; ++x)
{
tileData[y] |= (gMenuWindowPtr->foregroundColor << (4 * x));
}
*GetCursorTilemapPointerWithOffset(gMenuWindowPtr, 0, 0) = tileNum | paletteNum;
*GetCursorTilemapPointerWithOffset(gMenuWindowPtr, 0, 1) = tileNum | paletteNum;
AddToCursorX(gMenuWindowPtr, 8);
}
AddToCursorY(gMenuWindowPtr, 8);
*/

const u8 sText_HP[] = _("HP");
const u8 sText_Attack[] = _("Attack");
const u8 sText_Defense[] = _("Defense");
Expand Down Expand Up @@ -198,7 +174,7 @@ static void StatViewer_PrintPokemonCount(void)
*(ptr++) = CHAR_SLASH;
*(ptr++) = CHAR_SPACE;
ptr = ConvertIntToDecimalString(ptr, gPlayerPartyCount);
Menu_PrintText(gStringVar4, 1, 17);
MenuPrint_Centered(gStringVar4, 4, 17, StringLength(gStringVar4));
}

static void StatViewer_PrintPokemonInfo(void)
Expand All @@ -223,7 +199,7 @@ static void StatViewer_PrintPokemonInfo(void)
ptr = StringCopy(ptr, gSpeciesNames[species]);
*(ptr++) = EXT_CTRL_CODE_BEGIN;
*(ptr++) = EXT_CTRL_CODE_CLEAR_TO;
*(ptr++) = (POKEMON_NAME_LENGTH + 1) * 6;
*(ptr++) = POKEMON_NAME_LENGTH * 6;
*(ptr++) = EOS;

Menu_PrintText(gStringVar4, 1, 3);
Expand Down Expand Up @@ -279,7 +255,7 @@ static void StatViewer_DrawMonSprite(void)
{
struct Pokemon *mon = &gPlayerParty[sStatViewer.selectedMon];
u16 species = GetMonData(mon, MON_DATA_SPECIES);
sStatViewer.monSpriteId = CreateMonSprite_PicBox(species, 36, 96, 0);
sStatViewer.monSpriteId = CreateMonSprite_PicBox(species, 38, 96, 0);

if (sStatViewer.monSpriteId != MAX_SPRITES)
{
Expand All @@ -293,7 +269,7 @@ static void StatViewer_DrawMonSprite(void)

static void StatViewer_BlankStats(void)
{
Menu_BlankWindowRect(16, 4, 29, 18);
Menu_BlankWindowRect(16, 4, 29, 14);
}

#define tState data[0]
Expand Down Expand Up @@ -342,8 +318,30 @@ static void Task_StatViewer_ChangePokemon(u8 taskId)
}
}

#undef tState
#undef tDelay
static void Task_StatViewer_Close(u8 taskId)
{
s16 *data = gTasks[taskId].data;

switch (tState)
{
case 0:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
tState++;
break;
case 1:
if (!gPaletteFade.active)
tState++;
break;
case 2:
FreeResourcesAndDestroySprite(&gSprites[sStatViewer.monSpriteId]);
tState++;
break;
default:
SetMainCallback2(CB2_ReturnToField);
DestroyTask(taskId);
break;
}
}

static void Task_StatViewer_HandleInput(u8 taskId)
{
Expand All @@ -365,12 +363,15 @@ static void Task_StatViewer_HandleInput(u8 taskId)
}
else if (gMain.newKeys & B_BUTTON)
{
SetMainCallback2(CB2_ReturnToField);
PlaySE(SE_SELECT);
DestroyTask(taskId);
gTasks[taskId].tState = 0;
gTasks[taskId].func = Task_StatViewer_Close;
}
}

#undef tState
#undef tDelay

static void StatViewer_PrintStatTypeLabels(void)
{
MenuPrint_RightAligned(sText_BaseLabel, 20, 2);
Expand Down Expand Up @@ -417,6 +418,30 @@ static void StatViewer_PrintStatLabels(void)
}
}

ALIGNED(4) static const u8 sStatViewer_Tiles[] = INCBIN_U8("assets/stats_viewer.4bpp.lz");
ALIGNED(4) static const u8 sStatViewer_Tilemap[] = INCBIN_U8("assets/stats_viewer.bin.lz");
ALIGNED(4) static const u8 sStatViewer_Pal[] = INCBIN_U8("assets/stats_viewer.gbapal.lz");

const struct WindowTemplate sWindowTemplate_StatsViewer = {
0, // BG number
2, // BG character base block
31, // BG screen base block
0, // BG priority
15, // palette number
TEXT_COLOR_DARK_GREY, // foreground color
TEXT_COLOR_TRANSPARENT, // background color
TEXT_COLOR_LIGHT_GREY, // shadow color
3, // font
2, // text mode
0, // spacing
0, // tilemap left coordinate
0, // tilemap top coordinate
30, // width
20, // height
BG_CHAR_ADDR(2), // tile data
BG_SCREEN_ADDR(31), // tilemap
};

static bool8 SetupStatViewer(void)
{
u8 spriteId;
Expand All @@ -439,27 +464,37 @@ static bool8 SetupStatViewer(void)
break;
case 3:
DmaFill16(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
ClearTilemapBuffers();
gMain.state++;
break;
case 4:
Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C);
InitMenuWindow(&gMenuTextWindowTemplate);
Menu_BlankWindowRect(0, 0, 29, 19);
Text_LoadWindowTemplate(&sWindowTemplate_StatsViewer);
InitMenuWindow(&sWindowTemplate_StatsViewer);
// Menu_BlankWindowRect(0, 0, 29, 19);
LZDecompressVram(sStatViewer_Tiles, (void *)(BG_CHAR_ADDR(0)));
LZDecompressVram(sStatViewer_Tilemap, (void *)(BG_SCREEN_ADDR(8)));
LoadCompressedPalette(sStatViewer_Pal, 0x0, 32);
REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_TXT256x256 | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(8);
gMain.state++;
break;
case 5:
StatViewer_DrawMonSprite();
StatViewer_PrintStatTypeLabels();
StatViewer_PrintStatLabels();
StatViewer_DrawMonSprite();
StatViewer_PrintPokemonInfo();
StatViewer_PrintPokemonCount();

StatViewer_PrintPokemonInfo();
gMain.state++;
break;
default:
BeginNormalPaletteFade(0xffffffff, 0, 16, 0, RGB_BLACK);
gPaletteFade.bufferTransferDisabled = FALSE;

REG_BG1HOFS = 0;
REG_BG1VOFS = 0;

CreateTask(Task_StatViewer_HandleInput, 0x0);
SetVBlankCallback(VBlank_StatsViewerRun);
SetMainCallback2(CB2_StatsViewerRun);
Expand Down

0 comments on commit 863e614

Please sign in to comment.