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

fix LoadPartyImage for shift builds #1205

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/world/common/todo/LoadPartyImage.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@
#error "Define PARTY_IMAGE to the asset name to use LoadPartyImage."
#endif

#ifdef SHIFT
//this is required on modern compilers to guarantee the raster comes directly after the palette
typedef struct Img {
u16 palette[256];
Copy link
Collaborator

@z64a z64a Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PAL_BIN and IMG_BIN types here.
Use "PartyImage" for both struct name and typedef.

u8 raster[0x3D90]; // 10 bytes added for padding: 150 * 105 = 0x3D86
} PartyImage;

static PartyImage img;

API_CALLABLE(N(LoadPartyImage)) {
static MessageImageData image;

u32 decompressedSize;
void* compressed = load_asset_by_name(PARTY_IMAGE, &decompressedSize);

decode_yay0(compressed, &img);
general_heap_free(compressed);

image.raster = img.raster;
image.palette = img.palette;
image.width = 150;
image.height = 105;
image.format = G_IM_FMT_CI;
image.bitDepth = G_IM_SIZ_8b;
set_message_images(&image);
return ApiStatus_DONE2;
}
#else

API_CALLABLE(N(LoadPartyImage)) {
static PAL_BIN palette[256];
static IMG_BIN raster[0x3D90]; // 10 bytes added for padding: 150 * 105 = 3D86
Expand All @@ -26,4 +55,6 @@ API_CALLABLE(N(LoadPartyImage)) {
return ApiStatus_DONE2;
}

#endif

#undef PARTY_IMAGE
Loading