mirror of https://github.com/mgba-emu/mgba.git
DS Video: Allow capture of 2D engine
This commit is contained in:
parent
4bde13effb
commit
faf99ac304
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
CXX_GUARD_START
|
CXX_GUARD_START
|
||||||
|
|
||||||
|
#include <mgba/core/interface.h>
|
||||||
#include <mgba/core/log.h>
|
#include <mgba/core/log.h>
|
||||||
#include <mgba/core/timing.h>
|
#include <mgba/core/timing.h>
|
||||||
#include <mgba/internal/gba/video.h>
|
#include <mgba/internal/gba/video.h>
|
||||||
|
@ -95,6 +96,7 @@ struct DSVideoRenderer {
|
||||||
void (*writeOAM)(struct DSVideoRenderer* renderer, uint32_t oam);
|
void (*writeOAM)(struct DSVideoRenderer* renderer, uint32_t oam);
|
||||||
void (*invalidateExtPal)(struct DSVideoRenderer* renderer, bool obj, bool engB, int slot);
|
void (*invalidateExtPal)(struct DSVideoRenderer* renderer, bool obj, bool engB, int slot);
|
||||||
void (*drawScanline)(struct DSVideoRenderer* renderer, int y);
|
void (*drawScanline)(struct DSVideoRenderer* renderer, int y);
|
||||||
|
void (*drawScanlineDirectly)(struct DSVideoRenderer* renderer, int y, color_t* scanline);
|
||||||
void (*finishFrame)(struct DSVideoRenderer* renderer);
|
void (*finishFrame)(struct DSVideoRenderer* renderer);
|
||||||
|
|
||||||
void (*getPixels)(struct DSVideoRenderer* renderer, size_t* stride, const void** pixels);
|
void (*getPixels)(struct DSVideoRenderer* renderer, size_t* stride, const void** pixels);
|
||||||
|
|
|
@ -18,6 +18,7 @@ static void DSVideoSoftwareRendererWritePalette(struct DSVideoRenderer* renderer
|
||||||
static void DSVideoSoftwareRendererWriteOAM(struct DSVideoRenderer* renderer, uint32_t oam);
|
static void DSVideoSoftwareRendererWriteOAM(struct DSVideoRenderer* renderer, uint32_t oam);
|
||||||
static void DSVideoSoftwareRendererInvalidateExtPal(struct DSVideoRenderer* renderer, bool obj, bool engB, int slot);
|
static void DSVideoSoftwareRendererInvalidateExtPal(struct DSVideoRenderer* renderer, bool obj, bool engB, int slot);
|
||||||
static void DSVideoSoftwareRendererDrawScanline(struct DSVideoRenderer* renderer, int y);
|
static void DSVideoSoftwareRendererDrawScanline(struct DSVideoRenderer* renderer, int y);
|
||||||
|
static void DSVideoSoftwareRendererDrawScanlineDirectly(struct DSVideoRenderer* renderer, int y, color_t* scanline);
|
||||||
static void DSVideoSoftwareRendererFinishFrame(struct DSVideoRenderer* renderer);
|
static void DSVideoSoftwareRendererFinishFrame(struct DSVideoRenderer* renderer);
|
||||||
static void DSVideoSoftwareRendererGetPixels(struct DSVideoRenderer* renderer, size_t* stride, const void** pixels);
|
static void DSVideoSoftwareRendererGetPixels(struct DSVideoRenderer* renderer, size_t* stride, const void** pixels);
|
||||||
static void DSVideoSoftwareRendererPutPixels(struct DSVideoRenderer* renderer, size_t stride, const void* pixels);
|
static void DSVideoSoftwareRendererPutPixels(struct DSVideoRenderer* renderer, size_t stride, const void* pixels);
|
||||||
|
@ -139,6 +140,7 @@ void DSVideoSoftwareRendererCreate(struct DSVideoSoftwareRenderer* renderer) {
|
||||||
renderer->d.writeOAM = DSVideoSoftwareRendererWriteOAM;
|
renderer->d.writeOAM = DSVideoSoftwareRendererWriteOAM;
|
||||||
renderer->d.invalidateExtPal = DSVideoSoftwareRendererInvalidateExtPal;
|
renderer->d.invalidateExtPal = DSVideoSoftwareRendererInvalidateExtPal;
|
||||||
renderer->d.drawScanline = DSVideoSoftwareRendererDrawScanline;
|
renderer->d.drawScanline = DSVideoSoftwareRendererDrawScanline;
|
||||||
|
renderer->d.drawScanlineDirectly = DSVideoSoftwareRendererDrawScanlineDirectly;
|
||||||
renderer->d.finishFrame = DSVideoSoftwareRendererFinishFrame;
|
renderer->d.finishFrame = DSVideoSoftwareRendererFinishFrame;
|
||||||
renderer->d.getPixels = DSVideoSoftwareRendererGetPixels;
|
renderer->d.getPixels = DSVideoSoftwareRendererGetPixels;
|
||||||
renderer->d.putPixels = DSVideoSoftwareRendererPutPixels;
|
renderer->d.putPixels = DSVideoSoftwareRendererPutPixels;
|
||||||
|
@ -578,6 +580,17 @@ static void DSVideoSoftwareRendererDrawScanline(struct DSVideoRenderer* renderer
|
||||||
_drawScanlineB(softwareRenderer, y);
|
_drawScanlineB(softwareRenderer, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DSVideoSoftwareRendererDrawScanlineDirectly(struct DSVideoRenderer* renderer, int y, color_t* scanline) {
|
||||||
|
struct DSVideoSoftwareRenderer* softwareRenderer = (struct DSVideoSoftwareRenderer*) renderer;
|
||||||
|
if (!DSRegisterPOWCNT1IsSwap(softwareRenderer->powcnt)) {
|
||||||
|
softwareRenderer->engA.outputBuffer = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * DS_VIDEO_VERTICAL_PIXELS];
|
||||||
|
} else {
|
||||||
|
softwareRenderer->engA.outputBuffer = softwareRenderer->outputBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
DSVideoSoftwareRendererDrawGBAScanline(&softwareRenderer->engA.d, softwareRenderer->d.gx, y);
|
||||||
|
}
|
||||||
|
|
||||||
static void DSVideoSoftwareRendererFinishFrame(struct DSVideoRenderer* renderer) {
|
static void DSVideoSoftwareRendererFinishFrame(struct DSVideoRenderer* renderer) {
|
||||||
struct DSVideoSoftwareRenderer* softwareRenderer = (struct DSVideoSoftwareRenderer*) renderer;
|
struct DSVideoSoftwareRenderer* softwareRenderer = (struct DSVideoSoftwareRenderer*) renderer;
|
||||||
softwareRenderer->engA.d.finishFrame(&softwareRenderer->engA.d);
|
softwareRenderer->engA.d.finishFrame(&softwareRenderer->engA.d);
|
||||||
|
|
|
@ -23,6 +23,7 @@ static void DSVideoDummyRendererWritePalette(struct DSVideoRenderer* renderer, u
|
||||||
static void DSVideoDummyRendererWriteOAM(struct DSVideoRenderer* renderer, uint32_t oam);
|
static void DSVideoDummyRendererWriteOAM(struct DSVideoRenderer* renderer, uint32_t oam);
|
||||||
static void DSVideoDummyRendererInvalidateExtPal(struct DSVideoRenderer* renderer, bool obj, bool engB, int slot);
|
static void DSVideoDummyRendererInvalidateExtPal(struct DSVideoRenderer* renderer, bool obj, bool engB, int slot);
|
||||||
static void DSVideoDummyRendererDrawScanline(struct DSVideoRenderer* renderer, int y);
|
static void DSVideoDummyRendererDrawScanline(struct DSVideoRenderer* renderer, int y);
|
||||||
|
static void DSVideoDummyRendererDrawScanlineDirectly(struct DSVideoRenderer* renderer, int y, color_t* scanline);
|
||||||
static void DSVideoDummyRendererFinishFrame(struct DSVideoRenderer* renderer);
|
static void DSVideoDummyRendererFinishFrame(struct DSVideoRenderer* renderer);
|
||||||
static void DSVideoDummyRendererGetPixels(struct DSVideoRenderer* renderer, size_t* stride, const void** pixels);
|
static void DSVideoDummyRendererGetPixels(struct DSVideoRenderer* renderer, size_t* stride, const void** pixels);
|
||||||
static void DSVideoDummyRendererPutPixels(struct DSVideoRenderer* renderer, size_t stride, const void* pixels);
|
static void DSVideoDummyRendererPutPixels(struct DSVideoRenderer* renderer, size_t stride, const void* pixels);
|
||||||
|
@ -136,6 +137,7 @@ static struct DSVideoRenderer dummyRenderer = {
|
||||||
.writeOAM = DSVideoDummyRendererWriteOAM,
|
.writeOAM = DSVideoDummyRendererWriteOAM,
|
||||||
.invalidateExtPal = DSVideoDummyRendererInvalidateExtPal,
|
.invalidateExtPal = DSVideoDummyRendererInvalidateExtPal,
|
||||||
.drawScanline = DSVideoDummyRendererDrawScanline,
|
.drawScanline = DSVideoDummyRendererDrawScanline,
|
||||||
|
.drawScanlineDirectly = DSVideoDummyRendererDrawScanlineDirectly,
|
||||||
.finishFrame = DSVideoDummyRendererFinishFrame,
|
.finishFrame = DSVideoDummyRendererFinishFrame,
|
||||||
.getPixels = DSVideoDummyRendererGetPixels,
|
.getPixels = DSVideoDummyRendererGetPixels,
|
||||||
.putPixels = DSVideoDummyRendererPutPixels,
|
.putPixels = DSVideoDummyRendererPutPixels,
|
||||||
|
@ -221,6 +223,7 @@ static void _performCapture(struct DSVideo* video, int y) {
|
||||||
}
|
}
|
||||||
uint16_t* vram = &video->vram[0x10000 * block + DSRegisterDISPCAPCNTGetWriteOffset(dispcap) * 0x4000];
|
uint16_t* vram = &video->vram[0x10000 * block + DSRegisterDISPCAPCNTGetWriteOffset(dispcap) * 0x4000];
|
||||||
const color_t* pixelsA;
|
const color_t* pixelsA;
|
||||||
|
color_t pixels[DS_VIDEO_VERTICAL_PIXELS];
|
||||||
int width = DS_VIDEO_HORIZONTAL_PIXELS;
|
int width = DS_VIDEO_HORIZONTAL_PIXELS;
|
||||||
switch (DSRegisterDISPCAPCNTGetCaptureSize(dispcap)) {
|
switch (DSRegisterDISPCAPCNTGetCaptureSize(dispcap)) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -239,15 +242,13 @@ static void _performCapture(struct DSVideo* video, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
video->p->gx.renderer->getScanline(video->p->gx.renderer, y, &pixelsA);
|
video->p->gx.renderer->getScanline(video->p->gx.renderer, y, &pixelsA);
|
||||||
/*if (DSRegisterDISPCAPCNTIsSourceA(dispcap)) {
|
if (DSRegisterDISPCAPCNTIsSourceA(dispcap)) {
|
||||||
// TODO: Process scanline regardless of output type
|
// TODO: Process scanline regardless of output type
|
||||||
video->p->gx.renderer->getScanline(video->p->gx.renderer, y, &pixelsA);
|
video->p->gx.renderer->getScanline(video->p->gx.renderer, y, &pixelsA);
|
||||||
} else {
|
} else {
|
||||||
size_t stride;
|
video->renderer->drawScanlineDirectly(video->renderer, y, pixels);
|
||||||
const void* pixels;
|
pixelsA = pixels;
|
||||||
video->renderer->getPixels(video->renderer, &stride, &pixels);
|
}
|
||||||
pixelsA = &((const color_t*) pixels)[stride * y];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
uint16_t pixel;
|
uint16_t pixel;
|
||||||
int x;
|
int x;
|
||||||
|
@ -636,6 +637,13 @@ static void DSVideoDummyRendererDrawScanline(struct DSVideoRenderer* renderer, i
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DSVideoDummyRendererDrawScanlineDirectly(struct DSVideoRenderer* renderer, int y, color_t* scanline) {
|
||||||
|
UNUSED(renderer);
|
||||||
|
UNUSED(y);
|
||||||
|
UNUSED(scanline);
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
static void DSVideoDummyRendererFinishFrame(struct DSVideoRenderer* renderer) {
|
static void DSVideoDummyRendererFinishFrame(struct DSVideoRenderer* renderer) {
|
||||||
UNUSED(renderer);
|
UNUSED(renderer);
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
|
|
Loading…
Reference in New Issue