mirror of https://github.com/mgba-emu/mgba.git
Qt: Initial mask support for transformed sprites
This commit is contained in:
parent
2743905845
commit
b99d8164dd
|
@ -81,20 +81,20 @@ struct GBAObj {
|
|||
uint16_t d;
|
||||
};
|
||||
|
||||
struct GBAOAMMatrix {
|
||||
int16_t padding0[3];
|
||||
int16_t a;
|
||||
int16_t padding1[3];
|
||||
int16_t b;
|
||||
int16_t padding2[3];
|
||||
int16_t c;
|
||||
int16_t padding3[3];
|
||||
int16_t d;
|
||||
};
|
||||
|
||||
union GBAOAM {
|
||||
struct GBAObj obj[128];
|
||||
|
||||
struct GBAOAMMatrix {
|
||||
int16_t padding0[3];
|
||||
int16_t a;
|
||||
int16_t padding1[3];
|
||||
int16_t b;
|
||||
int16_t padding2[3];
|
||||
int16_t c;
|
||||
int16_t padding3[3];
|
||||
int16_t d;
|
||||
} mat[32];
|
||||
|
||||
struct GBAOAMMatrix mat[32];
|
||||
uint16_t raw[512];
|
||||
};
|
||||
|
||||
|
|
|
@ -204,9 +204,18 @@ bool AssetView::lookupObjGBA(int id, struct ObjInfo* info) {
|
|||
GBAObjAttributesCGetPriority(obj->c),
|
||||
GBAObjAttributesBGetX(obj->b),
|
||||
GBAObjAttributesAGetY(obj->a),
|
||||
bool(GBAObjAttributesBIsHFlip(obj->b)),
|
||||
bool(GBAObjAttributesBIsVFlip(obj->b)),
|
||||
false,
|
||||
false,
|
||||
};
|
||||
if (GBAObjAttributesAIsTransformed(obj->a)) {
|
||||
int matIndex = GBAObjAttributesBGetMatIndex(obj->b);
|
||||
const GBAOAMMatrix* mat = &gba->video.oam.mat[matIndex];
|
||||
QTransform invXform(mat->a / 256., mat->c / 256., mat->b / 256., mat->d / 256., 0, 0);
|
||||
newInfo.xform = invXform.inverted();
|
||||
} else {
|
||||
newInfo.hflip = bool(GBAObjAttributesBIsHFlip(obj->b));
|
||||
newInfo.vflip = bool(GBAObjAttributesBIsVFlip(obj->b));
|
||||
}
|
||||
GBARegisterDISPCNT dispcnt = gba->memory.io[0]; // FIXME: Register name can't be imported due to namespacing issues
|
||||
if (!GBARegisterDISPCNTIsObjCharacterMapping(dispcnt)) {
|
||||
newInfo.stride = 0x20 >> (GBAObjAttributesAGet256Color(obj->a));
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QTimer>
|
||||
#include <QTransform>
|
||||
#include <QWidget>
|
||||
|
||||
#include <mgba/core/cache-set.h>
|
||||
|
@ -58,6 +59,7 @@ protected:
|
|||
unsigned y : 9;
|
||||
bool hflip : 1;
|
||||
bool vflip : 1;
|
||||
QTransform xform;
|
||||
|
||||
bool operator!=(const ObjInfo&) const;
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "FrameView.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
|
||||
#include <array>
|
||||
|
@ -177,6 +176,11 @@ void FrameView::updateTilesGBA(bool force) {
|
|||
if (info.hflip || info.vflip) {
|
||||
obj = obj.mirrored(info.hflip, info.vflip);
|
||||
}
|
||||
if (!info.xform.isIdentity()) {
|
||||
offset += QPointF(obj.width(), obj.height()) / 2;
|
||||
obj = obj.transformed(info.xform);
|
||||
offset -= QPointF(obj.width() / 2, obj.height() / 2);
|
||||
}
|
||||
m_queue.append({
|
||||
{ LayerId::SPRITE, sprite },
|
||||
!m_disabled.contains({ LayerId::SPRITE, sprite }),
|
||||
|
@ -243,7 +247,7 @@ void FrameView::injectGBA() {
|
|||
}
|
||||
QPalette palette;
|
||||
gba->video.renderer->highlightColor = palette.color(QPalette::HighlightedText).rgb();
|
||||
gba->video.renderer->highlightAmount = sin(m_glowFrame * M_PI / 30) * 64 + 64;
|
||||
gba->video.renderer->highlightAmount = sin(m_glowFrame * M_PI / 30) * 48 + 64;
|
||||
if (!m_overrideBackdrop.isValid()) {
|
||||
QRgb backdrop = M_RGB5_TO_RGB8(gba->video.palette[0]) | 0xFF000000;
|
||||
m_backdropPicker.setColor(backdrop);
|
||||
|
|
Loading…
Reference in New Issue