Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pret/pokeemerald into por…
Browse files Browse the repository at this point in the history
…ymap-6
  • Loading branch information
GriffinRichards committed Nov 23, 2024
2 parents cc388ef + 6560bba commit 382ee9e
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 30 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ include audio_rules.mk
# NOTE: Tools must have been built prior (FIXME)
# so you can't really call this rule directly
generated: $(AUTO_GEN_TARGETS)
@: # Silence the "Nothing to be done for `generated'" message, which some people were confusing for an error.


%.s: ;
%.png: ;
Expand Down Expand Up @@ -377,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 ../../$@ <objs> <libs> | cat"
Expand Down
30 changes: 26 additions & 4 deletions data/battle_ai_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Binary file modified graphics/title_screen/emerald_version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion graphics_file_rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ POKEDEXGFXDIR := graphics/pokedex
STARTERGFXDIR := graphics/starter_choose
NAMINGGFXDIR := graphics/naming_screen
SPINDAGFXDIR := graphics/pokemon/spinda/spots
TITLESCREENGFXDIR := graphics/title_screen

types := normal fight flying poison ground rock bug ghost steel mystery fire water grass electric psychic ice dragon dark
contest_types := cool beauty cute smart tough
Expand Down Expand Up @@ -298,9 +299,13 @@ $(FONTGFXDIR)/frlg_female.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_female.png


### Miscellaneous ###
graphics/title_screen/pokemon_logo.gbapal: %.gbapal: %.pal

$(TITLESCREENGFXDIR)/pokemon_logo.gbapal: %.gbapal: %.pal
$(GFX) $< $@ -num_colors 224

$(TITLESCREENGFXDIR)/emerald_version.8bpp: %.8bpp: %.png
$(GFX) $< $@ -mwidth 8 -mheight 4

graphics/pokemon_jump/bg.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 63 -Wnum_tiles

Expand Down
6 changes: 4 additions & 2 deletions include/bard_music.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef GUARD_BARD_MUSIC_H
#define GUARD_BARD_MUSIC_H

#define BARD_SOUND_MAX_LENGTH 6

struct BardSound
{
/*0x00*/ u8 songLengthId;
Expand All @@ -26,8 +28,8 @@ struct BardSong
/*0x06*/ u16 volume;
/*0x08*/ s16 pitch;
/*0x0A*/ s16 voiceInflection;
/*0x0C*/ u16 lyrics[6];
/*0x18*/ struct BardPhoneme phonemes[6];
/*0x0C*/ u16 lyrics[BARD_SOUND_MAX_LENGTH];
/*0x18*/ struct BardPhoneme phonemes[BARD_SOUND_MAX_LENGTH];
/*0x30*/ const struct BardSound *sound;
};

Expand Down
2 changes: 1 addition & 1 deletion src/bard_music.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void GetWordPhonemes(struct BardSong *song, u16 word)
const struct BardSound *sound;

song->length = 0;
for (i = 0; i < 6; i ++)
for (i = 0; i < BARD_SOUND_MAX_LENGTH; i ++)
{
sound = &song->sound[i];
if (sound->songLengthId != 0xFF)
Expand Down
9 changes: 4 additions & 5 deletions src/contest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/data/bard_music/moves.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const u16 gNumBardWords_Moves = MOVES_COUNT;

const struct BardSound gBardSounds_Moves[MOVES_COUNT][6] = {
const struct BardSound gBardSounds_Moves[MOVES_COUNT][BARD_SOUND_MAX_LENGTH] = {
[MOVE_NONE] = {
NULL_BARD_SOUND,
NULL_BARD_SOUND,
Expand Down
2 changes: 1 addition & 1 deletion src/data/bard_music/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const u16 gNumBardWords_Species = NUM_SPECIES;

const struct BardSound gBardSounds_Pokemon[NUM_SPECIES][6] = {
const struct BardSound gBardSounds_Pokemon[NUM_SPECIES][BARD_SOUND_MAX_LENGTH] = {
[SPECIES_NONE] = {
NULL_BARD_SOUND,
NULL_BARD_SOUND,
Expand Down
32 changes: 17 additions & 15 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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; \
Expand Down Expand Up @@ -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); \
} \
} \
\
Expand Down

0 comments on commit 382ee9e

Please sign in to comment.