From da791cde9407641d3eb86700ffb8bd274a9a2d3a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 24 Oct 2024 12:41:38 -0400 Subject: [PATCH 1/5] Add TRY_DRAW_SPOT_PIXEL --- src/pokemon.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 077b8567938..d59f46ada1b 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5684,7 +5684,7 @@ u16 SpeciesToCryId(u16 species) // To draw a spot pixel, add 4 to the color index #define SPOT_COLOR_ADJUSTMENT 4 /* - The macro below handles drawing the randomly-placed spots on Spinda's front sprite. + The macros below handle drawing the randomly-placed spots on Spinda's front sprite. Spinda has 4 spots, each with an entry in gSpindaSpotGraphics. Each entry contains a base x and y coordinate for the spot and a 16x16 binary image. Each bit in the image determines whether that pixel should be considered part of the spot. @@ -5696,18 +5696,26 @@ u16 SpeciesToCryId(u16 species) coordinate is calculated as (baseCoord + (given 4 bits of personality) - 8). In effect this means each spot can start at any position -8 to +7 off of its base coordinates (256 possibilities). - The macro then loops over the 16x16 spot image. For each bit in the spot's binary image, if + DRAW_SPINDA_SPOTS loops over the 16x16 spot image. For each bit in the spot's binary image, if the bit is set then it's part of the spot; try to draw it. A pixel is drawn on Spinda if the - pixel on Spinda satisfies the following formula: ((u8)(colorIndex - 1) <= 2). The -1 excludes - transparent pixels, as these are index 0. Therefore only colors 1, 2, or 3 on Spinda will - allow a spot to be drawn. These color indexes are Spinda's light brown body colors. To create + pixel is between FIRST_SPOT_COLOR and LAST_SPOT_COLOR (so only colors 1, 2, or 3 on Spinda will + allow a spot to be drawn). These color indexes are Spinda's light brown body colors. To create the spot it adds 4 to the color index, so Spinda's spots will be colors 5, 6, and 7. - The above is done two different ways in the macro: one with << 4, and one without. This - is because Spinda's sprite is a 4 bits per pixel image, but the pointer to Spinda's pixels + The above is done in TRY_DRAW_SPOT_PIXEL two different ways: one with << 4, and one without. + This is because Spinda's sprite is a 4 bits per pixel image, but the pointer to Spinda's pixels (destPixels) is an 8 bit pointer, so it addresses two pixels. Shifting by 4 accesses the 2nd of these pixels, so this is done every other time. */ + +// Draw spot pixel if this is Spinda's body color +#define TRY_DRAW_SPOT_PIXEL(pixels, shift) \ + if (((*(pixels) & (0xF << (shift))) >= (FIRST_SPOT_COLOR << (shift))) \ + && ((*(pixels) & (0xF << (shift))) <= (LAST_SPOT_COLOR << (shift)))) \ + { \ + *(pixels) += (SPOT_COLOR_ADJUSTMENT << (shift)); \ + } + #define DRAW_SPINDA_SPOTS(personality, dest) \ { \ s32 i; \ @@ -5737,17 +5745,11 @@ u16 SpeciesToCryId(u16 species) /* of the two pixels is being considered for drawing */ \ if (column & 1) \ { \ - /* Draw spot pixel if this is Spinda's body color */ \ - if ((u8)((*destPixels & 0xF0) - (FIRST_SPOT_COLOR << 4))\ - <= ((LAST_SPOT_COLOR - FIRST_SPOT_COLOR) << 4))\ - *destPixels += (SPOT_COLOR_ADJUSTMENT << 4); \ + TRY_DRAW_SPOT_PIXEL(destPixels, 4); \ } \ else \ { \ - /* Draw spot pixel if this is Spinda's body color */ \ - if ((u8)((*destPixels & 0xF) - FIRST_SPOT_COLOR) \ - <= (LAST_SPOT_COLOR - FIRST_SPOT_COLOR)) \ - *destPixels += SPOT_COLOR_ADJUSTMENT; \ + TRY_DRAW_SPOT_PIXEL(destPixels, 0); \ } \ } \ \ From b60da57d8aad9b025e867900e55ccb83947e383a Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Tue, 12 Nov 2024 14:28:33 -0300 Subject: [PATCH 2/5] Remove usage of gHeap in sSpritePalettes_ContestantsTurnBlinkEffect Those offsets into gHeap are actually just inside of eContestTempSave. --- src/contest.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/contest.c b/src/contest.c index 5b9560faf55..40a42a35292 100644 --- a/src/contest.c +++ b/src/contest.c @@ -858,23 +858,22 @@ static const struct CompressedSpriteSheet sSpriteSheets_ContestantsTurnBlinkEffe } }; -// Yup this is super dangerous but that's how it is here static const struct SpritePalette sSpritePalettes_ContestantsTurnBlinkEffect[CONTESTANT_COUNT] = { { - .data = (u16 *)(gHeap + 0x1A0A4), + .data = eContestTempSave.cachedWindowPalettes[5], .tag = TAG_BLINK_EFFECT_CONTESTANT0 }, { - .data = (u16 *)(gHeap + 0x1A0C4), + .data = eContestTempSave.cachedWindowPalettes[6], .tag = TAG_BLINK_EFFECT_CONTESTANT1 }, { - .data = (u16 *)(gHeap + 0x1A0E4), + .data = eContestTempSave.cachedWindowPalettes[7], .tag = TAG_BLINK_EFFECT_CONTESTANT2 }, { - .data = (u16 *)(gHeap + 0x1A104), + .data = eContestTempSave.cachedWindowPalettes[8], .tag = TAG_BLINK_EFFECT_CONTESTANT3 } }; From 13692076f9374a41d9ee57e7bb424fc1789cbdbc Mon Sep 17 00:00:00 2001 From: surtr-games Date: Thu, 14 Nov 2024 00:29:42 -0500 Subject: [PATCH 3/5] Fixed a bug with Counter and Mirror Coat where they would be scored up depending on the wrong target mon type category. --- data/battle_ai_scripts.s | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index a43c8895028..19ee9d18a53 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -1613,6 +1613,8 @@ AI_CV_Disable2: AI_CV_Disable_End: end +@ BUG: The original script would score up Counter when the target's types were not physical +@ This is incorrect since Counter only deals double the damage received if hit by a physical attack AI_CV_Counter: if_status AI_TARGET, STATUS1_SLEEP, AI_CV_Counter_ScoreDown1 if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_Counter_ScoreDown1 @@ -1625,7 +1627,7 @@ AI_CV_Counter2: if_random_less_than 100, AI_CV_Counter3 score -1 AI_CV_Counter3: - if_has_move AI_USER, MOVE_MIRROR_COAT, AI_CV_Counter7 + if_has_move AI_USER, MOVE_MIRROR_COAT, AI_CV_Counter8 get_last_used_bank_move AI_TARGET get_move_power_from_result if_equal 0, AI_CV_Counter5 @@ -1645,15 +1647,24 @@ AI_CV_Counter5: if_random_less_than 100, AI_CV_Counter6 score +1 AI_CV_Counter6: +#ifdef BUGFIX + get_target_type1 + if_in_bytes AI_CV_Counter_PhysicalTypeList, AI_CV_Counter7 + get_target_type2 + if_in_bytes AI_CV_Counter_PhysicalTypeList, AI_CV_Counter7 + goto AI_CV_Counter_End +#else get_target_type1 if_in_bytes AI_CV_Counter_PhysicalTypeList, AI_CV_Counter_End get_target_type2 if_in_bytes AI_CV_Counter_PhysicalTypeList, AI_CV_Counter_End - if_random_less_than 50, AI_CV_Counter_End +#endif AI_CV_Counter7: - if_random_less_than 100, AI_CV_Counter8 - score +4 + if_random_less_than 50, AI_CV_Counter_End AI_CV_Counter8: + if_random_less_than 100, AI_CV_Counter9 + score +4 +AI_CV_Counter9: end AI_CV_Counter_ScoreDown1: @@ -2100,6 +2111,8 @@ AI_CV_PsychUp_ScoreDown2: AI_CV_PsychUp_End: end +@ BUG: The original script would score up Mirror Coat when the target's types were not special +@ This is incorrect since Mirror Coat only deals double the damage received if hit by a special attack AI_CV_MirrorCoat: if_status AI_TARGET, STATUS1_SLEEP, AI_CV_MirrorCoat_ScoreDown1 if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_MirrorCoat_ScoreDown1 @@ -2132,10 +2145,19 @@ AI_CV_MirrorCoat5: if_random_less_than 100, AI_CV_MirrorCoat6 score +1 AI_CV_MirrorCoat6: +#ifdef BUGFIX + get_target_type1 + if_in_bytes AI_CV_MirrorCoat_SpecialTypeList, AI_CV_MirrorCoat7 + get_target_type2 + if_in_bytes AI_CV_MirrorCoat_SpecialTypeList, AI_CV_MirrorCoat7 + goto AI_CV_MirrorCoat_End +#else get_target_type1 if_in_bytes AI_CV_MirrorCoat_SpecialTypeList, AI_CV_MirrorCoat_End get_target_type2 if_in_bytes AI_CV_MirrorCoat_SpecialTypeList, AI_CV_MirrorCoat_End +#endif +AI_CV_MirrorCoat7: if_random_less_than 50, AI_CV_MirrorCoat_End AI_CV_MirrorCoat_ScoreUp4: if_random_less_than 100, AI_CV_MirrorCoat_ScoreUp4_End From 6560bbab21ff171d7f0078d9f4966338f6466ef8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 23 Nov 2024 14:17:40 -0500 Subject: [PATCH 4/5] Restore .map file creation --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index a5f0224331b..6252664bded 100644 --- a/Makefile +++ b/Makefile @@ -379,6 +379,7 @@ libagbsyscall: @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN) # Elf from object files +LDFLAGS = -Map ../../$(MAP) $(ELF): $(LD_SCRIPT) $(LD_SCRIPT_DEPS) $(OBJS) libagbsyscall @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ $(OBJS_REL) $(LIB) | cat @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ | cat" From 4beb0efbcc202048fafa606147b7b5243ed55951 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 24 Nov 2024 22:46:01 -0300 Subject: [PATCH 5/5] Added extra encoded character support (#2050) --- src/mini_printf.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/mini_printf.c b/src/mini_printf.c index ac8a0ef1277..e4b89372428 100644 --- a/src/mini_printf.c +++ b/src/mini_printf.c @@ -86,6 +86,8 @@ static inline char mini_pchar_decode(char encoded) ret = '('; // opening parentheses else if (encoded == CHAR_RIGHT_PAREN) ret = ')'; // closing parentheses + else if (encoded == CHAR_HYPHEN) + ret = '-'; // hyphen return ret; } @@ -133,7 +135,31 @@ static s32 _putsEncoded(char *s, s32 len, void *buf) { break; } - *(b->pbuffer ++) = mini_pchar_decode(s[i]); + if (s[i] == CHAR_NEWLINE) + { + *(b->pbuffer ++) = '\\'; + *(b->pbuffer ++) = 'n'; + } + else if (s[i] == CHAR_PROMPT_SCROLL) + { + *(b->pbuffer ++) = '\\'; + *(b->pbuffer ++) = 'l'; + } + else if (s[i] == CHAR_PROMPT_CLEAR) + { + *(b->pbuffer ++) = '\\'; + *(b->pbuffer ++) = 'p'; + } + else if (s[i] == CHAR_ELLIPSIS) + { + *(b->pbuffer ++) = '.'; + *(b->pbuffer ++) = '.'; + *(b->pbuffer ++) = '.'; + } + else + { + *(b->pbuffer ++) = mini_pchar_decode(s[i]); + } } *(b->pbuffer) = 0; return b->pbuffer - p0;