Skip to content

Commit

Permalink
3DS: begin conversion from RGBA8888 to RGB565
Browse files Browse the repository at this point in the history
  • Loading branch information
BallM4788 committed Nov 13, 2019
1 parent 4952d1c commit 5272ad2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backends/platform/3ds/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

int main(int argc, char *argv[]) {
// Initialize basic libctru stuff
gfxInitDefault();
gfxInit(GSP_RGB565_OES, GSP_RGB565_OES, false);
cfguInit();
romfsInit();
osSetSpeedupEnable(true);
Expand Down
16 changes: 8 additions & 8 deletions backends/platform/3ds/osystem-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@
// Used to transfer the final rendered display to the framebuffer
#define DISPLAY_TRANSFER_FLAGS \
(GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | \
GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | \
GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \
GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) | \
GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565) | \
GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))

namespace _3DS {

void OSystem_3DS::initGraphics() {
_pfGame = Graphics::PixelFormat::createFormatCLUT8();
_pfGameTexture = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
_pfGameTexture = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);

C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);

// Initialize the render targets
_renderTargetTop =
C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
C3D_RenderTargetCreate(240, 400, GPU_RB_RGB565, GPU_RB_DEPTH24_STENCIL8);
C3D_RenderTargetClear(_renderTargetTop, C3D_CLEAR_ALL, 0x0000000, 0);
C3D_RenderTargetSetOutput(_renderTargetTop, GFX_TOP, GFX_LEFT,
DISPLAY_TRANSFER_FLAGS);

_renderTargetBottom =
C3D_RenderTargetCreate(240, 320, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
C3D_RenderTargetCreate(240, 320, GPU_RB_RGB565, GPU_RB_DEPTH24_STENCIL8);
C3D_RenderTargetClear(_renderTargetBottom, C3D_CLEAR_ALL, 0x00000000, 0);
C3D_RenderTargetSetOutput(_renderTargetBottom, GFX_BOTTOM, GFX_LEFT,
DISPLAY_TRANSFER_FLAGS);
Expand Down Expand Up @@ -217,8 +217,8 @@ void OSystem_3DS::updateSize() {

Common::List<Graphics::PixelFormat> OSystem_3DS::getSupportedFormats() const {
Common::List<Graphics::PixelFormat> list;
list.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); // GPU_RGBA8
list.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); // GPU_RGB565
list.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); // GPU_RGBA8
// list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0)); // GPU_RGB8
list.push_back(Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); // RGB555 (needed for FMTOWNS?)
list.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); // GPU_RGBA5551
Expand Down Expand Up @@ -640,12 +640,12 @@ void OSystem_3DS::setCursorPalette(const byte *colors, uint start, uint num) {
namespace {
template<typename SrcColor>
void applyKeyColor(Graphics::Surface *src, Graphics::Surface *dst, const SrcColor keyColor) {
assert(dst->format.bytesPerPixel == 4);
assert(dst->format.bytesPerPixel == 2);
assert((dst->w >= src->w) && (dst->h >= src->h));

for (uint y = 0; y < src->h; ++y) {
SrcColor *srcPtr = (SrcColor *)src->getBasePtr(0, y);
uint32 *dstPtr = (uint32 *)dst->getBasePtr(0, y);
uint16 *dstPtr = (uint16 *)dst->getBasePtr(0, y);

for (uint x = 0; x < src->w; ++x) {
const SrcColor color = *srcPtr++;
Expand Down
2 changes: 1 addition & 1 deletion backends/platform/3ds/sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Sprite::create(uint16 width, uint16 height, const Graphics::PixelFormat &f)

if (width && height) {
pixels = linearAlloc(h * pitch);
C3D_TexInit(&texture, w, h, GPU_RGBA8);
C3D_TexInit(&texture, w, h, GPU_RGB565);
C3D_TexSetFilter(&texture, GPU_LINEAR, GPU_LINEAR);
assert(pixels && texture.data);
clear();
Expand Down
2 changes: 1 addition & 1 deletion backends/platform/3ds/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define TEXTURE_TRANSFER_FLAGS \
(GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | \
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGBA8) | \
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565) | \
GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))

typedef struct {
Expand Down

0 comments on commit 5272ad2

Please sign in to comment.