GB: Drop invalid SGB packets

This commit is contained in:
Vicki Pfau 2017-08-03 19:35:00 -07:00
parent da10c3bbec
commit 75e609f65c
1 changed files with 4 additions and 0 deletions

View File

@ -552,6 +552,10 @@ void GBVideoSetPalette(struct GBVideo* video, unsigned index, uint32_t color) {
void GBVideoWriteSGBPacket(struct GBVideo* video, uint8_t* data) {
int i;
if (!(video->sgbCommandHeader & 7)) {
if ((data[0] >> 3) > SGB_OBJ_TRN) {
video->sgbCommandHeader = 0;
return;
}
video->sgbCommandHeader = data[0];
}
--video->sgbCommandHeader;