all repos — mgba @ ce97e265a3e26f7b1b25de872700fe3ef16fb450

mGBA Game Boy Advance Emulator

GB Video: Add constants for OBJ maxima
Vicki Pfau vi@endrift.com
Sat, 21 Nov 2020 18:10:55 -0800
commit

ce97e265a3e26f7b1b25de872700fe3ef16fb450

parent

7d77aac68fec49a947c71bb67d03c7f08a8c84eb

M include/mgba/gb/interface.hinclude/mgba/gb/interface.h

@@ -10,6 +10,8 @@ #include <mgba-util/common.h>

CXX_GUARD_START +#include <mgba/core/interface.h> + enum GBModel { GB_MODEL_AUTODETECT = 0xFF, GB_MODEL_DMG = 0x00,
M include/mgba/internal/gb/video.hinclude/mgba/internal/gb/video.h

@@ -31,6 +31,9 @@ GB_VIDEO_HORIZONTAL_LENGTH = 456,

GB_VIDEO_TOTAL_LENGTH = 70224, + GB_VIDEO_MAX_OBJ = 40, + GB_VIDEO_MAX_LINE_OBJ = 10, + GB_BASE_MAP = 0x1800, GB_SIZE_MAP = 0x0400,

@@ -63,8 +66,8 @@ GBObjAttributes attr;

}; union GBOAM { - struct GBObj obj[40]; - uint8_t raw[160]; + struct GBObj obj[GB_VIDEO_MAX_OBJ]; + uint8_t raw[GB_VIDEO_MAX_OBJ * 4]; }; struct mCacheSet;
M src/gb/extra/proxy.csrc/gb/extra/proxy.c

@@ -119,7 +119,7 @@

static bool _parsePacket(struct mVideoLogger* logger, const struct mVideoLoggerDirtyInfo* item) { struct GBVideoProxyRenderer* proxyRenderer = logger->context; uint8_t sgbPacket[16]; - struct GBObj legacyBuffer[40]; + struct GBObj legacyBuffer[GB_VIDEO_MAX_OBJ]; switch (item->type) { case DIRTY_REGISTER: proxyRenderer->backend->writeVideoRegister(proxyRenderer->backend, item->address, item->value);

@@ -160,7 +160,7 @@ break;

case DIRTY_BUFFER: switch (item->address) { case BUFFER_OAM: - if (item->value2 / sizeof(struct GBObj) > 40) { + if (item->value2 / sizeof(struct GBObj) > GB_VIDEO_MAX_OBJ) { return false; } logger->readData(logger, legacyBuffer, item->value2, true);
M src/gb/renderers/software.csrc/gb/renderers/software.c

@@ -508,7 +508,7 @@ spriteHeight = 16;

} int o = 0; int i; - for (i = 0; i < 40 && o < 10; ++i) { + for (i = 0; i < GB_VIDEO_MAX_OBJ && o < GB_VIDEO_MAX_LINE_OBJ; ++i) { uint8_t oy = renderer->d.oam->obj[i].y; if (y < oy - 16 || y >= oy - 16 + spriteHeight) { continue;
M src/gb/video.csrc/gb/video.c

@@ -409,7 +409,7 @@ spriteHeight = 16;

} int o = 0; int i; - for (i = 0; i < 40 && o < 10; ++i) { + for (i = 0; i < GB_VIDEO_MAX_OBJ && o < GB_VIDEO_MAX_LINE_OBJ; ++i) { uint8_t oy = video->oam.obj[i].y; if (y < oy - 16 || y >= oy - 16 + spriteHeight) { continue;