From 771136e712e67ba5109750cf86e7e66608078249 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 24 Jan 2025 07:30:45 +0100 Subject: [PATCH] =?UTF-8?q?-=20Comen=C3=A7ant=20a=20implementar=20el=20pin?= =?UTF-8?q?tat=20de=20sprites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gbscreen.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/gbscreen.cpp b/gbscreen.cpp index 30e6fc7..61001c6 100644 --- a/gbscreen.cpp +++ b/gbscreen.cpp @@ -132,7 +132,7 @@ namespace gbscreen } } - void fill_line_buffer(uint8_t LY) + void fill_line_buffer_bkg(uint8_t LY) { const uint8_t LCDC = mem::readMem(0xff40); const uint8_t SCY = mem::readMem(0xff42); @@ -167,6 +167,33 @@ namespace gbscreen } } + struct oam_entry_t + { + uint8_t y, tile, attr; + }; + + void fill_line_buffer_obj(uint8_t LY) + { + const uint8_t LCDC = mem::readMem(0xff40); + if ((LCDC & 0x2) == 0) return; + + const uint8_t height = (LCDC & 0x4) ? 16 : 8; + uint8_t obj_list[10] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; + int num_obj_found=0; + int obj=0; + while (obj<40 && num_obj_found<10) + { + const uint8_t y = mem::readMem(0xff00+(obj*4)); + if ( (LY>=y) && (LY0) && (obj_list[i-1]) ) + num_obj_found++; + } + obj++; + } + } + void refresh(const uint32_t dt, const bool full) { const uint8_t LCDC = mem::readMem(0xff40); @@ -216,7 +243,7 @@ namespace gbscreen { STAT = (STAT & 0xFC) | 0x02; // Set mode 2 if (STAT&0x20) stat_interrupt = true; - fill_line_buffer(LY); + fill_line_buffer_bkg(LY); } else if (LY==154) {