all repos — mgba @ d5548f6da87cd39070d96e69bc4293c9a121ce89

mGBA Game Boy Advance Emulator

GB Video: More SGB fixes
Vicki Pfau vi@endrift.com
Thu, 04 Oct 2018 10:34:17 -0700
commit

d5548f6da87cd39070d96e69bc4293c9a121ce89

parent

d7f2f5ba06fdf8e3d6feff7d7962323b813a92ad

2 files changed, 11 insertions(+), 10 deletions(-)

jump to
M src/gb/core.csrc/gb/core.c

@@ -1048,6 +1048,7 @@

gb->cpu->pc = GB_BASE_HRAM; gb->cpu->memory.setActiveRegion(gb->cpu, gb->cpu->pc); + GBVideoReset(&gb->video); GBVideoDeserialize(&gb->video, state); GBIODeserialize(gb, state); GBAudioReset(&gb->audio);
M src/gb/renderers/software.csrc/gb/renderers/software.c

@@ -30,7 +30,7 @@ static void GBVideoSoftwareRendererDrawObj(struct GBVideoSoftwareRenderer* renderer, struct GBObj* obj, int startX, int endX, int y);

static void _clearScreen(struct GBVideoSoftwareRenderer* renderer) { size_t sgbOffset = 0; - if (renderer->model == GB_MODEL_SGB) { + if (renderer->model & GB_MODEL_SGB) { return; } int y;

@@ -193,7 +193,7 @@ softwareRenderer->currentWy = 0;

softwareRenderer->lastY = GB_VIDEO_VERTICAL_PIXELS; softwareRenderer->hasWindow = false; softwareRenderer->wx = 0; - softwareRenderer->model = model & ~GB_MODEL_MGB; + softwareRenderer->model = model; softwareRenderer->sgbTransfer = 0; softwareRenderer->sgbCommandHeader = 0; softwareRenderer->sgbBorders = sgbBorders;

@@ -429,7 +429,7 @@

static void GBVideoSoftwareRendererWritePalette(struct GBVideoRenderer* renderer, int index, uint16_t value) { struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer; color_t color = mColorFrom555(value); - if (softwareRenderer->model == GB_MODEL_SGB) { + if (softwareRenderer->model & GB_MODEL_SGB) { if (index < 0x10 && index && !(index & 3)) { color = softwareRenderer->palette[0]; } else if (index >= 0x40 && !(index & 0xF)) {

@@ -460,7 +460,7 @@ #endif

} softwareRenderer->palette[index] = color; - if (softwareRenderer->model == GB_MODEL_SGB && !index && GBRegisterLCDCIsEnable(softwareRenderer->lcdc)) { + if (softwareRenderer->model & GB_MODEL_SGB && !index && GBRegisterLCDCIsEnable(softwareRenderer->lcdc)) { renderer->writePalette(renderer, 0x04, value); renderer->writePalette(renderer, 0x08, value); renderer->writePalette(renderer, 0x0C, value);

@@ -525,7 +525,7 @@ }

} size_t sgbOffset = 0; - if (softwareRenderer->model == GB_MODEL_SGB && softwareRenderer->sgbBorders) { + if (softwareRenderer->model & GB_MODEL_SGB && softwareRenderer->sgbBorders) { sgbOffset = softwareRenderer->outputBufferStride * 40 + 48; } color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y + sgbOffset];

@@ -533,7 +533,7 @@ int x = startX;

int p = 0; switch (softwareRenderer->d.sgbRenderMode) { case 0: - if (softwareRenderer->model == GB_MODEL_SGB) { + if (softwareRenderer->model & GB_MODEL_SGB) { p = softwareRenderer->d.sgbAttributes[(startX >> 5) + 5 * (y >> 3)]; p >>= 6 - ((x / 4) & 0x6); p &= 3;

@@ -543,7 +543,7 @@ for (; x < ((startX + 7) & ~7) && x < endX; ++x) {

row[x] = softwareRenderer->palette[p | softwareRenderer->lookup[softwareRenderer->row[x] & 0x7F]]; } for (; x + 7 < (endX & ~7); x += 8) { - if (softwareRenderer->model == GB_MODEL_SGB) { + if (softwareRenderer->model & GB_MODEL_SGB) { p = softwareRenderer->d.sgbAttributes[(x >> 5) + 5 * (y >> 3)]; p >>= 6 - ((x / 4) & 0x6); p &= 3;

@@ -558,7 +558,7 @@ row[x + 5] = softwareRenderer->palette[p | softwareRenderer->lookup[softwareRenderer->row[x + 5] & 0x7F]];

row[x + 6] = softwareRenderer->palette[p | softwareRenderer->lookup[softwareRenderer->row[x + 6] & 0x7F]]; row[x + 7] = softwareRenderer->palette[p | softwareRenderer->lookup[softwareRenderer->row[x + 7] & 0x7F]]; } - if (softwareRenderer->model == GB_MODEL_SGB) { + if (softwareRenderer->model & GB_MODEL_SGB) { p = softwareRenderer->d.sgbAttributes[(x >> 5) + 5 * (y >> 3)]; p >>= 6 - ((x / 4) & 0x6); p &= 3;

@@ -675,7 +675,7 @@ }

if (!GBRegisterLCDCIsEnable(softwareRenderer->lcdc)) { _clearScreen(softwareRenderer); } - if (softwareRenderer->model == GB_MODEL_SGB) { + if (softwareRenderer->model & GB_MODEL_SGB) { switch (softwareRenderer->sgbCommandHeader >> 3) { case SGB_PAL_SET: case SGB_ATTR_SET:

@@ -708,7 +708,7 @@ }

static void GBVideoSoftwareRendererEnableSGBBorder(struct GBVideoRenderer* renderer, bool enable) { struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer; - if (softwareRenderer->model == GB_MODEL_SGB) { + if (softwareRenderer->model & GB_MODEL_SGB) { if (enable == softwareRenderer->sgbBorders) { return; }