Compare commits

..

1 Commits

Author SHA1 Message Date
Josh Pearson
986921cc9c Preserve low res textures
Any texture less than 64x64 keep original size.  Improves building LOD texture quality, and doesn't blow VRAM budget
2025-01-09 14:07:43 -07:00
27 changed files with 226 additions and 583 deletions

View File

@@ -79,9 +79,6 @@ OBJS_TEXCONV += \
../vendor/librw/src/d3d-x/d3d.texconv.o \
../vendor/librw/src/d3d-x/d3d8.texconv.o \
../vendor/librw/src/d3d-x/d3d8render.texconv.o \
../vendor/librw/src/bmp.texconv.o \
../vendor/librw/src/png.texconv.o \
../vendor/librw/src/lodepng/lodepng.texconv.o
# Add compilation units to this list to explicity compile them with
# -O3 optimizations, while the rest get the default (-Os) treatment
@@ -319,22 +316,6 @@ TXD_OPTS_NEWS = 512 512
TXD_OPTS_SPLASH1 = 512 512
TXD_OPTS_SPLASH2 = 512 512
TXD_OPTS_SPLASH3 = 512 512
TXD_OPTS_frontend = 512 512 \
--delete-tex "fe_arrows4" \
--delete-tex "fe_arrows2" \
--delete-tex "fe_arrows1" \
--delete-tex "fe_controllersh" \
--delete-tex "fe_controller" \
\
--include-tex assets/dc_ps2d.png dc_ps2d \
--include-tex assets/dc_ps2f.png dc_ps2f \
--include-tex assets/dc_xboxd.png dc_xboxd \
--include-tex assets/dc_xboxf.png dc_xboxf \
--include-tex assets/ps4_d.png ps4_d \
--include-tex assets/ps4_f.png ps4_f \
--include-tex assets/xbox_d.png xbox_d \
--include-tex assets/xbox_f.png xbox_f
DEFAULT_RES = 512
PVR_ENCODER ?= PVRTEX

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

View File

@@ -3,7 +3,6 @@
#include <cstring>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
@@ -239,40 +238,6 @@ PluginAttach(void)
const char* currentFile;
namespace rw {
Image* readBMP(const char *filename);
Image* readPNG(const char *filename);
}
void InsertImage(RwTexDictionary* texDict, const char* file, const char* texName) {
RwTexture *tex;
RwRaster *raster;
RwInt32 width, height, depth, format;
RwImage *image = rw::readBMP(file);
if (!image) {
image = rw::readPNG(file);
}
assert(image);
RwImageFindRasterFormat(image, rwRASTERTYPETEXTURE, &width, &height, &depth, &format);
raster = RwRasterCreate(width, height, depth, format);
RwRasterSetFromImage(raster, image);
tex = RwTextureCreate(raster);
RwTextureSetName(tex, texName);
RwTextureSetFilterMode(tex, rwFILTERLINEAR);
RwTexDictionaryAddTexture(texDict, tex);
RwImageDestroy(image);
}
std::vector<std::pair<const char*, const char*>> ImagesToAdd;
std::vector<const char*> ImagesToRemove;
bool listTextures = false;
int main(int argc, const char** argv) {
if (argc >= 5) {
int width = atoi(argv[3]);
@@ -282,7 +247,7 @@ int main(int argc, const char** argv) {
if(height >= 16 && height <= 1024)
rw::dc::maxRasterHeight = height;
}
for (int i = 5; i < argc; i++) {
for (int i = 0; i < argc; i++) {
if (argv[i] != nullptr) {
// Downsample Parameter
if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "-D") == 0) {
@@ -306,22 +271,6 @@ int main(int argc, const char** argv) {
}
}
}
if (strcmp(argv[i], "--include-tex") == 0) {
assert(i + 2 < argc);
ImagesToAdd.emplace_back(argv[i+1], argv[i+2]);
i += 2;
}
if (strcmp(argv[i], "--delete-tex") == 0) {
assert(i + 1 < argc);
ImagesToRemove.emplace_back(argv[i+1]);
i += 1;
}
if (strcmp(argv[i], "--list-tex") == 0) {
listTextures = true;
}
}
}
@@ -349,31 +298,6 @@ int main(int argc, const char** argv) {
RwStreamClose(stream, nil);
if (listTextures) {
fprintf(stdout, "Incoming textures:\n");
FORLIST(lnk, texDict->textures) {
auto tex = rw::Texture::fromDict(lnk);
fprintf(stdout, "texture: '%s'\n", tex->name);
}
}
for (auto&& removedTextureName: ImagesToRemove) {
auto removedTexture = texDict->find(removedTextureName);
assert(removedTexture);
texDict->remove(removedTexture);
}
for (auto&& extraTexture: ImagesToAdd) {
InsertImage(texDict, extraTexture.first, extraTexture.second);
}
if (listTextures) {
fprintf(stdout, "Processing textures:\n");
FORLIST(lnk, texDict->textures) {
auto tex = rw::Texture::fromDict(lnk);
fprintf(stdout, "texture: '%s'\n", tex->name);
}
}
auto streamOut = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMWRITE, argv[2]);
assert(streamOut && "failed to open output");

View File

@@ -140,7 +140,7 @@ CAnimBlendNode::GetCurrentTranslation(CVector &trans, float weight)
float blend = association->GetBlendAmount(weight);
if(blend > 0.0f){
auto kfAdt = sequence->GetDeltaTime(frameA);
float t = kfAdt == 0.0f ? 0.0f : (kfAdt - remainingTime)/kfAdt;
float t = (kfAdt - remainingTime)/kfAdt;
if(sequence->type & CAnimBlendSequence::KF_TRANS){
auto kfAt = sequence->GetTranslation(frameA);
auto kfBt = sequence->GetTranslation(frameB);

View File

@@ -3789,10 +3789,6 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
if (iSound > 60)
iSound = 21;
}
// In some cases the left and right channels have different loop points
// This looks like a data file issue where the left and right channels have different loop points
// This is a hot fix to always have the correct loop point for each channel individually
SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex)
AddSampleToRequestedQueue();
}
}

View File

@@ -174,10 +174,6 @@ public:
void UpdateEffectsVolume(void);
#ifdef DC_SH4
void UpdateChannelVolume(uint32 nChannel);
#endif
void SetEffectsMasterVolume(uint8 nVolume);
void SetMusicMasterVolume (uint8 nVolume);
void SetEffectsFadeVolume (uint8 nVolume);

View File

