diff --git a/include/mgba/gba/interface.h b/include/mgba/gba/interface.h index e620c108e..930faa925 100644 --- a/include/mgba/gba/interface.h +++ b/include/mgba/gba/interface.h @@ -13,6 +13,11 @@ CXX_GUARD_START #include #include +enum { + GBA_VIDEO_HORIZONTAL_PIXELS = 240, + GBA_VIDEO_VERTICAL_PIXELS = 160, +}; + enum GBASIOMode { SIO_NORMAL_8 = 0, SIO_NORMAL_32 = 1, diff --git a/include/mgba/internal/gba/renderers/video-software.h b/include/mgba/internal/gba/renderers/video-software.h index d7831c5ac..8bfc3da9b 100644 --- a/include/mgba/internal/gba/renderers/video-software.h +++ b/include/mgba/internal/gba/renderers/video-software.h @@ -11,6 +11,7 @@ CXX_GUARD_START #include +#include #include #include @@ -122,8 +123,8 @@ struct GBAVideoSoftwareRenderer { GBARegisterDISPCNT dispcnt; - uint32_t row[VIDEO_HORIZONTAL_PIXELS]; - uint32_t spriteLayer[VIDEO_HORIZONTAL_PIXELS]; + uint32_t row[GBA_VIDEO_HORIZONTAL_PIXELS]; + uint32_t spriteLayer[GBA_VIDEO_HORIZONTAL_PIXELS]; int32_t spriteCyclesRemaining; // BLDCNT @@ -169,7 +170,7 @@ struct GBAVideoSoftwareRenderer { struct ScanlineCache { uint16_t io[REG_SOUND1CNT_LO]; int32_t scale[2][2]; - } cache[VIDEO_VERTICAL_PIXELS]; + } cache[GBA_VIDEO_VERTICAL_PIXELS]; int nextY; int start; diff --git a/include/mgba/internal/gba/video.h b/include/mgba/internal/gba/video.h index 265cb89aa..15e3a4381 100644 --- a/include/mgba/internal/gba/video.h +++ b/include/mgba/internal/gba/video.h @@ -16,13 +16,11 @@ CXX_GUARD_START mLOG_DECLARE_CATEGORY(GBA_VIDEO); enum { - VIDEO_HORIZONTAL_PIXELS = 240, VIDEO_HBLANK_PIXELS = 68, VIDEO_HDRAW_LENGTH = 1006, VIDEO_HBLANK_LENGTH = 226, VIDEO_HORIZONTAL_LENGTH = 1232, - VIDEO_VERTICAL_PIXELS = 160, VIDEO_VBLANK_PIXELS = 68, VIDEO_VERTICAL_TOTAL_PIXELS = 228, diff --git a/src/feature/ffmpeg/ffmpeg-encoder.c b/src/feature/ffmpeg/ffmpeg-encoder.c index c1c6439b4..c17bc5b8c 100644 --- a/src/feature/ffmpeg/ffmpeg-encoder.c +++ b/src/feature/ffmpeg/ffmpeg-encoder.c @@ -6,7 +6,7 @@ #include "ffmpeg-encoder.h" #include -#include +#include #include #include @@ -48,9 +48,9 @@ void FFmpegEncoderInit(struct FFmpegEncoder* encoder) { FFmpegEncoderSetAudio(encoder, "flac", 0); FFmpegEncoderSetVideo(encoder, "png", 0); FFmpegEncoderSetContainer(encoder, "matroska"); - FFmpegEncoderSetDimensions(encoder, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); - encoder->iwidth = VIDEO_HORIZONTAL_PIXELS; - encoder->iheight = VIDEO_VERTICAL_PIXELS; + FFmpegEncoderSetDimensions(encoder, GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); + encoder->iwidth = GBA_VIDEO_HORIZONTAL_PIXELS; + encoder->iheight = GBA_VIDEO_VERTICAL_PIXELS; encoder->resampleContext = 0; encoder->absf = 0; encoder->context = 0; @@ -175,8 +175,8 @@ bool FFmpegEncoderSetContainer(struct FFmpegEncoder* encoder, const char* contai } void FFmpegEncoderSetDimensions(struct FFmpegEncoder* encoder, int width, int height) { - encoder->width = width > 0 ? width : VIDEO_HORIZONTAL_PIXELS; - encoder->height = height > 0 ? height : VIDEO_VERTICAL_PIXELS; + encoder->width = width > 0 ? width : GBA_VIDEO_HORIZONTAL_PIXELS; + encoder->height = height > 0 ? height : GBA_VIDEO_VERTICAL_PIXELS; } bool FFmpegEncoderVerifyContainer(struct FFmpegEncoder* encoder) { diff --git a/src/feature/imagemagick/imagemagick-gif-encoder.c b/src/feature/imagemagick/imagemagick-gif-encoder.c index 1e0ddb6e6..8d8ebcb5c 100644 --- a/src/feature/imagemagick/imagemagick-gif-encoder.c +++ b/src/feature/imagemagick/imagemagick-gif-encoder.c @@ -6,7 +6,7 @@ #include "imagemagick-gif-encoder.h" #include -#include +#include #include static void _magickPostVideoFrame(struct mAVStream*, const color_t* pixels, size_t stride); @@ -23,8 +23,8 @@ void ImageMagickGIFEncoderInit(struct ImageMagickGIFEncoder* encoder) { encoder->frameskip = 2; encoder->delayMs = -1; - encoder->iwidth = VIDEO_HORIZONTAL_PIXELS; - encoder->iheight = VIDEO_VERTICAL_PIXELS; + encoder->iwidth = GBA_VIDEO_HORIZONTAL_PIXELS; + encoder->iheight = GBA_VIDEO_VERTICAL_PIXELS; } void ImageMagickGIFEncoderSetParams(struct ImageMagickGIFEncoder* encoder, int frameskip, int delayMs) { diff --git a/src/gba/core.c b/src/gba/core.c index 7d00f963c..8966fbe37 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -254,8 +254,8 @@ static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* con static void _GBACoreDesiredVideoDimensions(struct mCore* core, unsigned* width, unsigned* height) { UNUSED(core); - *width = VIDEO_HORIZONTAL_PIXELS; - *height = VIDEO_VERTICAL_PIXELS; + *width = GBA_VIDEO_HORIZONTAL_PIXELS; + *height = GBA_VIDEO_VERTICAL_PIXELS; } static void _GBACoreSetVideoBuffer(struct mCore* core, color_t* buffer, size_t stride) { @@ -311,7 +311,7 @@ static void _GBACoreSetAVStream(struct mCore* core, struct mAVStream* stream) { struct GBA* gba = core->board; gba->stream = stream; if (stream && stream->videoDimensionsChanged) { - stream->videoDimensionsChanged(stream, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + stream->videoDimensionsChanged(stream, GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); } } diff --git a/src/gba/dma.c b/src/gba/dma.c index bb13350a9..765358da1 100644 --- a/src/gba/dma.c +++ b/src/gba/dma.c @@ -182,7 +182,7 @@ void _dmaEvent(struct mTiming* timing, void* context, uint32_t cyclesLate) { dma->nextCount = 0; bool noRepeat = !GBADMARegisterIsRepeat(dma->reg); noRepeat |= GBADMARegisterGetTiming(dma->reg) == GBA_DMA_TIMING_NOW; - noRepeat |= memory->activeDMA == 3 && GBADMARegisterGetTiming(dma->reg) == GBA_DMA_TIMING_CUSTOM && gba->video.vcount == VIDEO_VERTICAL_PIXELS + 1; + noRepeat |= memory->activeDMA == 3 && GBADMARegisterGetTiming(dma->reg) == GBA_DMA_TIMING_CUSTOM && gba->video.vcount == GBA_VIDEO_VERTICAL_PIXELS + 1; if (noRepeat) { dma->reg = GBADMARegisterClearEnable(dma->reg); diff --git a/src/gba/extra/proxy.c b/src/gba/extra/proxy.c index d7092f30c..deeec5603 100644 --- a/src/gba/extra/proxy.c +++ b/src/gba/extra/proxy.c @@ -151,7 +151,7 @@ static bool _parsePacket(struct mVideoLogger* logger, const struct mVideoLoggerD } break; case DIRTY_SCANLINE: - if (item->address < VIDEO_VERTICAL_PIXELS) { + if (item->address < GBA_VIDEO_VERTICAL_PIXELS) { proxyRenderer->backend->drawScanline(proxyRenderer->backend, item->address); } break; diff --git a/src/gba/renderers/software-bg.c b/src/gba/renderers/software-bg.c index 9655166e1..db4b33e71 100644 --- a/src/gba/renderers/software-bg.c +++ b/src/gba/renderers/software-bg.c @@ -98,10 +98,10 @@ void GBAVideoSoftwareRendererDrawBackgroundMode3(struct GBAVideoSoftwareRenderer int outX; uint32_t* pixel; for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) { - BACKGROUND_BITMAP_ITERATE(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + BACKGROUND_BITMAP_ITERATE(GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); if (!mosaicWait) { - LOAD_16(color, ((localX >> 8) + (localY >> 8) * VIDEO_HORIZONTAL_PIXELS) << 1, renderer->d.vram); + LOAD_16(color, ((localX >> 8) + (localY >> 8) * GBA_VIDEO_HORIZONTAL_PIXELS) << 1, renderer->d.vram); color = mColorFrom555(color); mosaicWait = mosaicH; } else { @@ -137,10 +137,10 @@ void GBAVideoSoftwareRendererDrawBackgroundMode4(struct GBAVideoSoftwareRenderer int outX; uint32_t* pixel; for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) { - BACKGROUND_BITMAP_ITERATE(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + BACKGROUND_BITMAP_ITERATE(GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); if (!mosaicWait) { - color = ((uint8_t*)renderer->d.vram)[offset + (localX >> 8) + (localY >> 8) * VIDEO_HORIZONTAL_PIXELS]; + color = ((uint8_t*)renderer->d.vram)[offset + (localX >> 8) + (localY >> 8) * GBA_VIDEO_HORIZONTAL_PIXELS]; mosaicWait = mosaicH; } else { diff --git a/src/gba/renderers/software-mode0.c b/src/gba/renderers/software-mode0.c index 944232068..df5626c4b 100644 --- a/src/gba/renderers/software-mode0.c +++ b/src/gba/renderers/software-mode0.c @@ -378,7 +378,7 @@ if (background->mosaic && GBAMosaicControlGetBgH(renderer->mosaic)) { \ int mosaicH = GBAMosaicControlGetBgH(renderer->mosaic) + 1; \ int x; \ - int mosaicWait = (mosaicH - outX + VIDEO_HORIZONTAL_PIXELS * mosaicH) % mosaicH; \ + int mosaicWait = (mosaicH - outX + GBA_VIDEO_HORIZONTAL_PIXELS * mosaicH) % mosaicH; \ int carryData = 0; \ paletteData = 0; /* Quiets compiler warning */ \ DRAW_BACKGROUND_MODE_0_MOSAIC_ ## BPP (BLEND, OBJWIN) \ @@ -417,7 +417,7 @@ /*! TODO: Make sure these lines can be removed */ \ /*!*/ pixel = &renderer->row[outX]; \ outX += (tileEnd - tileX) * 8; \ - /*!*/ if (VIDEO_CHECKS && UNLIKELY(outX > VIDEO_HORIZONTAL_PIXELS)) { \ + /*!*/ if (VIDEO_CHECKS && UNLIKELY(outX > GBA_VIDEO_HORIZONTAL_PIXELS)) { \ /*!*/ mLOG(GBA_VIDEO, FATAL, "Out of bounds background draw would occur!"); \ /*!*/ return; \ /*!*/ } \ @@ -440,7 +440,7 @@ if (VIDEO_CHECKS && UNLIKELY(&renderer->row[outX] != pixel)) { \ mLOG(GBA_VIDEO, FATAL, "Background draw ended in the wrong place! Diff: %" PRIXPTR, &renderer->row[outX] - pixel); \ } \ - if (VIDEO_CHECKS && UNLIKELY(outX > VIDEO_HORIZONTAL_PIXELS)) { \ + if (VIDEO_CHECKS && UNLIKELY(outX > GBA_VIDEO_HORIZONTAL_PIXELS)) { \ mLOG(GBA_VIDEO, FATAL, "Out of bounds background draw occurred!"); \ return; \ } diff --git a/src/gba/renderers/software-obj.c b/src/gba/renderers/software-obj.c index ad846ace0..cb7441666 100644 --- a/src/gba/renderers/software-obj.c +++ b/src/gba/renderers/software-obj.c @@ -261,8 +261,8 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re SPRITE_TRANSFORMED_LOOP(256, NORMAL); } } - if (end == VIDEO_HORIZONTAL_PIXELS && x + totalWidth > VIDEO_HORIZONTAL_PIXELS) { - renderer->spriteCyclesRemaining -= (x + totalWidth - VIDEO_HORIZONTAL_PIXELS) * 2; + if (end == GBA_VIDEO_HORIZONTAL_PIXELS && x + totalWidth > GBA_VIDEO_HORIZONTAL_PIXELS) { + renderer->spriteCyclesRemaining -= (x + totalWidth - GBA_VIDEO_HORIZONTAL_PIXELS) * 2; } } else { int outX = x >= start ? x : start; @@ -321,8 +321,8 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re SPRITE_NORMAL_LOOP(256, NORMAL); } } - if (end == VIDEO_HORIZONTAL_PIXELS && x + width > VIDEO_HORIZONTAL_PIXELS) { - renderer->spriteCyclesRemaining -= x + width - VIDEO_HORIZONTAL_PIXELS; + if (end == GBA_VIDEO_HORIZONTAL_PIXELS && x + width > GBA_VIDEO_HORIZONTAL_PIXELS) { + renderer->spriteCyclesRemaining -= x + width - GBA_VIDEO_HORIZONTAL_PIXELS; } } return 1; diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index 6c4853bab..951febc5e 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -72,10 +72,10 @@ static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer) { struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; int y; - for (y = 0; y < VIDEO_VERTICAL_PIXELS; ++y) { + for (y = 0; y < GBA_VIDEO_VERTICAL_PIXELS; ++y) { color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; int x; - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x) { + for (x = 0; x < GBA_VIDEO_HORIZONTAL_PIXELS; ++x) { row[x] = GBA_COLOR_WHITE; } } @@ -315,52 +315,52 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender case REG_WIN0H: softwareRenderer->winN[0].h.end = value; softwareRenderer->winN[0].h.start = value >> 8; - if (softwareRenderer->winN[0].h.start > VIDEO_HORIZONTAL_PIXELS && softwareRenderer->winN[0].h.start > softwareRenderer->winN[0].h.end) { + if (softwareRenderer->winN[0].h.start > GBA_VIDEO_HORIZONTAL_PIXELS && softwareRenderer->winN[0].h.start > softwareRenderer->winN[0].h.end) { softwareRenderer->winN[0].h.start = 0; } - if (softwareRenderer->winN[0].h.end > VIDEO_HORIZONTAL_PIXELS) { - softwareRenderer->winN[0].h.end = VIDEO_HORIZONTAL_PIXELS; - if (softwareRenderer->winN[0].h.start > VIDEO_HORIZONTAL_PIXELS) { - softwareRenderer->winN[0].h.start = VIDEO_HORIZONTAL_PIXELS; + if (softwareRenderer->winN[0].h.end > GBA_VIDEO_HORIZONTAL_PIXELS) { + softwareRenderer->winN[0].h.end = GBA_VIDEO_HORIZONTAL_PIXELS; + if (softwareRenderer->winN[0].h.start > GBA_VIDEO_HORIZONTAL_PIXELS) { + softwareRenderer->winN[0].h.start = GBA_VIDEO_HORIZONTAL_PIXELS; } } break; case REG_WIN1H: softwareRenderer->winN[1].h.end = value; softwareRenderer->winN[1].h.start = value >> 8; - if (softwareRenderer->winN[1].h.start > VIDEO_HORIZONTAL_PIXELS && softwareRenderer->winN[1].h.start > softwareRenderer->winN[1].h.end) { + if (softwareRenderer->winN[1].h.start > GBA_VIDEO_HORIZONTAL_PIXELS && softwareRenderer->winN[1].h.start > softwareRenderer->winN[1].h.end) { softwareRenderer->winN[1].h.start = 0; } - if (softwareRenderer->winN[1].h.end > VIDEO_HORIZONTAL_PIXELS) { - softwareRenderer->winN[1].h.end = VIDEO_HORIZONTAL_PIXELS; - if (softwareRenderer->winN[1].h.start > VIDEO_HORIZONTAL_PIXELS) { - softwareRenderer->winN[1].h.start = VIDEO_HORIZONTAL_PIXELS; + if (softwareRenderer->winN[1].h.end > GBA_VIDEO_HORIZONTAL_PIXELS) { + softwareRenderer->winN[1].h.end = GBA_VIDEO_HORIZONTAL_PIXELS; + if (softwareRenderer->winN[1].h.start > GBA_VIDEO_HORIZONTAL_PIXELS) { + softwareRenderer->winN[1].h.start = GBA_VIDEO_HORIZONTAL_PIXELS; } } break; case REG_WIN0V: softwareRenderer->winN[0].v.end = value; softwareRenderer->winN[0].v.start = value >> 8; - if (softwareRenderer->winN[0].v.start > VIDEO_VERTICAL_PIXELS && softwareRenderer->winN[0].v.start > softwareRenderer->winN[0].v.end) { + if (softwareRenderer->winN[0].v.start > GBA_VIDEO_VERTICAL_PIXELS && softwareRenderer->winN[0].v.start > softwareRenderer->winN[0].v.end) { softwareRenderer->winN[0].v.start = 0; } - if (softwareRenderer->winN[0].v.end > VIDEO_VERTICAL_PIXELS) { - softwareRenderer->winN[0].v.end = VIDEO_VERTICAL_PIXELS; - if (softwareRenderer->winN[0].v.start > VIDEO_VERTICAL_PIXELS) { - softwareRenderer->winN[0].v.start = VIDEO_VERTICAL_PIXELS; + if (softwareRenderer->winN[0].v.end > GBA_VIDEO_VERTICAL_PIXELS) { + softwareRenderer->winN[0].v.end = GBA_VIDEO_VERTICAL_PIXELS; + if (softwareRenderer->winN[0].v.start > GBA_VIDEO_VERTICAL_PIXELS) { + softwareRenderer->winN[0].v.start = GBA_VIDEO_VERTICAL_PIXELS; } } break; case REG_WIN1V: softwareRenderer->winN[1].v.end = value; softwareRenderer->winN[1].v.start = value >> 8; - if (softwareRenderer->winN[1].v.start > VIDEO_VERTICAL_PIXELS && softwareRenderer->winN[1].v.start > softwareRenderer->winN[1].v.end) { + if (softwareRenderer->winN[1].v.start > GBA_VIDEO_VERTICAL_PIXELS && softwareRenderer->winN[1].v.start > softwareRenderer->winN[1].v.end) { softwareRenderer->winN[1].v.start = 0; } - if (softwareRenderer->winN[1].v.end > VIDEO_VERTICAL_PIXELS) { - softwareRenderer->winN[1].v.end = VIDEO_VERTICAL_PIXELS; - if (softwareRenderer->winN[1].v.start > VIDEO_VERTICAL_PIXELS) { - softwareRenderer->winN[1].v.start = VIDEO_VERTICAL_PIXELS; + if (softwareRenderer->winN[1].v.end > GBA_VIDEO_VERTICAL_PIXELS) { + softwareRenderer->winN[1].v.end = GBA_VIDEO_VERTICAL_PIXELS; + if (softwareRenderer->winN[1].v.start > GBA_VIDEO_VERTICAL_PIXELS) { + softwareRenderer->winN[1].v.start = GBA_VIDEO_VERTICAL_PIXELS; } } break; @@ -436,10 +436,10 @@ static void _breakWindow(struct GBAVideoSoftwareRenderer* softwareRenderer, stru } else if (y >= win->v.end && y < win->v.start) { return; } - if (win->h.end > VIDEO_HORIZONTAL_PIXELS || win->h.end < win->h.start) { + if (win->h.end > GBA_VIDEO_HORIZONTAL_PIXELS || win->h.end < win->h.start) { struct WindowN splits[2] = { *win, *win }; splits[0].h.start = 0; - splits[1].h.end = VIDEO_HORIZONTAL_PIXELS; + splits[1].h.end = GBA_VIDEO_HORIZONTAL_PIXELS; _breakWindowInner(softwareRenderer, &splits[0]); _breakWindowInner(softwareRenderer, &splits[1]); } else { @@ -511,7 +511,7 @@ static void _cleanOAM(struct GBAVideoSoftwareRenderer* renderer) { if (GBAObjAttributesAIsTransformed(obj.a)) { height <<= GBAObjAttributesAGetDoubleSize(obj.a); } - if (GBAObjAttributesAGetY(obj.a) < VIDEO_VERTICAL_PIXELS || GBAObjAttributesAGetY(obj.a) + height >= VIDEO_VERTICAL_TOTAL_PIXELS) { + if (GBAObjAttributesAGetY(obj.a) < GBA_VIDEO_VERTICAL_PIXELS || GBAObjAttributesAGetY(obj.a) + height >= VIDEO_VERTICAL_TOTAL_PIXELS) { int y = GBAObjAttributesAGetY(obj.a) + renderer->objOffsetY; renderer->sprites[oamMax].y = y; renderer->sprites[oamMax].endY = y + height; @@ -527,7 +527,7 @@ static void _cleanOAM(struct GBAVideoSoftwareRenderer* renderer) { static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) { struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; - if (y == VIDEO_VERTICAL_PIXELS - 1) { + if (y == GBA_VIDEO_VERTICAL_PIXELS - 1) { softwareRenderer->nextY = 0; } else { softwareRenderer->nextY = y + 1; @@ -567,21 +567,21 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; if (GBARegisterDISPCNTIsForcedBlank(softwareRenderer->dispcnt)) { int x; - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x) { + for (x = 0; x < GBA_VIDEO_HORIZONTAL_PIXELS; ++x) { row[x] = GBA_COLOR_WHITE; } return; } int x; - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; x += 4) { + for (x = 0; x < GBA_VIDEO_HORIZONTAL_PIXELS; x += 4) { softwareRenderer->spriteLayer[x] = FLAG_UNWRITTEN; softwareRenderer->spriteLayer[x + 1] = FLAG_UNWRITTEN; softwareRenderer->spriteLayer[x + 2] = FLAG_UNWRITTEN; softwareRenderer->spriteLayer[x + 3] = FLAG_UNWRITTEN; } - softwareRenderer->windows[0].endX = VIDEO_HORIZONTAL_PIXELS; + softwareRenderer->windows[0].endX = GBA_VIDEO_HORIZONTAL_PIXELS; softwareRenderer->nWindows = 1; if (GBARegisterDISPCNTIsWin0Enable(softwareRenderer->dispcnt) || GBARegisterDISPCNTIsWin1Enable(softwareRenderer->dispcnt) || GBARegisterDISPCNTIsObjwinEnable(softwareRenderer->dispcnt)) { softwareRenderer->windows[0].control = softwareRenderer->winout; @@ -676,14 +676,14 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render } #ifdef COLOR_16_BIT - for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; x += 4) { + for (x = 0; x < GBA_VIDEO_HORIZONTAL_PIXELS; x += 4) { row[x] = softwareRenderer->row[x]; row[x + 1] = softwareRenderer->row[x + 1]; row[x + 2] = softwareRenderer->row[x + 2]; row[x + 3] = softwareRenderer->row[x + 3]; } #else - memcpy(row, softwareRenderer->row, VIDEO_HORIZONTAL_PIXELS * sizeof(*row)); + memcpy(row, softwareRenderer->row, GBA_VIDEO_HORIZONTAL_PIXELS * sizeof(*row)); #endif } @@ -692,7 +692,7 @@ static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* rendere softwareRenderer->nextY = 0; if (softwareRenderer->temporaryBuffer) { - mappedMemoryFree(softwareRenderer->temporaryBuffer, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4); + mappedMemoryFree(softwareRenderer->temporaryBuffer, GBA_VIDEO_HORIZONTAL_PIXELS * GBA_VIDEO_VERTICAL_PIXELS * 4); softwareRenderer->temporaryBuffer = 0; } softwareRenderer->bg[2].sx = softwareRenderer->bg[2].refx; @@ -725,8 +725,8 @@ static void GBAVideoSoftwareRendererPutPixels(struct GBAVideoRenderer* renderer, const color_t* colorPixels = pixels; unsigned i; - for (i = 0; i < VIDEO_VERTICAL_PIXELS; ++i) { - memmove(&softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * i], &colorPixels[stride * i], VIDEO_HORIZONTAL_PIXELS * BYTES_PER_PIXEL); + for (i = 0; i < GBA_VIDEO_VERTICAL_PIXELS; ++i) { + memmove(&softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * i], &colorPixels[stride * i], GBA_VIDEO_HORIZONTAL_PIXELS * BYTES_PER_PIXEL); } } diff --git a/src/gba/video.c b/src/gba/video.c index ee9a8306c..e75d255b1 100644 --- a/src/gba/video.c +++ b/src/gba/video.c @@ -145,7 +145,7 @@ void _startHdraw(struct mTiming* timing, void* context, uint32_t cyclesLate) { case 0: GBAFrameStarted(video->p); break; - case VIDEO_VERTICAL_PIXELS: + case GBA_VIDEO_VERTICAL_PIXELS: video->p->memory.io[REG_DISPSTAT >> 1] = GBARegisterDISPSTATFillInVblank(dispstat); if (video->frameskipCounter <= 0) { video->renderer->finishFrame(video->renderer); @@ -177,14 +177,14 @@ void _startHblank(struct mTiming* timing, void* context, uint32_t cyclesLate) { // Begin Hblank dispstat = GBARegisterDISPSTATFillInHblank(dispstat); - if (video->vcount < VIDEO_VERTICAL_PIXELS && video->frameskipCounter <= 0) { + if (video->vcount < GBA_VIDEO_VERTICAL_PIXELS && video->frameskipCounter <= 0) { video->renderer->drawScanline(video->renderer, video->vcount); } - if (video->vcount < VIDEO_VERTICAL_PIXELS) { + if (video->vcount < GBA_VIDEO_VERTICAL_PIXELS) { GBADMARunHblank(video->p, -cyclesLate); } - if (video->vcount >= 2 && video->vcount < VIDEO_VERTICAL_PIXELS + 2) { + if (video->vcount >= 2 && video->vcount < GBA_VIDEO_VERTICAL_PIXELS + 2) { GBADMARunDisplayStart(video->p, -cyclesLate); } if (GBARegisterDISPSTATIsHblankIRQ(dispstat)) { diff --git a/src/platform/3ds/main.c b/src/platform/3ds/main.c index 288dc029f..8167b2b27 100644 --- a/src/platform/3ds/main.c +++ b/src/platform/3ds/main.c @@ -8,9 +8,9 @@ #include #include #ifdef M_CORE_GBA +#include #include #include -#include #endif #ifdef M_CORE_GB #include @@ -550,9 +550,9 @@ static void _drawFrame(struct mGUIRunner* runner, bool faded) { UNUSED(runner); C3D_Tex* tex = &outputTexture; - GSPGPU_FlushDataCache(outputBuffer, 256 * VIDEO_VERTICAL_PIXELS * 2); + GSPGPU_FlushDataCache(outputBuffer, 256 * GBA_VIDEO_VERTICAL_PIXELS * 2); C3D_SyncDisplayTransfer( - (u32*) outputBuffer, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS), + (u32*) outputBuffer, GX_BUFFER_DIM(256, GBA_VIDEO_VERTICAL_PIXELS), tex->data, GX_BUFFER_DIM(256, 256), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565) | diff --git a/src/platform/qt/MessagePainter.cpp b/src/platform/qt/MessagePainter.cpp index e62afe8f4..de24ade24 100644 --- a/src/platform/qt/MessagePainter.cpp +++ b/src/platform/qt/MessagePainter.cpp @@ -9,7 +9,7 @@ #include -#include +#include using namespace QGBA; @@ -39,9 +39,9 @@ void MessagePainter::resize(const QSize& size, bool lockAspectRatio, qreal scale } } m_world.reset(); - m_world.scale(qreal(drawW) / VIDEO_HORIZONTAL_PIXELS, qreal(drawH) / VIDEO_VERTICAL_PIXELS); + m_world.scale(qreal(drawW) / GBA_VIDEO_HORIZONTAL_PIXELS, qreal(drawH) / GBA_VIDEO_VERTICAL_PIXELS); m_scaleFactor = scaleFactor; - m_local = QPoint(1, VIDEO_VERTICAL_PIXELS - m_messageFont.pixelSize() - 1); + m_local = QPoint(1, GBA_VIDEO_VERTICAL_PIXELS - m_messageFont.pixelSize() - 1); m_local = m_world.map(m_local); m_local += QPoint((w - drawW) / 2, (h - drawH) / 2); m_pixmapBuffer = QPixmap(drawW * m_scaleFactor, diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index acf56669e..300d7d95c 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -65,8 +65,8 @@ #include #endif #ifdef M_CORE_GBA +#include #include -#include #endif #include #include "feature/sqlite3/no-intro.h" @@ -131,7 +131,7 @@ Window::Window(CoreManager* manager, ConfigController* config, int playerId, QWi }); #endif #if defined(M_CORE_GBA) - resizeFrame(QSize(VIDEO_HORIZONTAL_PIXELS * i, VIDEO_VERTICAL_PIXELS * i)); + resizeFrame(QSize(GBA_VIDEO_HORIZONTAL_PIXELS * i, GBA_VIDEO_VERTICAL_PIXELS * i)); #elif defined(M_CORE_GB) resizeFrame(QSize(GB_VIDEO_HORIZONTAL_PIXELS * i, GB_VIDEO_VERTICAL_PIXELS * i)); #endif @@ -580,7 +580,7 @@ void Window::resizeEvent(QResizeEvent* event) { } int factor = 0; - QSize size(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + QSize size(GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); if (m_controller) { size = m_controller->screenDimensions(); } @@ -625,8 +625,8 @@ void Window::closeEvent(QCloseEvent* event) { m_config->setQtOption("windowPos", pos()); if (m_savedScale > 0) { - m_config->setOption("height", VIDEO_VERTICAL_PIXELS * m_savedScale); - m_config->setOption("width", VIDEO_HORIZONTAL_PIXELS * m_savedScale); + m_config->setOption("height", GBA_VIDEO_VERTICAL_PIXELS * m_savedScale); + m_config->setOption("width", GBA_VIDEO_HORIZONTAL_PIXELS * m_savedScale); } saveConfig(); m_display.reset(); @@ -805,7 +805,7 @@ void Window::gameStopped() { #ifdef M_CORE_GB m_display->setMinimumSize(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS); #elif defined(M_CORE_GBA) - m_display->setMinimumSize(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + m_display->setMinimumSize(GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); #endif } @@ -909,7 +909,7 @@ void Window::reloadDisplayDriver() { #ifdef M_CORE_GB m_display->setMinimumSize(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS); #elif defined(M_CORE_GBA) - m_display->setMinimumSize(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + m_display->setMinimumSize(GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); #endif } } @@ -1410,7 +1410,7 @@ void Window::setupMenu(QMenuBar* menubar) { } connect(setSize, &QAction::triggered, [this, i, setSize]() { showNormal(); - QSize size(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); + QSize size(GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); if (m_controller) { size = m_controller->screenDimensions(); } diff --git a/src/platform/qt/main.cpp b/src/platform/qt/main.cpp index e3a958038..9c3fa5072 100644 --- a/src/platform/qt/main.cpp +++ b/src/platform/qt/main.cpp @@ -12,7 +12,7 @@ #include "Window.h" #include -#include +#include #include #include @@ -94,7 +94,7 @@ int main(int argc, char* argv[]) { freeArguments(&args); if (graphicsOpts.multiplier) { - w->resizeFrame(QSize(VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier)); + w->resizeFrame(QSize(GBA_VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, GBA_VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier)); } if (graphicsOpts.fullscreen) { w->enterFullScreen(); diff --git a/src/platform/sdl/pandora-sdl.c b/src/platform/sdl/pandora-sdl.c index ee3f33631..673d419b6 100644 --- a/src/platform/sdl/pandora-sdl.c +++ b/src/platform/sdl/pandora-sdl.c @@ -55,7 +55,7 @@ bool mSDLInit(struct SDLSoftwareRenderer* renderer) { ioctl(renderer->fb, OMAPFB_SETUP_PLANE, &plane); } - mem.size = VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4; + mem.size = GBA_VIDEO_HORIZONTAL_PIXELS * GBA_VIDEO_VERTICAL_PIXELS * 4; ioctl(renderer->fb, OMAPFB_SETUP_MEM, &mem); plane.enabled = 1; @@ -67,19 +67,19 @@ bool mSDLInit(struct SDLSoftwareRenderer* renderer) { struct fb_var_screeninfo info; ioctl(renderer->fb, FBIOGET_VSCREENINFO, &info); - info.xres = VIDEO_HORIZONTAL_PIXELS; - info.yres = VIDEO_VERTICAL_PIXELS; - info.xres_virtual = VIDEO_HORIZONTAL_PIXELS; - info.yres_virtual = VIDEO_VERTICAL_PIXELS * 2; + info.xres = GBA_VIDEO_HORIZONTAL_PIXELS; + info.yres = GBA_VIDEO_VERTICAL_PIXELS; + info.xres_virtual = GBA_VIDEO_HORIZONTAL_PIXELS; + info.yres_virtual = GBA_VIDEO_VERTICAL_PIXELS * 2; info.bits_per_pixel = 16; ioctl(renderer->fb, FBIOPUT_VSCREENINFO, &info); renderer->odd = 0; - renderer->base[0] = mmap(0, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4, PROT_READ | PROT_WRITE, MAP_SHARED, renderer->fb, 0); - renderer->base[1] = (uint16_t*) renderer->base[0] + VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS; + renderer->base[0] = mmap(0, GBA_VIDEO_HORIZONTAL_PIXELS * GBA_VIDEO_VERTICAL_PIXELS * 4, PROT_READ | PROT_WRITE, MAP_SHARED, renderer->fb, 0); + renderer->base[1] = (uint16_t*) renderer->base[0] + GBA_VIDEO_HORIZONTAL_PIXELS * GBA_VIDEO_VERTICAL_PIXELS; renderer->d.outputBuffer = renderer->base[0]; - renderer->d.outputBufferStride = VIDEO_HORIZONTAL_PIXELS; + renderer->d.outputBufferStride = GBA_VIDEO_HORIZONTAL_PIXELS; return true; } @@ -94,7 +94,7 @@ void mSDLRunloop(struct GBAThread* context, struct SDLSoftwareRenderer* renderer if (mCoreSyncWaitFrameStart(&context->sync)) { struct fb_var_screeninfo info; ioctl(renderer->fb, FBIOGET_VSCREENINFO, &info); - info.yoffset = VIDEO_VERTICAL_PIXELS * renderer->odd; + info.yoffset = GBA_VIDEO_VERTICAL_PIXELS * renderer->odd; ioctl(renderer->fb, FBIOPAN_DISPLAY, &info); int arg = 0; @@ -108,7 +108,7 @@ void mSDLRunloop(struct GBAThread* context, struct SDLSoftwareRenderer* renderer } void mSDLDeinit(struct SDLSoftwareRenderer* renderer) { - munmap(renderer->base[0], VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4); + munmap(renderer->base[0], GBA_VIDEO_HORIZONTAL_PIXELS * GBA_VIDEO_VERTICAL_PIXELS * 4); struct omapfb_plane_info plane; struct omapfb_mem_info mem;