fix performance issues, add config for alpha blend and 24 hour time, fix time display bugs, reverse readme changes

This commit is contained in:
ravepossum 2024-01-15 01:51:44 -05:00
parent 143332e9dd
commit 499354ddc5
10 changed files with 54 additions and 46 deletions

View File

@ -1,13 +1,11 @@
# pokeemerald branches
# Pokémon Emerald
This is a feature branch repo for [pret's](https://pret.github.io/) pokeemerald decomp.
This is a decompilation of Pokémon Emerald.
# Branches
It builds the following ROM:
## bsbob_map_popups
* [**pokeemerald.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=1961) `sha1: f3ae088181bf583e55daf962a92bb46f4f1d07b7`
This is a port of BSBob's map pop-ups from [Vanadium Version](https://github.com/nielsmittertreiner/pokeemerald/tree/vanadium). If you pull this, please credit him.
To set up the repository, see [INSTALL.md](INSTALL.md).
![bsbob_map_popup.gif](bsbob_map_popup.gif)
NOTE: This currently only builds on modern, not agbcc. I'm working on it.
For contacts and other pret projects, see [pret.github.io](https://pret.github.io/).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -5070,8 +5070,4 @@ extern const u8 gMailTilemap_Retro[];
extern const u8 gMonMarkingsMenu_Gfx[];
extern const u16 gMonMarkingsMenu_Pal[];
// BSBob map pop-ups
extern const u8 gPopUpWindowBorder_Tiles[];
extern const u16 gPopUpWindowBorder_Palette[];
#endif //GUARD_GRAPHICS_H

View File

@ -8,4 +8,8 @@
// Exported ROM declarations
void HideMapNamePopUpWindow(void);
void ShowMapNamePopup(void);
#define MAP_POPUP_24_HOUR_TIME FALSE
#define MAP_POPUP_ALPHA_BLEND TRUE
#endif //GUARD_MAP_NAME_POPUP_H

View File

@ -106,7 +106,7 @@ void DisplayYesNoMenuWithDefault(u8 initialCursorPos);
void BufferSaveMenuText(u8 textId, u8 *dest, u8 color);
void RemovePrimaryPopUpWindow(void);
u8 GetPrimaryPopUpWindowId(void);
u8 AddMapNamePopUpWindow(void);
u8 AddPrimaryPopUpWindow(void);
void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 letterSpacing, u8 lineSpacing);
void SetBgTilemapPalette(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette);
void AddValToTilemapBuffer(void *ptr, int delta, int width, int height, bool32 is8BPP);
@ -125,7 +125,7 @@ void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonP
void EraseYesNoWindow(void);
void PrintMenuActionTextsAtPos(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs);
void Menu_LoadStdPal(void);
u8 AddWeatherPopUpWindow(void);
u8 AddSecondaryPopUpWindow(void);
u8 GetSecondaryPopUpWindowId(void);
void RemoveSecondaryPopUpWindow(void);
void HBlankCB_DoublePopupWindow(void);

View File

@ -1536,6 +1536,3 @@ static const u8 sEmpty5[0x3242] = {0};
static const u8 sUnused3[] = {0x40};
static const u8 sEmpty6[0x13] = {0};
// BSBob map pop-ups
const u8 gPopUpWindowBorder_Tiles[] = INCBIN_U8("graphics/interface/map_popup_tiles.4bpp");
const u16 gPopUpWindowBorder_Palette[] = INCBIN_U16("graphics/interface/map_popup_palette.gbapal");

View File

@ -25,7 +25,9 @@ static void Task_MapNamePopUpWindow(u8 taskId);
static void ShowMapNamePopUpWindow(void);
static void LoadMapNamePopUpWindowBgs(void);
static const u16 sMapPopUp_Palette[16] = INCBIN_U16("graphics/interface/map_popup_palette.gbapal");
static const u8 sMapPopUpTiles_Primary[] = INCBIN_U8("graphics/interface/map_popup_primary.4bpp");
static const u8 sMapPopUpTiles_Secondary[] = INCBIN_U8("graphics/interface/map_popup_secondary.4bpp");
static const u16 sMapPopUpTiles_Palette[16] = INCBIN_U16("graphics/interface/map_popup_palette.gbapal");
static const u8 sText_PyramidFloor1[] = _("PYRAMID FLOOR 1");
static const u8 sText_PyramidFloor2[] = _("PYRAMID FLOOR 2");
@ -83,7 +85,10 @@ void ShowMapNamePopup(void)
{
// New pop up window
gPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 100);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND);
if (MAP_POPUP_ALPHA_BLEND)
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND);
gTasks[gPopupTaskId].tState = STATE_PRINT;
gTasks[gPopupTaskId].tYOffset = POPUP_OFFSCREEN_Y;
}
@ -176,9 +181,14 @@ void HideMapNamePopUpWindow(void)
DisableInterrupts(INTR_FLAG_HBLANK);
SetHBlankCallback(NULL);
SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 10));
if (MAP_POPUP_ALPHA_BLEND)
{
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 10));
}
DestroyTask(gPopupTaskId);
}
}
@ -187,7 +197,7 @@ static void ShowMapNamePopUpWindow(void)
{
u8 mapDisplayHeader[24];
u8 *withoutPrefixPtr;
u8 mapNameX, timeX, mapNameY, timeY, mapNamePopUpWindowId, weatherPopUpWindowId;
u8 mapNameX, timeX, mapNameY, timeY, primaryPopUpWindowId, secondaryPopUpWindowId;
const u8 *mapDisplayHeaderSource;
mapNameX = 8;
@ -195,13 +205,13 @@ static void ShowMapNamePopUpWindow(void)
timeX = 5;
timeY = 8;
SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR);
if (MAP_POPUP_ALPHA_BLEND)
SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR);
mapNamePopUpWindowId = AddMapNamePopUpWindow();
weatherPopUpWindowId = AddWeatherPopUpWindow();
primaryPopUpWindowId = AddPrimaryPopUpWindow();
secondaryPopUpWindowId = AddSecondaryPopUpWindow();
LoadMapNamePopUpWindowBgs();
LoadPalette(gPopUpWindowBorder_Palette, 0xE0, 32);
if (InBattlePyramid())
{
@ -227,18 +237,18 @@ static void ShowMapNamePopUpWindow(void)
mapDisplayHeader[1] = EXT_CTRL_CODE_HIGHLIGHT;
mapDisplayHeader[2] = TEXT_COLOR_TRANSPARENT;
AddTextPrinterParameterized(mapNamePopUpWindowId, FONT_SHORT, mapDisplayHeader, mapNameX, mapNameY, TEXT_SKIP_DRAW, NULL);
FormatDecimalTimeWithoutSeconds(withoutPrefixPtr, gLocalTime.hours, gLocalTime.minutes, FALSE);
AddTextPrinterParameterized(weatherPopUpWindowId, FONT_SMALL, mapDisplayHeader, GetStringRightAlignXOffset(FONT_SMALL, mapDisplayHeader, DISPLAY_WIDTH) - timeX, timeY, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(primaryPopUpWindowId, FONT_SHORT, mapDisplayHeader, mapNameX, mapNameY, TEXT_SKIP_DRAW, NULL);
FormatDecimalTimeWithoutSeconds(withoutPrefixPtr, gLocalTime.hours, gLocalTime.minutes, MAP_POPUP_24_HOUR_TIME);
AddTextPrinterParameterized(secondaryPopUpWindowId, FONT_SMALL, mapDisplayHeader, GetStringRightAlignXOffset(FONT_SMALL, mapDisplayHeader, DISPLAY_WIDTH) - timeX, timeY, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(mapNamePopUpWindowId, COPYWIN_FULL);
CopyWindowToVram(weatherPopUpWindowId, COPYWIN_FULL);
CopyWindowToVram(primaryPopUpWindowId, COPYWIN_FULL);
CopyWindowToVram(secondaryPopUpWindowId, COPYWIN_FULL);
}
static void LoadMapNamePopUpWindowBgs(void)
{
u8 mapNamePopUpWindowId = GetPrimaryPopUpWindowId();
u8 weatherPopUpWindowId = GetSecondaryPopUpWindowId();
u8 primaryPopUpWindowId = GetPrimaryPopUpWindowId();
u8 secondaryPopUpWindowId = GetSecondaryPopUpWindowId();
u16 regionMapSectionId = gMapHeader.regionMapSectionId;
if (regionMapSectionId >= KANTO_MAPSEC_START)
@ -249,9 +259,11 @@ static void LoadMapNamePopUpWindowBgs(void)
regionMapSectionId = 0; // Discard kanto region sections;
}
PutWindowTilemap(mapNamePopUpWindowId);
PutWindowTilemap(weatherPopUpWindowId);
LoadPalette(sMapPopUpTiles_Palette, BG_PLTT_ID(14), sizeof(sMapPopUpTiles_Palette));
BlitBitmapRectToWindow(mapNamePopUpWindowId, gPopUpWindowBorder_Tiles, 0, 0, DISPLAY_WIDTH, 24, 0, 0, DISPLAY_WIDTH, 24);
BlitBitmapRectToWindow(weatherPopUpWindowId, gPopUpWindowBorder_Tiles, 0, 24, DISPLAY_WIDTH, 24, 0, 0, DISPLAY_WIDTH, 24);
CopyToWindowPixelBuffer(primaryPopUpWindowId, sMapPopUpTiles_Primary, sizeof(sMapPopUpTiles_Primary), 0);
CopyToWindowPixelBuffer(secondaryPopUpWindowId, sMapPopUpTiles_Secondary, sizeof(sMapPopUpTiles_Secondary), 0);
PutWindowTilemap(primaryPopUpWindowId);
PutWindowTilemap(secondaryPopUpWindowId);
}

View File

@ -6,6 +6,7 @@
#include "event_data.h"
#include "graphics.h"
#include "main.h"
#include "map_name_popup.h"
#include "menu.h"
#include "menu_helpers.h"
#include "palette.h"
@ -60,7 +61,7 @@ static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8,
static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8, u8, u8, u8, u8, u8);
static void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
EWRAM_DATA u8 gPopupTaskId;
EWRAM_DATA u8 gPopupTaskId = 0;
static EWRAM_DATA u8 sStartMenuWindowId = 0;
static EWRAM_DATA u8 sPrimaryPopupWindowId = 0;
@ -522,7 +523,7 @@ static u16 UNUSED GetStandardFrameBaseTileNum(void)
return STD_WINDOW_BASE_TILE_NUM;
}
u8 AddMapNamePopUpWindow(void)
u8 AddPrimaryPopUpWindow(void)
{
if (sPrimaryPopupWindowId == WINDOW_NONE)
sPrimaryPopupWindowId = AddWindowParameterized(0, 0, 0, 30, 3, 14, 0x107);
@ -2151,7 +2152,7 @@ void BufferSaveMenuText(u8 textId, u8 *dest, u8 color)
}
// BSBob map pop-ups
u8 AddWeatherPopUpWindow(void)
u8 AddSecondaryPopUpWindow(void)
{
if (sSecondaryPopupWindowId == WINDOW_NONE)
sSecondaryPopupWindowId = AddWindowParameterized(0, 0, 17, 30, 3, 14, 0x161);
@ -2180,7 +2181,8 @@ void HBlankCB_DoublePopupWindow(void)
if (scanline < 80 || scanline > 160)
{
REG_BG0VOFS = offset;
REG_BLDALPHA = BLDALPHA_BLEND(15, 5);
if(MAP_POPUP_ALPHA_BLEND)
REG_BLDALPHA = BLDALPHA_BLEND(15, 5);
}
else
{

View File

@ -358,9 +358,8 @@ void FormatDecimalTimeWithoutSeconds(u8 *txtPtr, s8 hour, s8 minute, bool8 is24H
break;
case FALSE:
if (hour == 0)
hour = 12;
if (hour < 13)
txtPtr = ConvertIntToDecimalStringN(txtPtr, 12, STR_CONV_MODE_LEADING_ZEROS, 2);
else if (hour < 13)
txtPtr = ConvertIntToDecimalStringN(txtPtr, hour, STR_CONV_MODE_LEADING_ZEROS, 2);
else
txtPtr = ConvertIntToDecimalStringN(txtPtr, hour - 12, STR_CONV_MODE_LEADING_ZEROS, 2);
@ -368,7 +367,7 @@ void FormatDecimalTimeWithoutSeconds(u8 *txtPtr, s8 hour, s8 minute, bool8 is24H
*txtPtr++ = CHAR_COLON;
txtPtr = ConvertIntToDecimalStringN(txtPtr, minute, STR_CONV_MODE_LEADING_ZEROS, 2);
txtPtr = StringAppend(txtPtr, gText_Space);
if (hour < 13)
if (hour < 12)
txtPtr = StringAppend(txtPtr, gText_AM);
else
txtPtr = StringAppend(txtPtr, gText_PM);