@@ -151,6 +151,7 @@ void aica_snd_sfx_freq_vol(int chn, int freq, int vol) {
cSampleManager SampleManager;
bool8 _bSampmanInitialised = FALSE;
bool _dcAudioInitialized = false;
uint32 BankStartOffset[MAX_SFX_BANKS];
char SampleBankDescFilename[] = "sfx/sfx_all.dsc";
@@ -461,7 +462,7 @@ cSampleManager::Initialise(void)
assert(fdPedSfx >= 0);
_bSampmanInitialised = true;
_dcAudioInitialized = true;
return TRUE;
}
@@ -484,14 +485,7 @@ char cSampleManager::GetCDAudioDriveLetter(void)
void
cSampleManager::UpdateEffectsVolume(void)
{
if(_bSampmanInitialised) {
std::lock_guard<std::mutex> lk(channel_mtx);
for (int i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++) {
if (channels[i].ch != -1) {
UpdateChannelVolume(i);
}
}
}
// TODO
}
@@ -857,10 +851,9 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
return TRUE;
}
void cSampleManager::UpdateChannelVolume(uint32 nChannel) {
void updateVol(uint32 nChannel) {
auto newVol = channels[nChannel].emittingVol * channels[nChannel].attenuationVol / 255;
newVol = m_nEffectsFadeVolume * newVol * m_nEffectsVolume >> 14;
// newVol = 255;
// printf("updateVol(nChannel: %d) vol: %d, newVol: %d\n", nChannel, channels[nChannel].vol, newVol);
if (channels[nChannel].vol != newVol) {
@@ -883,7 +876,7 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
channels[nChannel].emittingVol = linearlize_volume(nVolume);// nVolume * 255 / MAX_VOLUME;
channels[nChannel].attenuationVol = 255;
UpdateChannelVolume(nChannel);
updateVol(nChannel);
verbosef("SetChannelVolume(nChannel: %d) vol: %d\n", nChannel, nVolume);
}
@@ -1139,8 +1132,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
debugf("StartStreamedFile(%d, %d, %d)\n", nFile, nPos, nStream);
uint32_t seek_aligned = 0;
if (nPos) {
uint64_t seek_bytes = (uint64_t)nPos * streams[nStream].rate / (streams[nStream].stereo ? 1000: 2000);
assert(seek_bytes <= INT32_MAX);
uint32 seek_bytes = nPos * streams[nStream].rate / (streams[nStream].stereo ? 1000: 2000);
seek_aligned = seek_bytes & ~(streams[nStream].stereo ? (STREAM_STAGING_READ_SIZE_STEREO-1) : (STREAM_STAGING_READ_SIZE_MONO-1));
}
PreloadStreamedFile(nFile, nStream, seek_aligned);
@@ -1172,9 +1164,7 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream)
ASSERT( nStream < MAX_STREAMS );
int32 rv = 0;
int64_t rv64 = (int64_t)streams[nStream].played_samples * 1000 / streams[nStream].rate;
assert(rv64 <= INT32_MAX);
rv = (int32)rv64;
return streams[nStream].played_samples * 1000 / streams[nStream].rate;
// if(streams[nStream].fd >= 0) {
// rv = fs_tell(streams[nStream].fd);
// }
@@ -1189,7 +1179,6 @@ cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffect
if (nVolume > MAX_VOLUME)
nVolume = MAX_VOLUME;
nVolume = linearlize_volume(nVolume); //nVolume * 255 / MAX_VOLUME;
nVolume = m_nMusicFadeVolume * nVolume * m_nMusicVolume >> 14;
if (streams[nStream].vol != nVolume || streams[nStream].nPan != nPan) {
streams[nStream].vol = nVolume;
streams[nStream].nPan = nPan;
@@ -1218,10 +1207,7 @@ cSampleManager::GetStreamedFileLength(uint8 nFile)
WavHeader hdr;
assert(fs_read(fd, &hdr, sizeof(hdr)) == sizeof(hdr));
uint64_t rv64 = (uint64_t)hdr.dataSize * 2000 / hdr.numOfChan / hdr.samplesPerSec;
assert(rv64 <= INT32_MAX);
rv = (int32)rv64;
rv = hdr.dataSize * 2000 / hdr.numOfChan / hdr.samplesPerSec;
fs_close(fd);
@@ -1301,17 +1287,9 @@ void cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
if (nVolume > MAX_VOLUME)
nVolume = MAX_VOLUME;
// reduce channel volume when JB.MP3 or S4_BDBD.MP3 playing
if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE
&& MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO
&& MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD )
{
nVolume /= 4;
}
std::lock_guard<std::mutex> lk(channel_mtx);
channels[nChannel].emittingVol = linearlize_volume(nVolume); // nVolume * 255 / MAX_VOLUME;
UpdateChannelVolume(nChannel);
updateVol(nChannel);
}
float calculatePan(float x, float z) {
@@ -1356,7 +1334,7 @@ void cSampleManager::SetChannel3DPosition (uint32 nChannel, float fX, float
channels[nChannel].fY = fY;
channels[nChannel].fZ = fZ;
channels[nChannel].attenuationVol = calculateAttenuation(channels[nChannel].fX, channels[nChannel].fY, channels[nChannel].fZ, channels[nChannel].distMin, channels[nChannel].distMax) * 255;
UpdateChannelVolume(nChannel);
updateVol(nChannel);
}
SetChannelPan(nChannel, calculatePan(-fX, fZ) * 63 + 64);
@@ -1369,7 +1347,7 @@ void cSampleManager::SetChannel3DDistances (uint32 nChannel, float fMax, floa
channels[nChannel].distMin = fMin;
channels[nChannel].distMax = fMax;
channels[nChannel].attenuationVol = calculateAttenuation(channels[nChannel].fX, channels[nChannel].fY, channels[nChannel].fZ, channels[nChannel].distMin, channels[nChannel].distMax) * 255;
UpdateChannelVolume(nChannel);
updateVol(nChannel);
}
#endif

View File

@@ -1721,8 +1721,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
return 0;
int attempts;
int model = -1;
int index = CGeneral::GetRandomNumberInRange(0, MAXVEHICLESLOADED);
for (attempts = 0; attempts < MAXVEHICLESLOADED; attempts++) {
int index = CGeneral::GetRandomNumberInRange(0, 50);
for (attempts = 0; attempts < 50; attempts++) {
if (model != -1)
break;
model = CStreaming::ms_vehiclesLoaded[index];

View File

@@ -2785,22 +2785,22 @@ bool CPad::WeaponJustDown(void)
case 0: //Xbox Mode
if (CPad::GetPad(0)->IsDualAnalog)
{
if (NewState.RightTrigger > 128 && !(OldState.RightTrigger > 128))
if (NewState.RightTrigger > 128)
return true;
}
else
{
if (NewState.RightTrigger > 128 && !(OldState.RightTrigger > 128))
if (NewState.RightTrigger > 128)
return true;
}
case 1: //PS2 Mode
if (CPad::GetPad(0)->IsDualAnalog)
{
return NewState.B && !OldState.B;
return NewState.B;
}
else
{
return NewState.B && !OldState.B;
return NewState.B;
}
}

View File

@@ -187,8 +187,8 @@ __always_inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#define SCREEN_HEIGHT ((float)448)
#endif
#else
extern float SCREEN_WIDTH;
extern float SCREEN_HEIGHT;
#define SCREEN_WIDTH ((float)640)
#define SCREEN_HEIGHT ((float)480)
#endif
#define SCREEN_HEIGHT_PAL ((float)512)

View File

@@ -311,7 +311,7 @@ enum Config {
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
// #define USE_TXD_CDIMAGE // generate and load textures from txd.img
// #define PS2_ALPHA_TEST // emulate ps2 alpha test
//#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
// #define DISABLE_LOADING_SCREEN // disable the loading screen which vastly improves the loading time
#ifdef DISABLE_LOADING_SCREEN
// enable the PC splash
@@ -327,7 +327,7 @@ enum Config {
//#define NEW_RENDERER // leeds-like world rendering, needs librw
#endif
// #define FIX_SPRITES // fix sprites aspect ratio(moon, coronas, particle etc) // JP - Disabled this as it produces incorrect aspect ratio with custom screen resolutions and is not needed otherwise
#define FIX_SPRITES // fix sprites aspect ratio(moon, coronas, particle etc)
#ifndef EXTENDED_COLOURFILTER
#undef SCREEN_DROPLETS // we need the backbuffer for this effect

View File

@@ -83,11 +83,6 @@ CEntity::~CEntity(void)
ResolveReferences();
}
bool
CEntity::IsFence(void) {
return IsObject() && ::IsFence(static_cast<CObject *>(this)->GetModelIndex());
}
void
CEntity::SetModelIndex(uint32 id)
{

View File

@@ -131,7 +131,6 @@ public:
bool IsPed(void) { return m_type == ENTITY_TYPE_PED; }
bool IsObject(void) { return m_type == ENTITY_TYPE_OBJECT; }
bool IsDummy(void) { return m_type == ENTITY_TYPE_DUMMY; }
bool IsFence(void);
RpAtomic *GetAtomic(void) {
assert(RwObjectGetType(m_rwObject) == rpATOMIC);

View File

@@ -59,7 +59,7 @@ CPhysical::CPhysical(void)
bInfiniteMass = false;
bIsInWater = false;
bHitByTrain = false;
bSkipLineCol = IsFence();
bSkipLineCol = false;
m_fDistanceTravelled = 0.0f;
m_treadable[PATH_CAR] = nil;
@@ -1461,10 +1461,6 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = false;
altcollision = false;
if(A->IsFence() && B->IsFence()) {
skipCollision = true;
A->bSkipLineCol = true;
}
if(B->IsBuilding())
skipCollision = false;
else if(IsStreetLight(A->GetModelIndex()) &&
@@ -1926,12 +1922,12 @@ CPhysical::ProcessCollision(void)
n = NUMSTEPS(0.09f);
step = savedTimeStep / n;
}
}else if(responsecase == COLLRESPONSE_SMALLBOX){
}else if(responsecase == COLLRESPONSE_SMALLBOX || responsecase == COLLRESPONSE_FENCEPART){
if(distSq >= sq(0.15f)){
n = NUMSTEPS(0.15f);
step = savedTimeStep / n;
}
}else if(responsecase != COLLRESPONSE_FENCEPART){
}else{
if(distSq >= sq(0.3f)){
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;

View File

@@ -41,11 +41,7 @@ CDraw::FindAspectRatio(void)
#else
switch (FrontEndMenuManager.m_PrefsUseWideScreen) {
case AR_AUTO:
#ifdef DC_SH4
return 4.0f / 3.0f;
#else
return SCREEN_WIDTH / SCREEN_HEIGHT;
#endif
default:
case AR_4_3:
return 4.0f / 3.0f;

View File

@@ -134,7 +134,7 @@ CMBlur::MotionBlurOpen(RwCamera *cam)
return TRUE;
#else
RwRect rect = { 0, 0, (rw::int32)SCREEN_WIDTH, (rw::int32)SCREEN_HEIGHT };
RwRect rect = { 0, 0, 640, 480 };
CreateImmediateModeData(cam, &rect);
return TRUE;
#endif

View File

@@ -877,6 +877,10 @@ psSelectDevice()
/* Get the default selection */
GcurSel = RwEngineGetCurrentSubSystem();
#ifdef IMPROVED_VIDEOMODE
if(FrontEndMenuManager.m_nPrefsSubsystem < GnumSubSystems)
GcurSel = FrontEndMenuManager.m_nPrefsSubsystem;
#endif
}
/* Set the driver to use the correct sub system */
@@ -885,6 +889,11 @@ psSelectDevice()
return FALSE;
}
#ifdef IMPROVED_VIDEOMODE
FrontEndMenuManager.m_nPrefsSubsystem = GcurSel;
#endif
#ifndef IMPROVED_VIDEOMODE
if ( !useDefault )
{
if ( _psGetVideoModeList()[FrontEndMenuManager.m_nDisplayVideoMode] && FrontEndMenuManager.m_nDisplayVideoMode )
@@ -894,11 +903,97 @@ psSelectDevice()
}
else
{
GcurSelVM = 0;
#ifdef DEFAULT_NATIVE_RESOLUTION
// get the native video mode
HDC hDevice = GetDC(NULL);
int w = GetDeviceCaps(hDevice, HORZRES);
int h = GetDeviceCaps(hDevice, VERTRES);
int d = GetDeviceCaps(hDevice, BITSPIXEL);
#else
const int w = 640;
const int h = 480;
const int d = 16;
#endif
while ( !modeFound && GcurSelVM < RwEngineGetNumVideoModes() )
{
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
if ( defaultFullscreenRes && vm.width != w
|| vm.height != h
|| vm.depth != d
|| !(vm.flags & rwVIDEOMODEEXCLUSIVE) )
++GcurSelVM;
else
modeFound = TRUE;
}
if ( !modeFound )
{
#ifdef DEFAULT_NATIVE_RESOLUTION
GcurSelVM = 1;
#else
printf("WARNING: Cannot find 640x480 video mode, selecting device cancelled\n");
return FALSE;
#endif
}
}
}
#else
if ( !useDefault )
{
if(FrontEndMenuManager.m_nPrefsWidth == 0 ||
FrontEndMenuManager.m_nPrefsHeight == 0 ||
FrontEndMenuManager.m_nPrefsDepth == 0){
// Defaults if nothing specified
//const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
FrontEndMenuManager.m_nPrefsWidth = 640; //mode->width;
FrontEndMenuManager.m_nPrefsHeight = 480; //mode->height;
FrontEndMenuManager.m_nPrefsDepth = 16;
FrontEndMenuManager.m_nPrefsWindowed = 0;
}
// Find the videomode that best fits what we got from the settings file
RwInt32 bestFsMode = -1;
RwInt32 bestWidth = -1;
RwInt32 bestHeight = -1;
RwInt32 bestDepth = -1;
for(GcurSelVM = 0; GcurSelVM < RwEngineGetNumVideoModes(); GcurSelVM++){
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
bestWndMode = GcurSelVM;
bestWidth = vm.width;
bestHeight = vm.height;
bestDepth = vm.depth;
bestFsMode = GcurSelVM;
break;
}
if(bestFsMode < 0){
printf("WARNING: Cannot find desired video mode, selecting device cancelled\n");
return FALSE;
}
GcurSelVM = bestFsMode;
FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
FrontEndMenuManager.m_nPrefsVideoMode = FrontEndMenuManager.m_nDisplayVideoMode;
FrontEndMenuManager.m_nSelectedScreenMode = FrontEndMenuManager.m_nPrefsWindowed;
}
#endif
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
#ifdef IMPROVED_VIDEOMODE
if (FrontEndMenuManager.m_nPrefsWindowed)
GcurSelVM = bestWndMode;
// Now GcurSelVM is 0 but vm has sizes(and fullscreen flag) of the video mode we want, that's why we changed the rwVIDEOMODEEXCLUSIVE conditions below
FrontEndMenuManager.m_nPrefsWidth = vm.width;
FrontEndMenuManager.m_nPrefsHeight = vm.height;
FrontEndMenuManager.m_nPrefsDepth = vm.depth;
#endif
#ifndef PS2_MENU
FrontEndMenuManager.m_nCurrOption = 0;
#endif
/* Set up the video mode and set the apps window
* dimensions to match */
@@ -921,6 +1016,25 @@ psSelectDevice()
}
}
*/
#ifndef IMPROVED_VIDEOMODE
if (vm.flags & rwVIDEOMODEEXCLUSIVE)
{
RsGlobal.maximumWidth = vm.width;
RsGlobal.maximumHeight = vm.height;
RsGlobal.width = vm.width;
RsGlobal.height = vm.height;
PSGLOBAL(fullScreen) = TRUE;
}
#else
RsGlobal.maximumWidth = FrontEndMenuManager.m_nPrefsWidth;
RsGlobal.maximumHeight = FrontEndMenuManager.m_nPrefsHeight;
RsGlobal.width = FrontEndMenuManager.m_nPrefsWidth;
RsGlobal.height = FrontEndMenuManager.m_nPrefsHeight;
PSGLOBAL(fullScreen) = !FrontEndMenuManager.m_nPrefsWindowed;
#endif
#ifdef MULTISAMPLING
RwD3D8EngineSetMultiSamplingLevels(1 << FrontEndMenuManager.m_nPrefsMSAALevel);
#endif

View File

@@ -10,7 +10,7 @@
# include <dc/sound/sound.h>
# endif
extern bool _bSampmanInitialised;
extern bool _dcAudioInitialized;
// ====== STATIC METHODS =====
@@ -86,7 +86,7 @@ void VmuProfiler::run() {
#ifdef DC_SH4
if(auto *dev = maple_enum_type(0, MAPLE_FUNC_MEMCARD);
dev && _bSampmanInitialised && updated_)
dev && _dcAudioInitialized && updated_)
{
pvr_stats_t pvrStats; pvr_get_stats(&pvrStats);
uint32_t sramStats = snd_mem_available();

View File

@@ -126,28 +126,6 @@ void CBulletInfo::Update(void)
}
pPed->InflictDamage(pBullet->m_pSource, pBullet->m_eWeaponType, pBullet->m_nDamage, (ePedPieceTypes)point.pieceB, pPed->GetLocalDirection(pPed->GetPosition() - point.point));
CEventList::RegisterEvent(pPed->m_nPedType == PEDTYPE_COP ? EVENT_SHOOT_COP : EVENT_SHOOT_PED, EVENT_ENTITY_PED, pPed, (CPed*)pBullet->m_pSource, 1000);
if (CGame::nastyGame) {
CVector vecParticleDirection = (point.point - pPed->GetPosition()) * 0.01f;
vecParticleDirection.z = 0.01f;
if (pPed->GetIsOnScreen()) {
for (int j = 0; j < NUM_PED_BLOOD_PARTICLES; j++)
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point.point + BLOOD_PARTICLE_OFFSET, vecParticleDirection);
}
if (pPed->GetPedState() == PED_DEAD) {
CAnimBlendAssociation* pAnim;
if (RpAnimBlendClumpGetFirstAssociation(pPed->GetClump(), ASSOC_FRONTAL))
pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_STD_HIT_FLOOR_FRONT, 8.0f);
else
pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_STD_HIT_FLOOR, 8.0f);
if (pAnim) {
pAnim->SetCurrentTime(0.0f);
pAnim->flags |= ASSOC_RUNNING;
pAnim->flags &= ~ASSOC_FADEOUTWHENDONE;
}
}
}
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
@@ -158,6 +136,31 @@ void CBulletInfo::Update(void)
bAddSound = false;
}
}
if (CGame::nastyGame) {
CVector vecParticleDirection = (point.point - pPed->GetPosition()) * 0.01f;
vecParticleDirection.z = 0.01f;
if (pPed->GetIsOnScreen()) {
for (int j = 0; j < NUM_PED_BLOOD_PARTICLES; j++)
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point.point + BLOOD_PARTICLE_OFFSET, vecParticleDirection);
}
if (pPed->GetPedState() == PED_DEAD) {
CAnimBlendAssociation* pAnim;
if (RpAnimBlendClumpGetFirstAssociation(pPed->GetClump(), ASSOC_FRONTAL))
pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_STD_HIT_FLOOR_FRONT, 8.0f);
else
pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_STD_HIT_FLOOR, 8.0f);
if (pAnim) {
pAnim->SetCurrentTime(0.0f);
pAnim->flags |= ASSOC_RUNNING;
pAnim->flags &= ~ASSOC_FADEOUTWHENDONE;
}
}
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point;
}
}
else if (pHitEntity->IsVehicle()) {
CVehicle* pVehicle = (CVehicle*)pHitEntity;

View File

@@ -29,7 +29,6 @@ extern const char* currentFile;
#include "rwdc.h"
#include "vq.h"
#include "tex-util.h"
#include "common.h"
#include <vector>
#include <set>
@@ -57,12 +56,6 @@ bool doEnvironmentMaps = true;
#define fclamp0_1(n) ((n) > 1.0f ? 1.0f : n < 0.0f ? 0.0f : n)
#define fclamp1(n) ((n) > 1.0f ? 1.0f : n)
const unsigned short VIDEO_MODES = 2;
unsigned short VIDEO_MODE = 0;
rw::VideoMode videoModes[VIDEO_MODES];
float SCREEN_WIDTH = 640;
float SCREEN_HEIGHT = 480;
struct alignas(32) pvr_vertex16_t {
uint32_t flags; /**< \brief TA command (vertex flags) */
float x; /**< \brief X coordinate */
@@ -183,6 +176,8 @@ static pvr_dr_state_t drState;
#if !defined(DC_TEXCONV) && !defined(DC_SIM)
#include <kos.h>
#define VIDEO_MODE_WIDTH vid_mode->width
#define VIDEO_MODE_HEIGHT vid_mode->height
#define mat_trans_nodiv_nomod(x, y, z, x2, y2, z2, w2) do { \
register float __x __asm__("fr12") = (x); \
@@ -293,6 +288,8 @@ void rw_mat_load_4x4(rw::Matrix* mtx) {
}
#include <dc/matrix.h>
#define VIDEO_MODE_WIDTH 640
#define VIDEO_MODE_HEIGHT 480
#define frsqrt(a) (1.0f/sqrt(a))
#define dcache_pref_block(a) __builtin_prefetch(a)
@@ -308,8 +305,6 @@ void rw_mat_load_4x4(rw::Matrix* mtx) {
#define mat_identity(a)
#define pvr_fog_table_color(a,r,g,b)
#define pvr_fog_table_linear(s,e)
#define pvr_fog_table_exp(d)
#define pvr_fog_table_custom(d)
#endif
#define mat_trans_single3_nomod(x_, y_, z_, x2, y2, z2) do { \
@@ -421,66 +416,6 @@ void leave_oix_() {
#endif
}
void enter_ocr_() {
#if defined(DC_SH4)
auto mask = irq_disable();
dcache_purge_all();
volatile uint32_t * CCN_CCR = (uint32_t *)0xFF00001C;
*CCN_CCR |= (1 << 5); // enable OCR (ORA)
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
irq_restore(mask);
#endif
}
void leave_ocr_() {
#if defined(DC_SH4)
auto mask = irq_disable();
dcache_inval_range(0x92000000, 8192);
dcache_purge_all();
volatile uint32_t * CCN_CCR = (uint32_t *)0xFF00001C;
*CCN_CCR &= ~( 1 << 5); // disable OCR (ORA)
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
irq_restore(mask);
#endif
}
#if defined(DC_SH4)
#define FLUSH_TA_DATA(src) do { __asm__ __volatile__("ocbwb @%0" : : "r" (src) : "memory"); } while(0)
#else
@@ -548,7 +483,7 @@ void DCE_MatrixViewport(float x, float y, float width, float height) {
DCE_MAT_SCREENVIEW[1][1] = height * 0.5f;
DCE_MAT_SCREENVIEW[2][2] = 1;
DCE_MAT_SCREENVIEW[3][0] = -DCE_MAT_SCREENVIEW[0][0] + x;
DCE_MAT_SCREENVIEW[3][1] = height - (DCE_MAT_SCREENVIEW[1][1] + y);
DCE_MAT_SCREENVIEW[3][1] = VIDEO_MODE_HEIGHT - (DCE_MAT_SCREENVIEW[1][1] + y);
}
void DCE_InitMatrices() {
@@ -557,7 +492,7 @@ void DCE_InitMatrices() {
mat_store(&DCE_MAT_SCREENVIEW);
DCE_MatrixViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
DCE_MatrixViewport(0, 0, VIDEO_MODE_WIDTH, VIDEO_MODE_HEIGHT);
}
}
@@ -728,10 +663,7 @@ void malloc_stats() { }
#define UNIMPL_LOGV(...)
#endif
Camera* rwdcCam;
void beginUpdate(Camera* cam) {
rwdcCam = cam;
float view[16], proj[16];
// View Matrix
@@ -807,9 +739,8 @@ std::vector<std::function<void()>> blendCallbacks;
std::vector<std::function<void()>> ptCallbacks;
void dcMotionBlur_v1(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
uint32_t col = (a << 24) | (r << 16) | (g << 8) | b;
int strip_width = SCREEN_WIDTH / 320;
int strip_mult = SCREEN_WIDTH / 640;
blendCallbacks.emplace_back([=]() {
pvr_poly_cxt_t cxt;
@@ -825,6 +756,8 @@ void dcMotionBlur_v1(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
auto addr2 = (pvr_ptr_t)&emu_vram[addr64b + 640 * 2];
#endif
PVR_SET(PVR_TEXTURE_MODULO, 640/32);
auto doquad = [=](float x, float y, float w, float h, float tx, float ty, float tw, float th) {
@@ -849,23 +782,23 @@ void dcMotionBlur_v1(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_dr_commit(vtx);
vtx = reinterpret_cast<pvr_vertex_t *>(pvr_dr_target(drState));
//vtx->flags = PVR_CMD_VERTEX;
vtx->flags = PVR_CMD_VERTEX;
vtx->x = x;
vtx->y = y+h;
//vtx->z = 1000000.0f;
vtx->z = 1000000.0f;
vtx->u = tx/1024.f;
vtx->v = (ty+th)/512.0f;
//vtx->argb = col;
vtx->argb = col;
pvr_dr_commit(vtx);
vtx = reinterpret_cast<pvr_vertex_t *>(pvr_dr_target(drState));
vtx->flags = PVR_CMD_VERTEX_EOL;
vtx->x = x+w;
vtx->y = y+h;
//vtx->z = 1000000.0f;
vtx->z = 1000000.0f;
vtx->u = (tx+tw)/1024.f;
vtx->v = (ty+th)/512.0f;
//vtx->argb = col;
vtx->argb = col;
pvr_dr_commit(vtx);
};
{
@@ -888,7 +821,7 @@ void dcMotionBlur_v1(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_dr_commit(hdr);
}
for (int x = 0; x < 320; x+=2) {
doquad(x*strip_mult, 0, strip_width, 480, x*2 + (is_bank1 ? 2 : 0), 0, 2, 480);
doquad(x, 0, 2, 480, x*2 + (is_bank1 ? 2 : 0), 0, 2, 480);
}
{
pvr_poly_cxt_txr(&cxt,
@@ -910,7 +843,7 @@ void dcMotionBlur_v1(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_dr_commit(hdr);
}
for (int x = 0; x < 320; x+=2) {
doquad(SCREEN_WIDTH/2 + x*strip_mult, 0, strip_width, 480, x*2 + (is_bank1 ? 2 : 0), 0, 2, 480);
doquad(320+x, 0, 2, 480, x*2 + (is_bank1 ? 2 : 0), 0, 2, 480);
}
});
}
@@ -953,23 +886,23 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_dr_commit(vtx);
vtx = reinterpret_cast<pvr_vertex_t *>(pvr_dr_target(drState));
//vtx->flags = PVR_CMD_VERTEX;
vtx->flags = PVR_CMD_VERTEX;
vtx->x = x;
vtx->y = y+h;
//vtx->z = z;
vtx->z = z;
vtx->u = umin;
vtx->v = vmax;
//vtx->argb = col;
vtx->argb = col;
pvr_dr_commit(vtx);
vtx = reinterpret_cast<pvr_vertex_t *>(pvr_dr_target(drState));
vtx->flags = PVR_CMD_VERTEX_EOL;
vtx->x = x+w;
vtx->y = y+h;
//vtx->z = z;
vtx->z = z;
vtx->u = umax;
vtx->v = vmax;
//vtx->argb = col;
vtx->argb = col;
pvr_dr_commit(vtx);
};
@@ -988,7 +921,7 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_poly_compile(hdr, &cxt);
pvr_dr_commit(hdr);
doquad(0.0f, 0.0f, 1e6f, SCREEN_WIDTH, 480.0f,
doquad(0.0f, 0.0f, 1e6f, 640.0f, 480.0f,
0.0f, 640.0f / 8.0f, 0.0f, 480.0f / 8.0f, mask_col);
pvr_poly_cxt_txr(&cxt, PVR_LIST_TR_POLY,
@@ -1007,10 +940,10 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_poly_compile(hdr, &cxt);
pvr_dr_commit(hdr);
doquad(0.0f, 0.0f, 2e6f, SCREEN_WIDTH / 2.0f, 480.0f,
doquad(0.0f, 0.0f, 2e6f, 320.0f, 480.0f,
0.0f, 640.0f / 1024.0f,
0.0f, 960.0f / 1024.0f, col);
doquad(SCREEN_WIDTH / 2.0f, 0.0f, 2e6f, SCREEN_WIDTH / 2.0f, 480.0f,
doquad(320.0f, 0.0f, 2e6f, 320.0f, 480.0f,
0.0f, 640.0f / 1024.0f,
1.0f / 1024.0f, 961.0f / 1024.0f, col);
@@ -1021,10 +954,10 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_poly_compile(hdr, &cxt);
pvr_dr_commit(hdr);
doquad(0.0f, 0.0f, 3e6f, SCREEN_WIDTH / 2.0f, 480.0f,
doquad(0.0f, 0.0f, 3e6f, 320.0f, 480.0f,
-1.0f / 1024.0f, 639.0f / 1024.0f,
0.0f, 960.0f / 1024.0f, col);
doquad(SCREEN_WIDTH / 2.0f, 0.0f, 3e6f, SCREEN_WIDTH / 2.0f, 480.0f,
doquad(320.0f, 0.0f, 3e6f, 320.0f, 480.0f,
-1.0f / 1024.0f, 639.0f / 1024.0f,
1.0f / 1024.0f, 961.0f / 1024.0f, col);
@@ -1040,7 +973,7 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_poly_compile(hdr, &cxt);
pvr_dr_commit(hdr);
doquad(0.0f, 0.0f, 4e6f, SCREEN_WIDTH, 480.0f,
doquad(0.0f, 0.0f, 4e6f, 640.0f, 480.0f,
0.0f, 640.0f / 8.0f, 0.0f, 480.0f / 8.0f, 0xffffffff);
cxt.blend.src = PVR_BLEND_ONE;
@@ -1050,7 +983,7 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_poly_compile(hdr, &cxt);
pvr_dr_commit(hdr);
doquad(0.0f, 0.0f, 4e6f, SCREEN_WIDTH, 480.0f,
doquad(0.0f, 0.0f, 4e6f, 640.0f, 480.0f,
0.0f, 640.0f / 8.0f, 0.0f, 480.0f / 8.0f, 0x000f0f0f);
cxt.blend.src = PVR_BLEND_INVDESTCOLOR;
@@ -1060,7 +993,7 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_poly_compile(hdr, &cxt);
pvr_dr_commit(hdr);
doquad(0.0f, 0.0f, 4e6f, SCREEN_WIDTH, 480.0f,
doquad(0.0f, 0.0f, 4e6f, 640.0f, 480.0f,
0.0f, 640.0f / 8.0f, 0.0f, 480.0f / 8.0f, 0xffffffff);
cxt.blend.dst_enable = PVR_BLEND_DISABLE;
@@ -1072,7 +1005,7 @@ void dcMotionBlur_v3(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
pvr_poly_compile(hdr, &cxt);
pvr_dr_commit(hdr);
doquad(0.0f, 0.0f, 4e6f, SCREEN_WIDTH, 480.0f,
doquad(0.0f, 0.0f, 4e6f, 640.0f, 480.0f,
0.0f, 640.0f / 8.0f, 0.0f, 480.0f / 8.0f, 0xffffffff);
});
}
@@ -1165,7 +1098,6 @@ static bool doAlphaTest;
static uint8_t fogFuncPvr = PVR_FOG_DISABLE;
static uint32_t fogColor = 0;
static float fogStart = 0.0f;
static uint32 cullModePvr;
static inline unsigned pvrCullMode(uint32_t cullMode) {
@@ -1266,9 +1198,8 @@ setRenderState(int32 state, void *pvalue)
fogFuncPvr = value ? PVR_FOG_TABLE : PVR_FOG_DISABLE;
break;
case FOGCOLOR:
#if !defined(DC_TEXCONV)
// Set fog color when state changes
if(fogColor != value || fogStart != RwCameraGetFogDistance(rwdcCam)) {
if(fogColor != value) {
fogColor = value;
RGBA c;
c.red = value;
@@ -1276,22 +1207,9 @@ setRenderState(int32 state, void *pvalue)
c.blue = value>>16;
c.alpha = value>>24;
pvr_fog_table_color(c.alpha / 255.0f, c.red / 255.0f, c.green / 255.0f, c.blue / 255.0f);
fogStart = RwCameraGetFogDistance(rwdcCam);
float fogEnd = RwCameraGetFarClipPlane(rwdcCam);
float fogIntensity[129];
uint8_t idx = 0;
float startIntensity = (-fogStart) / (fogEnd - fogStart); //interpolate between start and end to get initial intensity
float step = (1.0f - startIntensity) / 129; // we have 129 entries, create a step such that start + (step*129) = 1.0
for(int i = 128; i >= 0; i--) {
fogIntensity[i] = startIntensity + (idx++ * step);
}
pvr_fog_far_depth(fogEnd);
pvr_fog_table_custom(fogIntensity);
pvr_fog_table_linear(50.0f, 450.0f);
}
#endif
break;
// case CULLMODE:
// if(rwStateCache.cullmode != value){
// rwStateCache.cullmode = value;
@@ -2424,36 +2342,6 @@ __attribute__ ((noinline)) void submitMeshlet(uint8_t* OCR, const int8_t* indexD
} while(--indexCount);
}
template<bool textured>
__attribute__ ((noinline)) void submitMeshletFallback(uint8_t* OCR, const int8_t* indexData, uint32_t indexCount) {
struct SQBUF {
union {
uint32_t flags;
uint64_t data[4];
uint8_t data8[32];
};
};
SQBUF* sq = (SQBUF*)pvr_dr_target(drState);
static_assert(sizeof(SQBUF) == 32);
do {
auto idx = *indexData++;
auto flags = idx & 0x80 ? PVR_CMD_VERTEX_EOL : PVR_CMD_VERTEX;
auto lookup_idx = idx & 0x7F;
auto src = (SQBUF*)(OCR + lookup_idx * 64);
src[0].flags = flags;
*sq = src[0];
pvr_dr_commit(sq);
if (textured) {
*sq = src[1];
pvr_dr_commit(sq);
}
} while(--indexCount);
}
#if defined(DC_SH4)
template<>
@@ -2533,7 +2421,7 @@ __attribute__ ((noinline)) void submitMeshlet<true>(uint8_t* OCR, const int8_t*
// 8 kb in total
#if defined(DC_SH4)
uint8_t* OCR_SPACE;
uint8_t* OCR_SPACE = (uint8_t*)0x92000000;
#else
uint8_t OCR_SPACE[32 * 256] __attribute__((aligned(32)));
#endif
@@ -2764,159 +2652,6 @@ __attribute__ ((noinline)) void clipAndsubmitMeshlet(uint8_t* vertexData, const
}
};
} while(indexCount != 0);
#undef FILLVERT
#undef SUBMIT_VTX
#undef SUBMIT_INTERPOLATE
}
template<bool textured>
__attribute__ ((noinline)) void clipAndsubmitMeshletFallback(uint8_t* vertexData, const int8_t* indexData, uint32_t indexCount) {
struct SQBUF {
union {
uint32_t flags;
uint64_t data[4];
uint8_t data8[32];
};
};
static_assert(sizeof(SQBUF) == 32);
SQBUF* sq = (SQBUF*)pvr_dr_target(drState);
constexpr int8_t VERTEX = 0;
constexpr int8_t VERTEX_EOL = 0x80;
#define FILLVERT(n) \
do { \
auto idx = *indexData++; \
auto local_idx = idx & 0x7f; \
eol_now = idx & 0x80; \
auto local_ptr = (vertexData + local_idx * 64); \
vpp[n] = local_ptr; \
auto v = (const pvr_vertex64_t*)local_ptr; \
vismask >>= 1; \
if((textured?v->tex_z:v->o_b) >= -v->o_g) vismask |= 0b100; \
indexCount--; \
currentCount++; \
} while(0)
#define SUBMIT_VTX(vid, eolf) \
do { \
auto src = (SQBUF*) vpp[vid]; \
src[0].flags = eolf ? PVR_CMD_VERTEX_EOL : PVR_CMD_VERTEX; \
*sq = src[0]; \
pvr_dr_commit(sq); \
if (textured) { \
*sq = src[1]; \
pvr_dr_commit(sq); \
} \
} while(0)
#define SUBMIT_INTERPOLATE(vid1, vid2, eolf) \
do { \
sq = (SQBUF*)interpolateAndSubmit<textured>(sq, vpp[vid1], vpp[vid2], eolf ? PVR_CMD_VERTEX_EOL : PVR_CMD_VERTEX); \
} while(0)
uint32_t vismask = 0;
uint8_t* vpp[3];
int8_t eol = 0;
int8_t eol_now = 0;
do {
uint32_t currentCount = -1;
FILLVERT(0);
FILLVERT(1);
FILLVERT(2);
if (vismask & 1) {
SUBMIT_VTX(0, VERTEX);
if (vismask & 2) {
// both first verts visible
SUBMIT_VTX(1, VERTEX);
} else {
// 0 visible, 1 hidden
SUBMIT_INTERPOLATE(0, 1, VERTEX);
}
} else if (vismask & 2) {
// 0 hidden, 1 visible
SUBMIT_INTERPOLATE(1, 0, VERTEX);
SUBMIT_VTX(1, VERTEX);
}
eol = 0;
// each remaining vertex of the strip
while(!eol) {
// "ring buffery" indices
uint8_t vertZeroIdx = (currentCount - 2) % 3;
uint8_t vertOneIdx = (currentCount - 1) % 3;
uint8_t vertTwoIdx = currentCount % 3;
//dcache_pref_block(&vph[vertZeroIdx]); not sure where to put this honestly -jaxyn
eol = eol_now;
if (!vismask) {
if (!eol) {
// "ring buffery" filling
FILLVERT(vertZeroIdx);
}
continue;
}
if (vismask == 7) {
// all visible
SUBMIT_VTX(vertTwoIdx, eol);
if (!eol) {
// "ring buffery" filling
FILLVERT(vertZeroIdx);
}
continue;
}
switch (vismask) {
case 1: // 0 visible, 1 and 2 hidden
// pause strip
SUBMIT_INTERPOLATE(vertZeroIdx, vertTwoIdx, VERTEX_EOL);
break;
case 3: // 0 and 1 visible, 2 hidden
SUBMIT_INTERPOLATE(vertZeroIdx, vertTwoIdx, VERTEX);
SUBMIT_VTX(vertOneIdx, VERTEX);
case 2: // 0 hidden, 1 visible, 2 hidden
SUBMIT_INTERPOLATE(vertOneIdx, vertTwoIdx, eol);
break;
case 4: // 0 and 1 hidden, 2 visible
SUBMIT_INTERPOLATE(vertTwoIdx, vertZeroIdx, VERTEX);
if (currentCount & 0x01) { // flip directionality
case 5: // 0 visible, 1 hidden, 2 visible
SUBMIT_VTX(vertTwoIdx, VERTEX);
}
SUBMIT_INTERPOLATE(vertTwoIdx, vertOneIdx, VERTEX);
SUBMIT_VTX(vertTwoIdx, eol);
break;
case 6: // 0 hidden, 1 and 2 visible
SUBMIT_INTERPOLATE(vertTwoIdx, vertZeroIdx, VERTEX);
SUBMIT_VTX(vertOneIdx, VERTEX);
SUBMIT_VTX(vertTwoIdx, eol);
break;
default:
break;
}
if (!eol) {
// "ring buffery" filling
FILLVERT(vertZeroIdx);
}
};
} while(indexCount != 0);
#undef FILLVERT
#undef SUBMIT_VTX
#undef SUBMIT_INTERPOLATE
}
@@ -3183,26 +2918,16 @@ static constexpr void (*tnlMeshletDiffuseColorSelector[8])(uint8_t* dstCol, cons
&tnlMeshletDiffuseColor<4, true>,
};
static void (*submitMeshletSelector[2])(uint8_t* OCR, const int8_t* indexData, uint32_t indexCount) = {
static constexpr void (*submitMeshletSelector[2])(uint8_t* OCR, const int8_t* indexData, uint32_t indexCount) = {
&submitMeshlet<false>,
&submitMeshlet<true>,
};
static void (*submitMeshletSelectorFallback[2])(uint8_t* OCR, const int8_t* indexData, uint32_t indexCount) = {
&submitMeshletFallback<false>,
&submitMeshletFallback<true>,
};
static void (*clipAndsubmitMeshletSelector[2])(uint8_t* OCR, const int8_t* indexData, uint32_t indexCount) = {
static constexpr void (*clipAndsubmitMeshletSelector[2])(uint8_t* OCR, const int8_t* indexData, uint32_t indexCount) = {
&clipAndsubmitMeshlet<false>,
&clipAndsubmitMeshlet<true>,
};
static void (*clipAndsubmitMeshletSelectorFallback[2])(uint8_t* OCR, const int8_t* indexData, uint32_t indexCount) = {
&clipAndsubmitMeshletFallback<false>,
&clipAndsubmitMeshletFallback<true>,
};
static constexpr void(*tnlMeshletSkinVerticesSelector[4])(uint8_t *OCR, uint8_t *OCR_normal, const uint8_t* vertex, const uint8_t* normals, const uint8_t* skinWeights, const uint8_t* skinIndexes, int vertexCount, int vertexSize, Matrix* skinMatrices) = {
&tnlMeshletSkinVertices<false, false>,
&tnlMeshletSkinVertices<true , false>,
@@ -4162,19 +3887,19 @@ imageFindRasterFormat(Image *img, int32 type,
;
if(downsampleMode >= HALF) {
if(height / 2 >= 16) {
if(height / 2 >= 64) {
height /= 2;
}
if(width / 2 >= 16) {
if(width / 2 >= 64) {
width /= 2;
}
}
if(downsampleMode >= QUARTER) {
if(height / 2 >= 16) {
if(height / 2 >= 32) {
height /= 2;
}
if(width / 2 >= 16) {
if(width / 2 >= 32) {
width /= 2;
}
}
@@ -4523,32 +4248,6 @@ rasterToImage(Raster*)
return nil;
}
static pvr_init_params_t pvr_params = {
.opb_sizes = {
PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_8, PVR_BINSIZE_0,
PVR_BINSIZE_8
},
.vertex_buf_size = (1024 + 1024) * 1024,
.dma_enabled = 0,
.fsaa_enabled = 0,
.autosort_disabled = true,
.opb_overflow_count = 7 // 268800 bytes
};
static void makeVideoModeList() {
videoModes[0].width = 640;
videoModes[0].height = 480;
videoModes[0].depth = 16;
videoModes[0].flags = VIDEOMODEEXCLUSIVE;
videoModes[1].width = 1280;
videoModes[1].height = 480;
videoModes[1].depth = 16;
videoModes[1].flags = VIDEOMODEEXCLUSIVE;
}
int
deviceSystem(DeviceReq req, void *arg0, int32 n)
{
@@ -4577,14 +4276,14 @@ deviceSystem(DeviceReq req, void *arg0, int32 n)
// TODO: implement subsystems
case DEVICEGETVIDEOMODEINFO:{
makeVideoModeList(); // On startup this is not yet called
auto rwmode = (VideoMode*)arg0;
rwmode->width = videoModes[n].width;
rwmode->height = videoModes[n].height;
rwmode->depth = videoModes[n].depth;
rwmode->flags = videoModes[n].flags;
rwmode->width = 640;
rwmode->height = 480;
rwmode->depth = 16;
rwmode->flags = VIDEOMODEEXCLUSIVE;
return 1;
}
}
case DEVICEGETMAXMULTISAMPLINGLEVELS:
{
@@ -4597,21 +4296,11 @@ deviceSystem(DeviceReq req, void *arg0, int32 n)
case DEVICESETSUBSYSTEM:
return 1;
case DEVICEGETNUMVIDEOMODES:
return VIDEO_MODES;
return 1;
case DEVICEGETCURRENTVIDEOMODE:
return VIDEO_MODE;
return 0;
case DEVICESETVIDEOMODE:
{
makeVideoModeList(); // On startup this is called before driverOpen
VIDEO_MODE = n;
SCREEN_WIDTH = videoModes[VIDEO_MODE].width;
SCREEN_HEIGHT = videoModes[VIDEO_MODE].height;
pvr_params.fsaa_enabled = n;
return 1;
}
return 1;
default:
assert(0 && "not implemented");
return 0;
@@ -4639,7 +4328,15 @@ Device renderdevice = {
deviceSystem
};
static pvr_init_params_t pvr_params = {
.opb_sizes = {
PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_8, PVR_BINSIZE_0,
PVR_BINSIZE_8
},
.vertex_buf_size = (1024 + 1024) * 1024,
.autosort_disabled = true,
.opb_overflow_count = 7 // 268800 bytes
};
void defaultInstance(ObjPipeline *pipe, Atomic *atomic) {
#if defined(DC_TEXCONV)
@@ -4665,36 +4362,6 @@ ObjPipeline* makeDefaultPipeline(void)
static void*
driverOpen(void *o, int32, int32)
{
makeVideoModeList();
#if defined(DC_SH4)
OCR_SPACE = (uint8_t*)0x92000000;
bool has_oix = true;
enter_oix();
*(volatile uint8_t*)OCR_SPACE = 1;
if (*(volatile uint8_t*)OCR_SPACE != 1) {
has_oix = false;
}
leave_oix();
if (!has_oix) {
dbglog(DBG_CRITICAL, "You appear to be using an emulator that does not support OIX. Attempting fallback to OCR\n");
OCR_SPACE = (uint8_t*)0x7c001000;
enter_oix = (void(*)())(((uintptr_t)&enter_ocr_) - 0x8c000000 + 0xAc000000);
leave_oix = (void(*)())(((uintptr_t)&leave_ocr_) - 0x8c000000 + 0xAc000000);
for (size_t i = 0; i < ARRAY_SIZE(submitMeshletSelector); i++) {
submitMeshletSelector[i] = submitMeshletSelectorFallback[i];
}
for (size_t i = 0; i < ARRAY_SIZE(clipAndsubmitMeshletSelector); i++) {
clipAndsubmitMeshletSelector[i] = clipAndsubmitMeshletSelectorFallback[i];
}
}
#endif
pvr_init(&pvr_params);
fake_tex = pvr_mem_malloc(sizeof(fake_tex_data));
@@ -4730,8 +4397,6 @@ driverClose(void *o, int32, int32)
{
pvr_mem_free(fake_tex);
pvr_shutdown();
return o;
}