Skip to content

Commit 222710f

Browse files
committed
(hack) expose ps1 semi-transparent bit, previews lie less
1 parent e30baca commit 222710f

12 files changed

+96
-14
lines changed

palmod/ColorSystem.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ namespace ColorSystem
6565
case ColMode::COLMODE_GRB555_LE:
6666
case ColMode::COLMODE_BRG555_LE:
6767
case ColMode::COLMODE_RGB666_NEOGEO:
68+
case ColMode::COLMODE_BGR555STB_LE:
6869
return 2;
6970

7071
case ColMode::COLMODE_BGR888:
@@ -117,6 +118,7 @@ namespace ColorSystem
117118
{ "BRG888", ColMode::COLMODE_BRG888 },
118119
{ "xBGR555LE", ColMode::COLMODE_xBGR555_LE }, // Different packing used by Asura Buster / Fuuki
119120
{ "BRG555LE", ColMode::COLMODE_BRG555_LE }, // BRG555 little endian, used by Fists of Fury
121+
{ "BGR555STB_LE", ColMode::COLMODE_BGR555STB_LE },
120122
};
121123

122124
bool GetColorFormatForColorFormatString(LPCSTR paszColorString, ColMode& cmColorMode)
@@ -253,6 +255,7 @@ namespace ColorSystem
253255
case ColMode::COLMODE_GRB555_LE:
254256
case ColMode::COLMODE_BRG555_LE:
255257
case ColMode::COLMODE_RGB555_SHARP:
258+
case ColMode::COLMODE_BGR555STB_LE:
256259
return k_nRGBPlaneAmtForRGB555;
257260

258261
case ColMode::COLMODE_RGB666_NEOGEO:
@@ -418,6 +421,61 @@ namespace ColorSystem
418421
return (((auxr >> 3) & 31) | (((auxg >> 3) & 31) << 5) | (((auxb >> 3) & 31) << 10)) | (auxa << 15);
419422
}
420423

424+
uint32_t CONV_BGR555STBLE_32(uint16_t inCol)
425+
{
426+
if (inCol == 0x0000) {
427+
return 0x00000000;
428+
} else if (inCol == 0x8000) {
429+
return 0xFF000000;
430+
}
431+
432+
uint32_t red = (inCol & 31) << 3;
433+
uint32_t green = ((inCol >> 5) & 31) << 3;
434+
uint32_t blue = ((inCol >> 10) & 31) << 3;
435+
uint32_t alpha = ((inCol >> 15) & 1) << 3;
436+
437+
// account for rounding
438+
red += red / 32;
439+
green += green / 32;
440+
blue += blue / 32;
441+
442+
if (alpha == 0x8)
443+
{
444+
alpha = 0x7F;
445+
}
446+
else
447+
{
448+
alpha = 0xFF;
449+
}
450+
451+
return ((alpha << 24) | (blue << 16) | (green << 8) | (red));
452+
}
453+
454+
uint16_t CONV_32_BGR555STBLE(uint32_t inCol)
455+
{
456+
if (inCol == 0x00000000) {
457+
return 0x0000;
458+
} else if (inCol == 0xFF000000) {
459+
return 0x8000;
460+
}
461+
462+
uint16_t auxa = ((inCol & 0xFF000000) >> 24);
463+
uint16_t auxb = ((inCol & 0x00FF0000) >> 16);
464+
uint16_t auxg = ((inCol & 0x0000FF00) >> 8);
465+
uint16_t auxr = ((inCol & 0x000000FF));
466+
467+
if (CurrAlphaMode == AlphaMode::GameDoesNotUseAlpha)
468+
{
469+
auxa = 0;
470+
}
471+
else
472+
{
473+
auxa = (auxa == 0x7F) ? 0x1 : 0;
474+
}
475+
476+
return (((auxr >> 3) & 31) | (((auxg >> 3) & 31) << 5) | (((auxb >> 3) & 31) << 10)) | (auxa << 15);
477+
}
478+
421479
uint32_t CONV_BGR555BE_32(uint16_t inCol)
422480
{
423481
return CONV_BGR555LE_32(_byteswap_ushort(inCol));

palmod/ColorSystem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ enum class ColMode
5656

5757
COLMODE_BRG555_LE, // used by Fists of Fury
5858

59+
COLMODE_BGR555STB_LE, // semi-transparency bit for ps1
60+
5961
COLMODE_LAST,
6062
};
6163

