Skip to content

Commit

Permalink
Fix reading banner from homebrew ROMs
Browse files Browse the repository at this point in the history
Some homebrew ROMs do not have a banner, and use a null value to indicate this.
Do not attempt to read the banner when this is the case.
  • Loading branch information
RayyanAnsari committed Sep 2, 2022
1 parent 9d56055 commit c3bd1d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/NDSCart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,15 @@ bool LoadROM(const u8* romdata, u32 romlen)
memcpy(CartROM, romdata, romlen);

memcpy(&Header, CartROM, sizeof(Header));
memcpy(&Banner, CartROM + Header.BannerOffset, sizeof(Banner));

if (!Header.BannerOffset)
{
memset(&Banner, 0, sizeof(Banner));
}
else
{
memcpy(&Banner, CartROM + Header.BannerOffset, sizeof(Banner));
}

printf("Game code: %.4s\n", Header.GameCode);

Expand Down

0 comments on commit c3bd1d2

Please sign in to comment.