diff --git a/README.md b/README.md index adde8c3af2..d9148b32ec 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +For contacts and other pret projects, see [pret.github.io](https://pret.github.io/). diff --git a/graphics/interface/map_popup_tiles.png b/graphics/interface/map_popup_primary.png similarity index 97% rename from graphics/interface/map_popup_tiles.png rename to graphics/interface/map_popup_primary.png index 546c4a420c..72602052fe 100644 Binary files a/graphics/interface/map_popup_tiles.png and b/graphics/interface/map_popup_primary.png differ diff --git a/graphics/interface/map_popup_secondary.png b/graphics/interface/map_popup_secondary.png new file mode 100644 index 0000000000..39ad7d2e06 Binary files /dev/null and b/graphics/interface/map_popup_secondary.png differ diff --git a/include/graphics.h b/include/graphics.h index da860030de..9e2fb79539 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -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 diff --git a/include/map_name_popup.h b/include/map_name_popup.h index 85d2f0795f..a357407803 100644 --- a/include/map_name_popup.h +++ b/include/map_name_popup.h @@ -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 diff --git a/include/menu.h b/include/menu.h index 0b2d8611d5..1e84a416b0 100644 --- a/include/menu.h +++ b/include/menu.h @@ -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); diff --git a/src/graphics.c b/src/graphics.c index ec81bfebab..0a2f91cedd 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -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"); diff --git a/src/map_name_popup.c b/src/map_name_popup.c index e1ec7f7adc..15c482a2f6 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -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); } diff --git a/src/menu.c b/src/menu.c index f57e7fd3ff..f1c179e2af 100644 --- a/src/menu.c +++ b/src/menu.c @@ -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 { diff --git a/src/rtc.c b/src/rtc.c index 9f92894263..0344d17131 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -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);