@@ -105,6 +107,8 @@ namespace ColorSystem
105107
uint32_t CONV_GRB555LE_32(uint16_t inCol);
106108
uint16_t CONV_32_BRG555LE(uint32_t inCol);
107109
uint32_t CONV_BRG555LE_32(uint16_t inCol);
110+
uint16_t CONV_32_BGR555STBLE(uint32_t inCol);
111+
uint32_t CONV_BGR555STBLE_32(uint16_t inCol);
108112

109113
// Lookup tables
110114
uint16_t CONV_32_RGB666NeoGeo(uint32_t inCol);

palmod/Game/GameClass.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ bool CGameClass::_UpdateColorSteps(ColMode NewMode)
127127
{
128128
bool fSuccess = true;
129129

130-
static_assert((ColMode)28 == ColMode::COLMODE_LAST, "New color formats require updating the color steps code.");
130+
static_assert((ColMode)29 == ColMode::COLMODE_LAST, "New color formats require updating the color steps code.");
131131

132132
switch (NewMode)
133133
{
@@ -165,6 +165,7 @@ bool CGameClass::_UpdateColorSteps(ColMode NewMode)
165165
break;
166166

167167
case ColMode::COLMODE_BGR555_LE:
168+
case ColMode::COLMODE_BGR555STB_LE:
168169
case ColMode::COLMODE_BGR555_BE:
169170
case ColMode::COLMODE_xBGR555_LE:
170171
case ColMode::COLMODE_RGB555_LE:
@@ -272,7 +273,7 @@ bool CGameClass::_UpdateColorConverters(ColMode NewMode)
272273
{
273274
bool fSuccess = true;
274275

275-
static_assert((ColMode)28 == ColMode::COLMODE_LAST, "New color formats require updating the color converter code.");
276+
static_assert((ColMode)29 == ColMode::COLMODE_LAST, "New color formats require updating the color converter code.");
276277

277278
switch (NewMode)
278279
{
@@ -314,6 +315,10 @@ bool CGameClass::_UpdateColorConverters(ColMode NewMode)
314315
ConvPal16 = &ColorSystem::CONV_BGR555LE_32;
315316
ConvCol16 = &ColorSystem::CONV_32_BGR555LE;
316317
break;
318+
case ColMode::COLMODE_BGR555STB_LE:
319+
ConvPal16 = &ColorSystem::CONV_BGR555STBLE_32;
320+
ConvCol16 = &ColorSystem::CONV_32_BGR555STBLE;
321+
break;
317322
case ColMode::COLMODE_BGR555_BE:
318323
ConvPal16 = &ColorSystem::CONV_BGR555BE_32;
319324
ConvCol16 = &ColorSystem::CONV_32_BGR555BE;

palmod/Game/GameDef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ enum SupportedGamesList
4949
DUMMY_RGBA8881 = 85,
5050
DUMMY_RGBA8888_LE = 86,
5151

52+
DUMMY_BGR555STB_LE,
53+
5254
NUM_GAMES // This needs to be last
5355
};
5456

@@ -151,6 +153,7 @@ const wchar_t g_GameFriendlyName[][64] =
151153
L"",
152154
L"DUMMY_RGBA8881",
153155
L"DUMMY_RGB8888LE",
156+
L"DUMMY_BGR555STB_LE"
154157
};
155158

156159
static_assert(ARRAYSIZE(g_GameFriendlyName) == NUM_GAMES, "The gameId enum and the descriptors in g_GameFriendlyName must match length.");

palmod/Game/Game_DevMode_DIR.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,12 @@ bool CGame_DevMode_DIR::SetAlphaAndColorModeInternal(ColMode NewMode, AlphaMode
628628
// ID_COLORFORMAT_BGR555_BE
629629
// ID_COLORFORMAT_xBGR555_LE
630630
// ID_COLORFORMAT_BRG555_LE
631+
// ID_COLORFORMAT_BGR555STB_LE
631632
// I am explicitly and needlessly listing out all of those string IDs because Visual Studio search sometimes misses the color modes below,
632633
// and we have to add explicit color handling here so that people can change to that color mode in Unknown Game mode
633634

634635
// Update this check once you've decided whether to expose the new color or not.
635-
static_assert((ColMode)28 == ColMode::COLMODE_LAST, "New color formats usually mean updating color selectability in the Developer Mode support.");
636+
static_assert((ColMode)29 == ColMode::COLMODE_LAST, "New color formats usually mean updating color selectability in the Developer Mode support.");
636637

637638
switch (NewMode)
638639
{
@@ -660,6 +661,7 @@ bool CGame_DevMode_DIR::SetAlphaAndColorModeInternal(ColMode NewMode, AlphaMode
660661
case ColMode::COLMODE_RGB555_LE:
661662
case ColMode::COLMODE_xBGR555_LE:
662663
case ColMode::COLMODE_RGB555_BE:
664+
case ColMode::COLMODE_BGR555STB_LE:
663665
cbRequiredColorSize = 2;
664666
suggestedAlphaSetting = AlphaMode::GameUsesFixedAlpha;
665667
m_fGameUsesAlphaValue = true;

palmod/Game/Game_LandMaker_P.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ class CGame_LandMaker_P : public CGameClassPerUnitPerFile
1313
LandMaker_P_IMGIDS_USED,
1414
{ NO_SPECIAL_OPTIONS, PALWriteOutputOptions::WRITE_MAX },
1515
eImageOutputSpriteDisplay::DISPLAY_SPRITES_LEFTTORIGHT,
16-
AlphaMode::GameDoesNotUseAlpha,
17-
ColMode::COLMODE_BGR555_LE,
16+
AlphaMode::GameUsesVariableAlpha,
17+
ColMode::COLMODE_BGR555STB_LE,
1818
LandMaker_P_CharacterData,
1919
PaletteArrangementStyle::OneButtonLabelEntryPerEachNode,
2020
0x40,
2121
};
2222

2323

2424
public:
25-
CGame_LandMaker_P(uint32_t nConfirmedROMSize) { InitializeGame(nConfirmedROMSize, m_sCoreGameData); };
25+
CGame_LandMaker_P(uint32_t nConfirmedROMSize) { InitializeGame(nConfirmedROMSize, m_sCoreGameData);
26+
AllowTransparencyEdits(TRUE);
27+
};
2628
~CGame_LandMaker_P() { ClearDataBuffer(); FlushChangeTrackingArray(); };
2729

2830
static sFileRule GetRule(uint32_t nRuleId) { return CGameClassPerUnitPerFile::GetRule(nRuleId, LandMaker_P_CharacterData);

palmod/Game/Game_NEOGEO_A.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,12 @@ bool CGame_NEOGEO_A::SetAlphaAndColorModeInternal(ColMode NewMode, AlphaMode Cur
159159
// ID_COLORFORMAT_BGR555_BE
160160
// ID_COLORFORMAT_xBGR555_LE
161161
// ID_COLORFORMAT_BRG555_LE
162+
// ID_COLORFORMAT_BGR555STB_LE
162163
// I am explicitly and needlessly listing out all of those string IDs because Visual Studio search sometimes misses the color modes below,
163164
// and we have to add explicit color handling here so that people can change to that color mode in Unknown Game mode
164165

165166
// Update this check once you've decided whether to expose the new color or not.
166-
static_assert((ColMode)28 == ColMode::COLMODE_LAST, "New color formats usually mean updating color selectability in the Developer Mode support.");
167+
static_assert((ColMode)29 == ColMode::COLMODE_LAST, "New color formats usually mean updating color selectability in the Developer Mode support.");
167168

168169
switch (NewMode)
169170
{
@@ -191,6 +192,7 @@ bool CGame_NEOGEO_A::SetAlphaAndColorModeInternal(ColMode NewMode, AlphaMode Cur
191192
case ColMode::COLMODE_RGB555_LE:
192193
case ColMode::COLMODE_xBGR555_LE:
193194
case ColMode::COLMODE_RGB555_BE:
195+
case ColMode::COLMODE_BGR555STB_LE:
194196
cbRequiredColorSize = 2;
195197
suggestedAlphaSetting = AlphaMode::GameUsesFixedAlpha;
196198
m_fGameUsesAlphaValue = true;

palmod/PalMod.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ BEGIN
517517
MENUITEM "RGB444 (big endian for CPS1/CPS2)", ID_COLORFORMAT_RGB444_BE
518518
MENUITEM "RGB444 (little endian for SF2/SFA 30th)", ID_COLORFORMAT_RGB444_LE
519519
MENUITEM SEPARATOR
520-
MENUITEM "BGR555 (little endian for GBA, most PSX, SNES)", ID_COLORFORMAT_BGR555_LE
520+
MENUITEM "BGR555 (little endian for GBA, SNES)", ID_COLORFORMAT_BGR555_LE
521+
MENUITEM "BGR555 (little endian for most PSX)", ID_COLORFORMAT_BGR555STB_LE
521522
MENUITEM "BGR555 (little endian for Fuuki)", ID_COLORFORMAT_xBGR555_LE
522523
MENUITEM "BGR555 (big endian for Motorola 68000)", ID_COLORFORMAT_BGR555_BE
523524
MENUITEM "BRG555 (little endian)", ID_COLORFORMAT_BRG555_LE

palmod/PalModDlg.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void CPalModDlg::DoDataExchange(CDataExchange* pDX)
126126
#pragma warning( push )
127127
#pragma warning( disable : 26454 ) // bug in Microsoft headers
128128

129-
static_assert((ColMode)28 == ColMode::COLMODE_LAST, "New color formats need menu command handlers added to the message map.");
129+
static_assert((ColMode)29 == ColMode::COLMODE_LAST, "New color formats need menu command handlers added to the message map.");
130130

131131
// CPalModDlg message handlers
132132
BEGIN_MESSAGE_MAP(CPalModDlg, CDialog)
@@ -207,7 +207,8 @@ BEGIN_MESSAGE_MAP(CPalModDlg, CDialog)
207207
ON_COMMAND(ID_COLORFORMAT_RGB555_LE, &CPalModDlg::SetColorFormatToRGB555_LE)
208208
ON_COMMAND(ID_COLORFORMAT_RGB555_BE, &CPalModDlg::SetColorFormatToRGB555_BE)
209209
ON_COMMAND(ID_COLORFORMAT_xBGR555_LE, &CPalModDlg::SetColorFormatToxBGR555_LE)
210-
210+
ON_COMMAND(ID_COLORFORMAT_BGR555STB_LE, &CPalModDlg::SetColorFormatToBGR555STB_LE)
211+
211212

212213
ON_COMMAND(ID_COLORFORMAT_RGB666, &CPalModDlg::SetColorFormatToNEOGEO)
213214
ON_COMMAND(ID_COLORFORMAT_SHARPRGB, &CPalModDlg::SetColorFormatToSharpRGB)

palmod/PalModDlg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class CPalModDlg : public CDialog
109109
void SetColorsPerLineTo16();
110110
void SetColorFormatTo(ColMode newColMode);
111111

112-
static_assert((ColMode)28 == ColMode::COLMODE_LAST, "New color formats need functions backing their menu command added here.");
112+
static_assert((ColMode)29 == ColMode::COLMODE_LAST, "New color formats need functions backing their menu command added here.");
113113

114114
void SetColorFormatToBGR333() { SetColorFormatTo(ColMode::COLMODE_BGR333); };
115115
void SetColorFormatToRBG333() { SetColorFormatTo(ColMode::COLMODE_RBG333); };
@@ -128,6 +128,7 @@ class CPalModDlg : public CDialog
128128
void SetColorFormatToRGB555_BE() { SetColorFormatTo(ColMode::COLMODE_RGB555_BE); };
129129
void SetColorFormatToRGB555_LE() { SetColorFormatTo(ColMode::COLMODE_RGB555_LE); };
130130
void SetColorFormatToxBGR555_LE() { SetColorFormatTo(ColMode::COLMODE_xBGR555_LE); };
131+
void SetColorFormatToBGR555STB_LE() { SetColorFormatTo(ColMode::COLMODE_BGR555STB_LE); };
131132

132133
void SetColorFormatToNEOGEO() { SetColorFormatTo(ColMode::COLMODE_RGB666_NEOGEO); };
133134
void SetColorFormatToSharpRGB() { SetColorFormatTo(ColMode::COLMODE_RGB555_SHARP); };

0 commit comments

Comments
 (0)