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

Merrp's follower merge (11th of July) #4944

Merged
merged 2 commits into from
Jul 11, 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
13 changes: 9 additions & 4 deletions gflib/sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ void SetOamMatrixRotationScaling(u8 matrixNum, s16 xScale, s16 yScale, u16 rotat
CopyOamMatrix(matrixNum, &matrix);
}

u16 LoadSpriteSheet(const struct SpriteSheet *sheet)
static u16 LoadSpriteSheetWithOffset(const struct SpriteSheet *sheet, u32 offset)
{
s16 tileStart = AllocSpriteTiles(sheet->size / TILE_SIZE_4BPP);

Expand All @@ -1454,11 +1454,16 @@ u16 LoadSpriteSheet(const struct SpriteSheet *sheet)
else
{
AllocSpriteTileRange(sheet->tag, (u16)tileStart, sheet->size / TILE_SIZE_4BPP);
CpuSmartCopy16(sheet->data, (u8 *)OBJ_VRAM0 + TILE_SIZE_4BPP * tileStart, sheet->size);
CpuSmartCopy16(sheet->data, (u8 *)OBJ_VRAM0 + TILE_SIZE_4BPP * tileStart + offset, sheet->size - offset);
return (u16)tileStart;
}
}

u16 LoadSpriteSheet(const struct SpriteSheet *sheet)
{
return LoadSpriteSheetWithOffset(sheet, 0);
}

// Like LoadSpriteSheet, but checks if already loaded, and uses template image frames
u16 LoadSpriteSheetByTemplate(const struct SpriteTemplate *template, u32 frame, s32 offset)
{
Expand All @@ -1469,10 +1474,10 @@ u16 LoadSpriteSheetByTemplate(const struct SpriteTemplate *template, u32 frame,
return TAG_NONE;
if ((tileStart = GetSpriteTileStartByTag(template->tileTag)) != TAG_NONE) // return if already loaded
return tileStart;
sheet.data = template->images[frame].data - offset;
sheet.data = template->images[frame].data;
sheet.size = template->images[frame].size;
sheet.tag = template->tileTag;
return LoadSpriteSheet(&sheet);
return LoadSpriteSheetWithOffset(&sheet, offset);
}

void LoadSpriteSheets(const struct SpriteSheet *sheets)
Expand Down
Loading