diff --git a/gbscreen.cpp b/gbscreen.cpp index 41deab2..4d54c86 100644 --- a/gbscreen.cpp +++ b/gbscreen.cpp @@ -245,10 +245,10 @@ namespace gbscreen obj=0; while (obj_list[obj] != 255) { oam_entry_t *o = &oam[obj_list[obj]]; - const uint8_t ly = uint8_t(LY-o->y) & 0x7; + const uint8_t ly = uint8_t(LY-o->y) & 0xf; uint16_t tile = height==8 ? o->tile : o->tile & 0xFE; // si es dos tiles de alt, el primer sempre comença en numero parell - uint8_t yflip = o->attr&0x40 ? 8-ly : ly; // està invertit verticalment? + uint8_t yflip = o->attr&0x40 ? (height-1)-ly : ly; // està invertit verticalment? uint16_t tile_address = 0x8000 + (tile<<4) + (yflip*2); uint8_t a = mem::readMem(tile_address); @@ -262,7 +262,7 @@ namespace gbscreen const uint8_t ppos = 1 << ( o->attr&0x20 ? i : 7-i); const uint8_t val = (a&ppos ? 1 : 0) + (b&ppos ? 2 : 0 ); // agafem el pixel que toca if (val) { // Si el pixel no es transparent... - const uint8_t color = (OBP[(LCDC>>4)&1] >> (val*2)) & 0x3; + const uint8_t color = (OBP[(o->attr>>4)&1] >> (val*2)) & 0x3; pixels[o->x+i-8] = color | o->attr&0x80;; // el pintem al buffer, amb el flag de prioritat respecte al BKG x_pos[o->x+i-8] = o->x; // I apuntem la seua x per a comparar després }