Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master to upcoming (again, for pret merge), 2024-11-30 #5740

Merged
Merged
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ libagbsyscall:
@$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=1

# 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 ../../$@ <objs> <libs> | cat"
Expand Down
9 changes: 4 additions & 5 deletions src/contest.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,23 +949,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
}
};
Expand Down
28 changes: 27 additions & 1 deletion src/mini_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
27 changes: 16 additions & 11 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -4977,16 +4977,25 @@ u16 HoennToNationalOrder(u16 hoennNum)

The function then 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 function: 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)); \
}


void DrawSpindaSpots(u32 personality, u8 *dest, bool32 isSecondFrame)
{
s32 i;
Expand Down Expand Up @@ -5028,16 +5037,12 @@ void DrawSpindaSpots(u32 personality, u8 *dest, bool32 isSecondFrame)
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);
}
}

Expand Down