- Començant a implementar el pintat de sprites
This commit is contained in:
31
gbscreen.cpp
31
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) && (LY<y+height) ) {
|
||||
obj_list[num_obj_found]=obj;
|
||||
uint8_t i = num_obj_found;
|
||||
while( (i>0) && (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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user