all repos — mgba @ 1b6531e32044481feeb0c631ef01bc61d5ccecc6

mGBA Game Boy Advance Emulator

Core: Add more video log types
Vicki Pfau vi@endrift.com
Tue, 18 Apr 2017 01:53:49 -0700
commit

1b6531e32044481feeb0c631ef01bc61d5ccecc6

parent

db4a873d9caab6fbb4d368690b382f7082dd1b12

3 files changed, 55 insertions(+), 5 deletions(-)

jump to
M src/feature/video-logger.csrc/feature/video-logger.c

@@ -127,7 +127,7 @@ };

logger->writeData(logger, &dirty, sizeof(dirty)); } -void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y) { +static void _flushVRAM(struct mVideoLogger* logger) { size_t i; for (i = 0; i < _roundUp(logger->vramSize, 17); ++i) { if (logger->vramDirtyBitmap[i]) {

@@ -141,7 +141,7 @@ }

struct mVideoLoggerDirtyInfo dirty = { DIRTY_VRAM, j * 0x1000, - 0xABCD, + 0x1000, 0xDEADBEEF, }; logger->writeData(logger, &dirty, sizeof(dirty));

@@ -149,6 +149,10 @@ logger->writeData(logger, logger->vramBlock(logger, j * 0x1000), 0x1000);

} } } +} + +void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y) { + _flushVRAM(logger); struct mVideoLoggerDirtyInfo dirty = { DIRTY_SCANLINE, y,

@@ -158,6 +162,17 @@ };

logger->writeData(logger, &dirty, sizeof(dirty)); } +void mVideoLoggerRendererDrawRange(struct mVideoLogger* logger, int startX, int endX, int y) { + _flushVRAM(logger); + struct mVideoLoggerDirtyInfo dirty = { + DIRTY_RANGE, + y, + startX, + endX, + }; + logger->writeData(logger, &dirty, sizeof(dirty)); +} + void mVideoLoggerRendererFlush(struct mVideoLogger* logger) { struct mVideoLoggerDirtyInfo dirty = { DIRTY_FLUSH,

@@ -168,6 +183,27 @@ };

logger->writeData(logger, &dirty, sizeof(dirty)); } +void mVideoLoggerRendererFinishFrame(struct mVideoLogger* logger) { + struct mVideoLoggerDirtyInfo dirty = { + DIRTY_FRAME, + 0, + 0, + 0xDEADBEEF, + }; + logger->writeData(logger, &dirty, sizeof(dirty)); +} + +void mVideoLoggerWriteBuffer(struct mVideoLogger* logger, uint32_t bufferId, uint32_t offset, uint32_t length, const void* data) { + struct mVideoLoggerDirtyInfo dirty = { + DIRTY_BUFFER, + bufferId, + offset, + length, + }; + logger->writeData(logger, &dirty, sizeof(dirty)); + logger->writeData(logger, data, length); +} + bool mVideoLoggerRendererRun(struct mVideoLogger* logger, bool block) { struct mVideoLoggerDirtyInfo item = {0}; while (logger->readData(logger, &item, sizeof(item), block)) {

@@ -178,6 +214,9 @@ case DIRTY_OAM:

case DIRTY_VRAM: case DIRTY_SCANLINE: case DIRTY_FLUSH: + case DIRTY_FRAME: + case DIRTY_RANGE: + case DIRTY_BUFFER: if (!logger->parsePacket(logger, &item)) { return true; }
M src/feature/video-logger.hsrc/feature/video-logger.h

@@ -19,14 +19,17 @@ DIRTY_SCANLINE,

DIRTY_REGISTER, DIRTY_OAM, DIRTY_PALETTE, - DIRTY_VRAM + DIRTY_VRAM, + DIRTY_FRAME, + DIRTY_RANGE, + DIRTY_BUFFER, }; struct mVideoLoggerDirtyInfo { enum mVideoLoggerDirtyType type; uint32_t address; - uint16_t value; - uint32_t padding; + uint32_t value; + uint32_t value2; }; struct VFile;

@@ -104,8 +107,12 @@ void mVideoLoggerRendererWriteVRAM(struct mVideoLogger* logger, uint32_t address);

void mVideoLoggerRendererWritePalette(struct mVideoLogger* logger, uint32_t address, uint16_t value); void mVideoLoggerRendererWriteOAM(struct mVideoLogger* logger, uint32_t address, uint16_t value); +void mVideoLoggerWriteBuffer(struct mVideoLogger* logger, uint32_t bufferId, uint32_t offset, uint32_t length, const void* data); + void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y); +void mVideoLoggerRendererDrawRange(struct mVideoLogger* logger, int startX, int endX, int y); void mVideoLoggerRendererFlush(struct mVideoLogger* logger); +void mVideoLoggerRendererFinishFrame(struct mVideoLogger* logger); bool mVideoLoggerRendererRun(struct mVideoLogger* logger, bool block);
M src/gba/renderers/proxy.csrc/gba/renderers/proxy.c

@@ -144,6 +144,9 @@ break;

case DIRTY_SCANLINE: proxyRenderer->backend->drawScanline(proxyRenderer->backend, item->address); break; + case DIRTY_FRAME: + proxyRenderer->backend->finishFrame(proxyRenderer->backend); + break; case DIRTY_FLUSH: return false; default:

@@ -235,6 +238,7 @@ if (proxyRenderer->logger->block && proxyRenderer->logger->wait) {

proxyRenderer->logger->lock(proxyRenderer->logger); proxyRenderer->logger->wait(proxyRenderer->logger); } + mVideoLoggerRendererFinishFrame(proxyRenderer->logger); mVideoLoggerRendererFlush(proxyRenderer->logger); if (proxyRenderer->logger->block && proxyRenderer->logger->wait) { proxyRenderer->logger->unlock(proxyRenderer->logger);